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 7892303
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T06:50:11+00:00 2026-06-03T06:50:11+00:00

I’ve successfully setup both MarkerClusterer v3 and Viewport Marker Management ( performing an ajax

  • 0

I’ve successfully setup both MarkerClusterer v3 and Viewport Marker Management ( performing an ajax call to gather only markers visible with viewport and rendering those whenever the map is ‘idle’) separately.

However when I combine them, they only seem to work together when the page first loads and not afterward.

When zooming or panning the initial clusters remain and the markers are for the entire map are rendered unclustered, but leaves the previously clustered markers.

The original clustered markers still behave properly though when you zoom in/out, but the new markers provided when the viewport bounds are changed aren’t added to them or clustered.

Code Below:

function drawMap(swLat, swLng, neLat, neLng){
    //Load the map data
     $.ajax({
            type: "POST",
            url: "readMapInfo.php",
            cache: false,
            data:{S:swLat, W:swLng, N:neLat, E:neLng},
            dataType: "xml",
            success: function(data) {
            if(markerArray.length >0){
                for (i in markerArray) {
                    markerArray[i].setMap(null);
                }
                drawMarker(data);   //takes the info provided and performs "markerArray.push(marker);"
                mc = new MarkerClusterer(map, markerArray, clusterOptions);
            } else {
                drawMarker(data);   //takes the info provided and performs "markerArray.push(marker);"
                mc = new MarkerClusterer(map, markerArray, clusterOptions);
            }
    });
}

google.maps.event.addListener(map, 'idle', function() {
    bounds = map.getBounds();
    sw = bounds.getSouthWest();
    ne = bounds.getNorthEast();
    swLat = sw.lat();
    swLng = sw.lng();
    neLat = ne.lat();
    neLng = ne.lng();

    drawMap(swLat, swLng, neLat, neLng);
});
  • 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-03T06:50:13+00:00Added an answer on June 3, 2026 at 6:50 am

    Your description of your problem is detailed and thorough, but it would be easier if there were also a URL to a page that demonstrates the problem(s). Of course, that may not be possible in this specific scenario. That said, I will take a crack at helping out:

    I believe you need some additional cleanup code at the beginning of your ajax success callback:

    if( markerArray.length > 0 ) {
        // For loop logic is unchanged
        // It removes the markers from the Map, but leaves them in markerArray
        for (i in markerArray) {
            markerArray[i].setMap( null );    
        }
    
        // New code to truncate the Array; the markers should be removed
        markerArray.length = 0;
    
        // New code to clear the clusterer; the markers should be removed
        mc.clearMarkers();        
    
        // Original line of code unchanged
        drawMarker(data);   //takes the data and performs markerArray.push(marker)
    
        // Commented out, because the cluster is cleared each time, not recreated
        //mc = new MarkerClusterer(map, markerArray, clusterOptions);
    
        // New code to refill the cluster, rather than recreate the cluster
        // The original clusterOptions are retained
        mc.addMarkers( markerArray );
    
    } else {
        // Original line of code unchanged
        drawMarker(data);   //takes the data and performs markerArray.push(marker)
    
        // Original line of code unchanged
        // Necessary here, because the clusterer does not yet exist
        mc = new MarkerClusterer(map, markerArray, clusterOptions);
    }
    

    I believe this will help move you forward. Please let me know if this resolves the problem or at least helps.

    After you have your immediate challenges resolved, I also suggest that you take a look at MarkerClustererPlus; it is described in the question: Is there any way to disable the Marker Clusterer for less than defined marker counts?.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I want use html5's new tag to play a wav file (currently only supported
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I am writing an app with both english and french support. The app requests
I'm making a simple page using Google Maps API 3. My first. One marker
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but

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.