Remove Google Marker on Kentico Google Map

Witchayanin Maythangkul asked on September 11, 2014 13:50

How can I remove a marker in google map webpart by javascript ?

Recent Answers


Joshua Adams answered on September 11, 2014 20:04

Does this link help?

https://developers.google.com/maps/documentation/javascript/examples/marker-remove

0 votesVote for this answer Mark as a Correct answer

Witchayanin Maythangkul answered on September 12, 2014 05:12

I try this but it not work.

function setAllMap(map) { for (var i = 0; i < content_p_lt_CMSWebPartZone2_pageplaceholder_p_lt_CMSWebPartZone1_GoogleMaps.length; i++) { content_p_lt_CMSWebPartZone2_pageplaceholder_p_lt_CMSWebPartZone1_GoogleMaps[i].setMap(map); } }

//[content_p_lt_CMSWebPartZone2_pageplaceholder_p_lt_CMSWebPartZone1_GoogleMaps] this my google webpart. I can count them but not remove them . What I miss something?

0 votesVote for this answer Mark as a Correct answer

Joshua Adams answered on September 12, 2014 15:23

If you don't need to remove a single one from the group, then you can use either of these:

// Removes the markers from the map, but keeps them in the array. function clearMarkers() { setAllMap(null); }

// Deletes all markers in the array by removing references to them. function deleteMarkers() { clearMarkers(); markers = []; }

Otherwise, you have to loop through the items and find the specific one at the index and do something like this:

markers[indexOfMarker].setMap(null);

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.