MarkerClusterer 只能在 webkit(Chrome 和 Safari)中工作,在 Firefox 中工作正常吗?
这让我精神不振。
我将 MarkerCluster 与谷歌地图 v3 一起使用,它在 FF 中工作正常,但是当我(和客户端)在 Chrome 或 Safari 中启动它时,集群不存在。
没有错误,只是不能在 webkit 中工作。
一些注意事项:它来自一些 ajax 加载的 json,并且位于 jquery 中。
这是负责添加的函数:
add_clusters: function() {
markers = [];
$.each( interpreters, function ( i, interpreter ){
//maps.add_postcode_marker(i, 'interpreter');
var latLng = new google.maps.LatLng(interpreter.lat, interpreter.lng);
//, map: map
interpreters[i].marker = new google.maps.Marker({ position: latLng });
maps.add_info_box(i, "interpter");
markers.push(interpreters[i].marker);
app.log(interpreters[i].marker);
});
markerCluster = new MarkerClusterer(map, markers);
}
干杯!
重申一下,Chrome 中没有错误,只是不显示。
This is driving me mental.
I'm using MarkerCluster with google maps v3, and it works fine in FF, however when I (and the client) kick it up in Chrome or Safari the clusters arn't there.
No errors, just not working in webkit.
A few notes: it's coming from some ajax-loaded json and it's in jquery.
This is the function taking care of the adding:
add_clusters: function() {
markers = [];
$.each( interpreters, function ( i, interpreter ){
//maps.add_postcode_marker(i, 'interpreter');
var latLng = new google.maps.LatLng(interpreter.lat, interpreter.lng);
//, map: map
interpreters[i].marker = new google.maps.Marker({ position: latLng });
maps.add_info_box(i, "interpter");
markers.push(interpreters[i].marker);
app.log(interpreters[i].marker);
});
markerCluster = new MarkerClusterer(map, markers);
}
Cheers!
Just to reiterate, there are no errors in Chrome, it's just not displaying.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
问题出在makercluster本身。
具体是 725 号线。 Jquery 也被包含在内,并且 .indexOf 的行为在浏览器之间略有变化。
在 Firefox 中,它返回正确的 -1。
然而 chrome 返回未定义。
您可以通过将第 725 行更改为...来修复它
The problem was with makercluster itself.
Line 725 specifically. Jquery was also included and the behaviour of .indexOf was changed slightly between browsers.
In firefox it was returning the correct -1.
However chrome was returning undefined.
You can fix it by changing line 725 to...
乍一看,我看不出这个片段有什么问题。在我看来这一切都很好。
您可以使用 jsfiddle.net 创建一个包含工作演示的页面(在 Firefox 中),以便我们可以看到它/尝试我们自己编辑吗?
At a glance, I can't see what's wrong with this snippet. It all looks good to me.
Can you use jsfiddle.net to create a page that contains a working demo (in Firefox) so we can see it/try to edit it on our own?
我在使用 PrimeFaces 时也遇到了类似的问题。解决方案是确保响应 mimeType 为
text/html
。I had a similar problem with PrimeFaces. The solution was to make sure the response mimeType is
text/html
.