Flask-GoogleMaps icon indicating copy to clipboard operation
Flask-GoogleMaps copied to clipboard

Can you please provide some example of js files?

Open BronzeCrab opened this issue 8 years ago • 4 comments

Please add some examples of js files, like fullmap.js

BronzeCrab avatar Aug 31 '16 19:08 BronzeCrab

@BronzeCrab which JS files are you referring?

rochacbruno avatar Aug 31 '16 19:08 rochacbruno

https://github.com/rochacbruno/Flask-GoogleMaps/blob/master/examples/templates/example_fullmap.html here fullmap.js

BronzeCrab avatar Aug 31 '16 19:08 BronzeCrab

@BronzeCrab that {{fullmap.js}} is a template tag which will render the JS content of https://github.com/rochacbruno/Flask-GoogleMaps/blob/master/flask_googlemaps/templates/googlemaps/gmapjs.html replacing variables with values provided in the fullmap view.

rochacbruno avatar Aug 31 '16 20:08 rochacbruno

Ok, I see. Can I somehow paste gmapjs.html into my repo, so I want it to be part of my project, because I want to add some logic in it. Is it possible? Or maybe can I modify map after work of gmapjs.html? I've tried to do it like so:

{% block additional_head %}
    {{ estates_map.js }}
{% endblock %}

{% block page_content %}

<script type="text/javascript">

$(document).ready(function () { initialize();  });

    function initialize() {
        if (navigator.geolocation) {
            navigator.geolocation.getCurrentPosition(function(position) {
                estates_map.setCenter(new google.maps.LatLng(
                    position.coords.latitude, position.coords.longitude));
            });
        }
        else {
            estates_map.setCenter(new google.maps.LatLng(55.7558, 37.6173));  
        }
    }
</script>
...
{{estates_map.html}}

but I have error: Uncaught TypeError: estates_map.setCenter is not a function

BronzeCrab avatar Sep 03 '16 08:09 BronzeCrab