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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T12:41:13+00:00 2026-06-15T12:41:13+00:00

I have the following code to try to get the MarkerClusterer library to work

  • 0

I have the following code to try to get the MarkerClusterer library to work for my Google Map but for some reason it doesn’t change anything. I have some jinja2 in there for the loop but that is all working properly. Can you see any errors?

<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
        <style type="text/css">
          html { height: 100% }
          body { height: 100%; margin: 0; padding: 0 }
          #map_canvas { height: 100% }
        </style>
        <script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?key=AIzaSyD-pLsocZXv5mYwJsSxMghJncxa6iklFUU&sensor=false"></script>
        <script type="text/javascript" src="/static/js/markerclusterer.js"></script>
        <script type="text/javascript">

    var map;    

    function initialize() {

        var centerlocation = {{centerlocation|json_encode|safe}};   
        var LatLng = centerlocation.replace("(", "").replace(")", "").split(", ")
        var Lat = parseFloat(LatLng[0]);
        var Lng = parseFloat(LatLng[1]);

        var zoomAmt = 10;


      var USA = new google.maps.LatLng(Lat, Lng);
      var mapOptions = {
        zoom: zoomAmt,
        center: USA,
        mapTypeId: google.maps.MapTypeId.TERRAIN
      };
      map =  new google.maps.Map(document.getElementById("map_canvas"), mapOptions);

    // Global var
       var infowindow = new google.maps.InfoWindow();

    //markers array
    var markers = [];

    //put all the markers on the map
    {% for location in locations %}

    //need to do the JSON encoding because JavaScript can't have Jinja2 variables
    //I need the safe here because Jinja2 tries to escape the characters otherwise
    var GPSlocation = {{location.GPSlocation|json_encode|safe}};    
    var LatLng = GPSlocation.replace("(", "").replace(")", "").split(", ")
    var Lat = parseFloat(LatLng[0]);
    var Lng = parseFloat(LatLng[1]);    

    var markerLatlng = new google.maps.LatLng(Lat, Lng);
    var title = {{location.title|json_encode|safe}}
    var iwContent = {{location.render_front()|json_encode|safe}}

    var marker = new google.maps.Marker({
            position: markerLatlng,
            title: title,
            map: map
      });

    google.maps.event.addListener(marker, 'click', function () {
      infowindow.setContent(iwContent);
      infowindow.open(map, marker);
      });

    //putting the marker onto the markers array
    markers.push(marker);


    {% endfor %}

    //creating the marker cluster
    var markerCluster = new MarkerClusterer(map, markers);

    }

    </script>

Like I said the map just looks normal after I call MarkerClusterer.

  • 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-15T12:41:14+00:00Added an answer on June 15, 2026 at 12:41 pm

    Looks like you need to remove the {map: map} property from the Marker.

    Here is a working example with clustering.

    Errors in chrome Javascript console on this page:

    • Uncaught ReferenceError: GOverlay is not defined markerclusterer.js:630
    • Uncaught ReferenceError: markers is not defined

    The first implies you are using the wrong version of the markerclusterer script (GOverlay is from the Google Maps API v2)

    If I use your code with the correct MarkerClusterer and declaring the markers array, the clusterer works, but you have issues with the association of the InfoWindow contents with the marker (which can be fixed with a createMarker function).

    Here is an example that uses a createMarker function to fix the association of the markers to the infowindow. It is based off your code, but there is room for improvement (there is a lot of redundancy in your code).

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

Sidebar

Related Questions

We have following code: try { // some code throwing MyException } catch (MyException
hi i have the following code below, where i try to get all the
I have the following code to try and get the current day in seconds
If I have the following code: try { Entity questionEntity = datastore.get(currentKey); questionEntity.doSomething(); }
I have the following code and when i try to get a value from
I have the following code: try { res = new Utils(ubc_context).new DownloadCalendarTask().execute().get(); } catch
I have the following code: try: redirect_url = self.auth.get_authorization_url() webbrowser.open_new(redirect_url) except tweepy.TweepError: print 'Error!
How I can start reading from a specific byte? I have following code: try
Hy ... I have the following code : try { Nrtrde record = new
i have the following code to try and load a local html page in

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.