Removing a single marker from Google Maps - API v3

I want to remove a single marker from a Google map. I am using API version 3. I know how I can remove all tokens, maintaining markerArrayand setting a value of zero for everyone.

To delete one by one, I am going to make a combination of a pair of key values. So that I give the key and delete a specific token. I need help with this.

The following is the code I'm using for the drum marker:

function geoCodeAddresses(data) {

    var markerInfo = {addressKey: '', marker:''};

    for (var i = 0; i < data.length; i++) {
        myLocation = data[i];

        geocoder.geocode({"address":myLocation}, function (results, status) {

            if (status == google.maps.GeocoderStatus.OK) {
                map.setCenter(results[0].geometry.location);
                var marker = new google.maps.Marker({map:map, position:results[0].geometry.location});
                // checkpoint A
                alert(myLocation);
                /*
                markerInfo.addressKey = myLocation;
                markerInfo.marker = marker;*/

                //mArray.push(markerInfo);
            }
        });

    }
}

I will search addresskeyand remove the marker from mArray. But I get the last value every time in the geocode callback method. And each time each pushed one subject. var myLocation always gives me the address of the last index of my array. If I warned about this at checkpoint A.

Is my approach right?

0
1

:

mArray.push(markerInfo);

markerInfo . markerInfo . , , markerInfo, , . , , .

:

mArray.push({addressKey:myLocation,marker:marker});

, :

mArray.push({addressKey:data[i],marker:marker});
0

All Articles