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

Feature request: Export map object to window #29

Closed loretoparisi closed 8 years ago

loretoparisi commented 8 years ago

This issue is related to https://github.com/rochacbruno/Flask-GoogleMaps/issues/27

function initialize_{{gmap.varname}}() {
               var {{gmap.varname}} = new google.maps.Map(
                         document.getElementById('{{gmap.identifier}}') )
       //...

Please add an option to export the var {{gmap.varname}} as a window var like

var {{gmap.varname}} = new google.maps.Map(
                         document.getElementById('{{gmap.identifier}}') )
window[{{gmap.varname}}]={{gmap.varname}}

In this way it will be possible to add markers from the page like

var marker = new google.maps.Marker({
    position: myLatlng,
    title:"Hello World!"
});

// To add the marker to the map, call setMap();
marker.setMap(window.map);
rochacbruno commented 8 years ago

Done! using a global variable. Thanks.