Okay, I have a GoogleMaps page being loaded up within a c++ program I have
been working on.

Whenever the user hits the s key i create a Start marker and add it to my
StartFinishMarkerManager and then refresh it.  Whenever the user hits the f
key the finish marker is created and the same is done.  After this I prompt
the user if they wish to save these 2 locations and if they cancel it calls
a function to remove the 2 markers previously added and then recenter on
their previous location.

This works fine if their previous location is currently visible to them, but
if they are zoomed in to a point where the map must pan to the previous
location the first marker is still present.

I have performed alerts keeping track of the length of my arrays in which I
am storing these in as well as the getCount values for the marker manager at
the given zoom.  Even though the arrays have been flushed and the getCount
for the manager shows 0, it is still showing that first marker.  Any ideas?
 Here is some of my code:

If s key was registered:
var StartMarker = new GMarker(point, ZoneStartMarkerOptions);
ZoneStartFinishMarkers.push(StartMarker);
StartFinishRemoveCounter++;

If f key:
var FinishMarker = new GMarker(point, ZoneFinishMarkerOptions);
ZoneStartFinishMarkers.push(FinishMarker );
StartFinishRemoveCounter++;

On cancelling the remove function:
var zsfmLength1 = ZoneStartFinishMarkers.length-1; // Gets the last
ZoneStartFinishMarkers
var zsfmLength2 = ZoneStartFinishMarkers.length-2; // Gets the second to
last ZoneStartFinishMarkers

alert("ZoneStartFinishMarkers " + ZoneStartFinishMarkers.length);  //  This
shows 2
alert("StartFinishRemoveCounter " + StartFinishRemoveCounter);   //  This is
showing 2
alert("Count " + ZoneStartFinishMM.getMarkerCount(14));             //  This
is showing 2
//================================================================================================================================================
//  Now remove the value from ZoneStartFinishMarkers
//------------------------------------------------------------------------------------------------------------------------------------------------
if ( StartFinishRemoveCounter % 2 == 0 ) {                                //
 This is checking if there is both a start and finish and there is
I omitted the extra else condition
//============================================================================================================================================
//  First call the removeMarker method for the ZoneStartFinishMM Marker
Manager
//  This removes the Marker that was inserted into the Marker Manager
//  The way to do this is to call the Array we passed to the Marker Manager
and the marker
//  location of the Marker you wish to remove
//--------------------------------------------------------------------------------------------------------------------------------------------
ZoneStartFinishMM.removeMarker(ZoneStartFinishMarkers[zsfmLength1]);
alert("Count " + ZoneStartFinishMM.getMarkerCount(14));
        //  This is showing 1
ZoneStartFinishMM.removeMarker(ZoneStartFinishMarkers[zsfmLength2]);
alert("Count " + ZoneStartFinishMM.getMarkerCount(14));
       //  This is showing 2

//============================================================================================================================================
//  Now remove the Markers from the array that we stored them in using the
.pop method
//  Array.pop removes the last object in the array
//  We run it twice since there was both a start and finish saved to the
array
//--------------------------------------------------------------------------------------------------------------------------------------------
alert("ZoneStartFinishMarkers " + ZoneStartFinishMarkers.length);
    //  This shows 2
ZoneStartFinishMarkers.pop();
alert("ZoneStartFinishMarkers " + ZoneStartFinishMarkers.length);
    //  This shows 1
ZoneStartFinishMarkers.pop();
alert("ZoneStartFinishMarkers " + ZoneStartFinishMarkers.length);
    //  This shows 0
StartFinishRemoveCounter = StartFinishRemoveCounter - 2;
alert("StartFinishRemoveCounter " + StartFinishRemoveCounter);
 //  This shows 0
}
ZoneStartFinishMM.refresh();

Any ideas on why the 1st marker is still showing up even though it has been
deleted and refreshed?

-- 
You received this message because you are subscribed to the Google Groups 
"Google Maps API" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-maps-api?hl=en.

Reply via email to