Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6092531
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T12:27:12+00:00 2026-05-23T12:27:12+00:00

I have put multiple markers on my map by click event and now I

  • 0

I have put multiple markers on my map by click event and now I want to delete a single marker by double clicking on a specific marker. But what it is doing is just deleting the last marker of the array. Any help please?

:::::::::::::::::::::EDIT::::::::::::::

Is it possible to delete a single marker based on a button press? It is something like I have a table row where I have put the lat long of that marker and a delete button. If I click delete button it should delete the point associated with that button in that row.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T12:27:13+00:00Added an answer on May 23, 2026 at 12:27 pm

    The easy way: assign added marker’s index (in markersArray) to the button and invoke deleteMarker upon click event on that button:

    function createRow(markerIndex){ // add your args like lat, lng etc
      // do the magic and create table row with button having onclick=deleteMarker(markerIndex)
    }
    
    function deleteMarker(markerIndex){
      markersArray[markerIndex].setMap(null);
    }
    
    // invoke createRow when adding new marker
    function addMarker(position){
      marker = new google.maps.Marker({
        position: location,
        map: map
      });
      var markerIndex = markersArray.push(marker) - 1; // push() returns new array length
      createRow(markerIndex);
    }
    

    This will work for new markers as well as for the ones loaded from eg. db.
    Mind that you will have to check which markers are going to be put in db if you want to save them, since setMap(null) doesn’t deletes them from the markersArray.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have multiple vb projects.We want to put error handlers in all functions, and
I am unable to get this event to fire: $(#about).click(function() { //I have put
I want to share ehcache in multiple wars. I have put ehcache-core-2.2 jar in
i have a google map with multiple markers and each has its own infowindow.
If you have multiple, unrelated projects, is it a good idea to put them
I have a web form that has multiple ListBoxes, TextBoxes, DropDowns. If I put
i have put fckeditor in jsp page. I want to get the value whatever
Im making an map with different markers which should have different info windows. But
I would like to know when i have to put multiple index should i
I am wanting to use a view across multiple areas. I have put the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.