How to remove a marker by double clicking on it through the Google Map

507 views
Skip to first unread message

ghoastfalcon

unread,
Sep 23, 2010, 1:00:35 PM9/23/10
to Google Maps JavaScript API v3
Hi all,
I have been struggling with this for some time. What I am trying
to do seems very simple and strait forward, but I cannot seem to get
anything to work. I wish I could like you directly to the page I am
working on, but it is behind a firewall and has not been officially
released for the public to see. What I want to do is to allow the user
to click on the map and create a point or marker, this much I have
working quite nicely; however it would be really nice to allow them to
double click on the marker they just made and have it be removed. This
is where my problems begin.

I have tried marker[i].setMap(null); and it does not do anything. So I
am assuming that I am not calling that function properly or do not
have something linked up correctly. Does anyone have a good example
page or example code I can look at to see what I am doing wrong here?
Any help would be greatly appreciated.

Thank you for your time.

geoco...@gmail.com

unread,
Sep 23, 2010, 5:09:45 PM9/23/10
to Google Maps JavaScript API v3
On Sep 23, 10:00 am, ghoastfalcon <barrettav...@hotmail.com> wrote:
> Hi all,
>     I have been struggling with this for some time. What I am trying
> to do seems very simple and strait forward, but I cannot seem to get
> anything to work. I wish I could like you directly to the page I am
> working on, but it is behind a firewall and has not been officially
> released for the public to see. What I want to do is to allow the user
> to click on the map and create a point or marker, this much I have
> working quite nicely; however it would be really nice to allow them to
> double click on the marker they just made and have it be removed. This
> is where my problems begin.
>
> I have tried marker[i].setMap(null);
Sorry need more context.

What is "i"?
Is marker in context?

-- Larry

Mark

unread,
Sep 23, 2010, 6:17:40 PM9/23/10
to Google Maps JavaScript API v3
You need to post some code. To me, it sounds like you should be
adding the double click event listener to the marker. Maybe you are
adding it to the map.

e.g (I've not tested this)

//marker variable points to the marker just after marker creation
google.maps.event.addListener(marker, 'rightclick', function(event)
{marker.setMap(null)} );

Mark

unread,
Sep 23, 2010, 6:18:57 PM9/23/10
to Google Maps JavaScript API v3
oops change 'rightclick' to 'dblclick'
Reply all
Reply to author
Forward
0 new messages