2

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?

4

1 回答 1

1

我认为您正在尝试将一些 Google Maps v2 或可能 v1 代码与 v3 api 一起使用,因此您收到错误“getLatLng 不是函数”。

试试 v3 标记集群库:

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

这是一个例子:

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

于 2012-01-09T12:32:33.827 回答