Difference between #1 and #2 of
Simple Google Maps object for use with ajax maps

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 a
n 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
[...]
0 0
3 followers
Viewed: 16 416 times
Version: 2.0
Category: How-tos
Written by: Chris Backhouse
Last updated by: Chris Backhouse
Created on: Oct 5, 2015
Last updated: 8 years ago
Update Article

Revisions

View all history