Moises Wattanabi
Moises Wattanabi

Reputation: 21

Google Maps API Store Locator example with MarkerClusterer

I recently created a store locator using the "Google Maps API Store Locator" example.

Now I'm trying to implement the MarkerClusterer Library so that I can display a large single marker instead of multiple markers when users are zoomed out at a certain distance.

When I add the output code:

... 

GDownloadUrl(searchUrl, function(data) {

var xml = GXml.parse(data);

var markers = xml.documentElement.getElementsByTagName('marker');

map.clearOverlays();

var markerCluster = new MarkerClusterer(map, markers);

...

I get the following error:

marker.getLatLng is not a function

Has anyone tried to implement this piece in the past?

Upvotes: 2

Views: 2430

Answers (1)

jenswirf
jenswirf

Reputation: 7327

I think you're trying to use some Google Maps v2 or possibly v1 code with the v3 api, hence you get the error 'getLatLng is not a function'..

Try the v3 marker cluster library:

http://google-maps-utility-library-v3.googlecode.com/svn/trunk/markerclusterer/docs/examples.html

Here's an example:

http://google-maps-utility-library-v3.googlecode.com/svn/tags/markerclusterer/1.0/examples/advanced_example.html?

Upvotes: 1

Related Questions