On Dec 1, 2:06 pm, "[email protected]"
<[email protected]> wrote:
> im trying to plot a marker if it does not exist on the map and remove
> it if it does at the time of the event trigger, like a toggle. the
> onclick event is an image on the page:
>
> <img src="img/misc/icon_map_add.png" id="marker" class="mapit"
> onclick="plotMarker(30.398937,-86.470642)" />
>
> function plotMarker(lat,long) {
>   var marker = new GLatLng(lat,long);
>   if (marker){
>     map.removeOverlay(marker);
>   }
>   else {
>     map.addOverlay(new GMarker(marker));
>   }
>
> }
>
> im very new to the google api

Did you read the posting guidelines?
http://groups.google.com/group/google-maps-api/web/suggested-posting-guidelines
and
http://groups.google.com/group/Google-Maps-API/web/why-including-a-link-is-critical


> and not quite sure how to accomplish this. any help is appreciated.

There is an obvious problem with the routine above.  You create a
marker, then check to see if it exists.  It does, so you try to remove
it, but it hasn't been added to the map yet, so that fails.  You can
solve that problem by putting ht marker creation inside the else.  You
haven't provided enough context to tell whether that is the only
problem.  Please post a link to your map if that doesn't help.

  -- Larry



  -- Larry

--

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