Blair Cox
Posts: 0
Joined: Thu Jun 04, 2015 2:29 pm

How can I remove markers that are mapped to markers?

Even adding a button and javascript to clear the markers and following the exact code you reference, does not work. I get Uncaught ReferenceError: setMapOnAll is not defined.

If I try to bind it to the map, it then becomes 'not a function'.
google.maps.Marker.setMapOnAll(null);

Uncaught TypeError: google.maps.Marker.setMapOnAll is not a function

Uncaught TypeError: Appery(...).options.mapElement.gmap.setMapOnAll is not a function

Blair Cox
Posts: 0
Joined: Thu Jun 04, 2015 2:29 pm

How can I remove markers that are mapped to markers?

Hi Sergiy,

I did manage to get the last marker to be removed. This was done by changing var marker to a global variable. When clicking a button, call marker.setMap(null);. This however removes only the last marker placed.

My code and the way the Google example work are different. I'm walking through an array, placing the marker for each pass. I see that the Google code sets the marker on the map, but my code seems to do this as soon as you create the marker. If I try setting the marker as Google does, I get markers which update without coordinates and are placed in the middle of the world map.

It took two weeks to get the markers to even appear. I don't want to rewrite everything just in order to delete a marker.

Can someone please throw me a bone here????

[quote:]
list_location = [];
var list_location = localStorage.getItem('farmProducts_storage');
obj = [];
var obj = JSON.parse(list_location);

var coordsArray = obj;
marker = [];
markers = [];
var image = 'http://chart.apis.google.com/chart?ch...';
var map = [];
var map = new Appery("Gmap").options.mapElement.gmap('get', 'map');

var CreateMarker = function(coordsArray, i){

Code: Select all

 marker = new google.maps.Marker({  
     position: new google.maps.LatLng( coordsArray[i].lat, coordsArray[i].lng ),  
     title: coordsArray[i].business_name,  
     map: Appery("Gmap").gmap,  
 }); 

// Adds a marker to the map and push to the array.
markers.push(marker);
alert (markers);

Code: Select all

 var infowindow = new google.maps.InfoWindow({content: ('[b]' + coordsArray[i].business_name + '[/b]

' + coordsArray.hours_season + '
' + coordsArray.combinedAddress )});

Code: Select all

 google.maps.event.addListener(marker, 'click', function() {  
     infowindow.open(Appery("Gmap").gmap,marker);  
 });  

};
for (var i = 0, j = coordsArray.length; i < j; i++)
CreateMarker(coordsArray, i);

google.maps.event.addListener(map, 'bounds_changed', function() {
// Adds a marker to the map and push to the array.

});

[/quote]

Blair Cox
Posts: 0
Joined: Thu Jun 04, 2015 2:29 pm

How can I remove markers that are mapped to markers?

I'm going to need your help here guys. Following the Google documentation does not work. Is the Appery implementation of the Google Maps different??

At this point, I'd settle with destroying and recreating the map just to get this to work!!!!

Alena Prykhodko
Posts: 0
Joined: Tue Apr 09, 2013 7:36 am

How can I remove markers that are mapped to markers?

Dear Blair,

Thank you for sharing.

Return to “Issues”