1

Here is my function of delete marker, my function delete marker working it delete the marker when i reload the page.

deleteCurrentMarker: function (marker_id) {
        //Find and remove the marker from the Array

        var self = this;

        for (var i = 0; i < self.markers.length; i++) {
            if (self.markers[i].id == marker_id) {
                //Remove the marker from Map

                self.markers[i].setMap(null);

                //Remove the marker from array.
                self.markers.splice(i, 1);
            }
        }
    },

and here it is my delete function that call on delete button.

 deleteSpot: function () {
        var self = this;
        console.log("Self ====================================>" + JSON.stringify(self));

        if (confirm('Are you sure to delete this Spot?')) {
            $.getJSON(lighthouse.serviceURL + "Spots/DeleteSpot", {
                SPOT_GUID: Spot_Guid,
            }, function (response) {
                self.hideOndelete();
                lighthouse.googleMap.deleteCurrentMarker(self.selectedMarkerID);

            }).fail(function (jqxhr, textStatus, error) {
            });
        }

    },
  • You can refer this answer - http://stackoverflow.com/a/2439176 – JRodDynamite Jan 08 '16 at 08:26
  • 3
    `setMap(null)` basically removes the underlying marker from the map, not just the variable itself, but also the graphic entity. Are you sure your `self.markers` actually holds the list of the markers as they are drawn on the map? – TaoPR Jan 08 '16 at 08:44
  • 1
    +1 for what @TaoP.R. says. Show us the code where you create your markers, and how you call your deleteCurrentMarker function. – duncan Jan 08 '16 at 10:23
  • yes Jason Estibeiro, my self.marker hold the list of markers array, but when i delete selected marker my delete function working perfectly but deleted markers not hide without page reloading even i use self.markers[i].setMap(null) – Haseeb Kahn Jan 11 '16 at 09:13
  • deleteSpot: function () { var self = this; if (confirm('Are you sure to delete this Spot?')) { $.getJSON(lighthouse.serviceURL + "Spots/DeleteSpot", { SPOT_GUID: Spot_Guid, }, function (response) { self.hideOndelete(); lighthouse.googleMap.deleteCurrentMarker(self.selectedMarkerID); }).fail(function (jqxhr, textStatus, error) { }); } }, – Haseeb Kahn Jan 11 '16 at 09:14

0 Answers0