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

  • SEARCH
  • Home
  • 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 8145289
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T13:37:01+00:00 2026-06-06T13:37:01+00:00

I have a google map using V3 of the API. It has one marker

  • 0

I have a google map using V3 of the API. It has one marker on it which is draggable and then a load of other markers that are static. I have set up a dragend listener for the draggable marker which calls a function called clear_markers() like so:

google.maps.event.addListener(marker_0, "dragend", function() {
    clear_markers();
});

function clear_markers()
{
  if (markers) {
    for (var i = 1; i <= markers.length; i++ ) {
        if(typeof markers[i] !== "undefined") {
            markers[i].setMap(null);
        }
    }
  }
}

The reason I start the for loop at 1 and not 0 is that my draggable marker is the first marker so I want to clear all markers from the map except this one.

Here is the problem:

If I call clear_markers(); in any other way it works fine and the markers are removed from the map, so something like this works:

$('#mybutton').click(function() {
    clear_markers();
});

When you drag and drop the green marker though and it’s called from the dragend listener it does not work. The markers do get removed but then they immediately get re added again. I know they do get removed because if I put something in the clear_markers() function just after the for loop that kills the script, the markers get removed. But if the script is allowed to continue they are still there meaning they have been removed and then instantly added back on again.

I’m not calling any other code so it seems like a bug with the api to me. Does anyone have any ideas?

Here is a working example showing the problem:

https://tinker.io/64b68/1

  • 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-06-06T13:37:04+00:00Added an answer on June 6, 2026 at 1:37 pm

    Remove the markerClusterer. It is adding the markers back in and you aren’t using it.

    Update:

    Since you need to keep it, if you want the markers to not be displayed, you need to remove them from the markerClusterer:

     markerCluster.clearMarkers();
    

    (but you will need to make it global to use it that way)

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

Sidebar

Related Questions

I am using Google Maps API v3 , and have several map markers that
I have a Google Map on the webpage with markers on it that has
I have a Google Map on our site that has a list of markers
I have a web page with a google map (api v3) that has dozens
I have an application which is currently using the google map API. I like
I have an application where I'm using the Google Map API to display markers
I have a scenario where I am using Google Map JavaScript API to process
I have a Google V3 map which uses steetView and some map markers. The
I have an app that saves google map markers, I basically save the lat
I have a question regarding map api. I was using the the google map

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.