Revision #2 has been created by Chris Backhouse on Oct 5, 2015, 11:12:49 AM with the memo:
correct typos and add comments
« previous (#1)
Changes
Title
unchanged
Simple Google Maps object for use with ajax maps
Category
unchanged
How-tos
Yii version
unchanged
Tags
unchanged
googlemap, maps
Content
changed
The Google mapping extension by Dos Amigos ([link](https://github.com/2amigos/yii2-google-maps-library "link")) is really great but there are difficulties with Google maps when you want to manipulate your map object with Ajax.
Thanks to some core code from Dos Amigos, I have fashioned a simpler way to manage ajax manipulation of Google maps.[...]
The method described here enables you to create a map canvas and then update it over time with Ajax calls.
First, create an javascript file with the following code
~~~[...]
gmap0.clearMarkers();
$.getScript( link , function( data, textStatus, jqxhr ) {
// refresh map to get it to display new markers
// you can also use this. if you need to refresh the map eg: when changing tabs
setTimeout(function() {map = gmap0.getMap(); var center = map.getCenter(); google.maps.event.trigger(map, 'resize'); map.setCenter(center);}, 500);
});
~~~
example of action-that-returns-just-javascript[...]