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

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)


Title unchanged

Simple Google Maps object for use with ajax maps

Category unchanged


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

$.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
Viewed: 12 439 times
Version: 2.0
Category: How-tos
Written by: Chris Backhouse
Last updated by: Chris Backhouse
Created on: Oct 5, 2015
Last updated: 4 years ago
Update Article


View all history