Start a new topic

Deleting a POI on click

Deleting a POI on click


Hi all,

I am trying to delete make it so that when I click a poi it is deleted from the screen. I have pretty much followed the multiple pois example when it comes to generating them and then modified a couple of methods in order to try and delete them, however it does not seem to work. Here are the modified methods:

Marker.prototype.getOnClickTrigger = function(marker) {

return function() {

Marker.prototype.remove(marker);
try {
World.onMarkerSelected(marker);
} catch (err) {
alert(err);
}

return true;
};
};

Marker.prototype.remove = function(marker) {
marker.enabled = false;
};

 

onMarkerSelected: function onMarkerSelectedFn(marker) {
marker.remove();

},

Using this approach I am sometimes able to remove one marker, however not always, and only one. After that the others won't disappear even though the taps are registered. I used a console.log and it prints.

I also tried the following version of the above method, but no luck

onMarkerSelected: function onMarkerSelectedFn(marker) {
World.currentMarker = marker;

// disables selected markers
for(var k=0; k<World.markerList.length; k++){
World.markerList.markerObject.enabled = ( World.markerList !== World.currentMarker );
World.markerList.splice(k, 1);
}
},

Thanks for any help

Hello,

What you could try and do is destroy these objects by calling the method destroy. You can find further details here.

Thanks

Eva
Login or Signup to post a comment