Active
Project:
GMap Module
Version:
6.x-1.1
Component:
Code
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
15 Jul 2011 at 09:18 UTC
Updated:
2 Mar 2017 at 13:24 UTC
Jump to comment: Most recent
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
Comment #1
vimaljoseph commentedAny advice on how to clear and redraw markers for pages that load data via ajax?
Comment #2
kossumov commentedCould you figure out how to do this?
Comment #3
james.williamsHere'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).