Rahul Rahul - 6 months ago 387
Javascript Question

what is the alternate source path for google markerclusterer.js library?

in my project I am including this library like this:

<script src="http://google-maps-utility-library-v3.googlecode.com/svn/trunk/markerclusterer/src/markerclusterer.js"></script>


however the src path seems to be broken since yesterday hence it is not rendering the JS thus I am unable to show clusters on the map.

I do have the local copy for this JS, I can set src path to refer to my local copy instead of above ../svnt/runk/.. path.

What I am searching is there any alternative path for this library? May be it is hosted on CDN.

So far, I think, above is only the place where it is hosted:

Ref: https://code.google.com/p/google-maps-utility-library-v3/source/checkout

Answer

The GitHub hosted version can also be accessed directly by using the following script urls (standard and compiled version):

https://rawgit.com/googlemaps/js-marker-clusterer/gh-pages/src/markerclusterer.js
https://rawgit.com/googlemaps/js-marker-clusterer/gh-pages/src/markerclusterer_compiled.js

You'll also need to specify the imagePath option when instantiating your MarkerClusterer to access the images from GitHub:

var mc = new MarkerClusterer(map, markers, { 
    imagePath: 'https://raw.githubusercontent.com/googlemaps/js-marker-clusterer/gh-pages/images/m' 
});

The following earlier SO post contains more detail regarding the imagePath reference to the cluster images:

Google maps not working in https://

In production, the above urls should be replaced with the cdn versions. To do this simply replace rawgit.com with cdn.rawgit.com as covered in the following SO answer:

Link and execute external JavaScript file hosted on GitHub