Hi,

I'm trying to load the markers via ajax. The markers are added to the Drupal.settings.gmap['mapid']['markers'] successfully (I copied the gmap_location_node_page() in the gmap_location.module to populate the markers ).

I use the following code to refresh the map with new marker data.

var map = Drupal.gmap.getMap('mapid');
map.map.clearOverlays();
map.change('iconsready', -1);

This works, but the autozoom functionality is not working. I'm also not sure whether this is the right way to do this kind of stuff with gmap module. Please advice.

Thanks,

~vimal

Comments

vimaljoseph’s picture

Any advice on how to clear and redraw markers for pages that load data via ajax?

kossumov’s picture

Issue summary: View changes

Could you figure out how to do this?

james.williams’s picture

Here's some javascript I used (more or less) that might fit what you're trying to do:

      var mapid = 'auto1map'; // @TODO Get the ID however else you need to rather than hardcoding it.
      delete Drupal.gmap.getMap(mapid).vars.markers;
      Drupal.gmap.getMap(mapid).change('clearmarkers', -1);

The iconsready event handler in markerloader_static.js respects when markers in the vars property are still set. They get set within the 'addmarker' event handler in marker.js, but they don't get cleared up by anything that I can see, so you have to do it manually. I then fired the clearmarkers event to be sure (though you won't need to do this if it's already done for you by other code running on the same event).