Pow
Pow

Reputation: 1367

Delete a single marker with a button click in Google Maps API

I have created something like following -

  1. In a Google map I'll place markers by clicking and there will be a table row created dynamically with each click and will show the lat, long in that table row.

  2. i have put a delete button with each of the table row which deletes the corresponding row.

What I want -

I want when the row is deleted, the corresponding marker should also be deleted from the map. I have no clue how can I associate that specific marker with that delete button.

Any sort of help will be appreciated. A rough look of my page is available here-

My Sample Code

Upvotes: 0

Views: 2897

Answers (1)

AR.
AR.

Reputation: 1955

Look here: http://groups.google.com/group/google-maps-js-api-v3/browse_thread/thread/c0e80cdbde13dd36/0bb97b3de988b4f7?lnk=gst&q=remove+markers&pli=1

I guess you need to add markers to the array when creating them. Then you can set and index that relate to that marker to be the value of hidden field next to the Delete button. Or you can set the marker's index as href for anchor tag and use anchor tag instead of a button to call the removal function for that particular marker.

You can also check out discussion here: http://www.svennerberg.com/2009/07/google-maps-api-3-markers/

Upvotes: 1

Related Questions