flask-extensions / Flask-GoogleMaps

Easy way to add GoogleMaps to Flask applications. maintainer: @getcake
https://flask-googlemaps.com
MIT License
647 stars 196 forks source link

Can you please provide some example of js files? #40

Open BronzeCrab opened 8 years ago

BronzeCrab commented 8 years ago

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

rochacbruno commented 8 years ago

@BronzeCrab which JS files are you referring?

BronzeCrab commented 8 years ago

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

rochacbruno commented 8 years ago

@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.

BronzeCrab commented 8 years ago

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