markcluster 和 google 地图 v3 错误“a 未定义”
我正在努力尝试使用 markclusterer v3 和 Google 地图 API v3 来聚类 50 个标记。
我遵循了以下位置的简单示例: http://google-maps-utility-library-v3.googlecode.com/svn/trunk/markerclusterer/docs/examples.html 构建我的函数,但是加载地图时出现以下错误在 firebug 中:
a is undefined
Ba(H,function(a){if(!a)return l;return...){return new P(this.T.d,this.P.b,i)}; main.js (line 13)
我的函数只是执行一个简单的 json 调用以从服务器获取点,然后在将标记添加到标记集群之前构建标记数组。
function addMarkerCluster(){
//get json data and create array of map markers and mark up the map using
//a map cluster
$.getJSON("feed/kml.php?action=json",
function(data){
var map;
var markers = [];
var latlng = new google.maps.LatLng(24.91654, 15.31326);
var myOptions = {
zoom: 3,
center: latlng,
mapTypeId: google.maps.MapTypeId.HYBRID
};
map = new google.maps.Map(document.getElementById("googlemap"), myOptions);
google.maps.event.addListener(map, "tilesloaded", function(){
attachFancyBox();
hideLoadDialog();
});
//loop through the data and add to the markers array the lat/lng of the centerpoints
//as google lat/lng objects.
$.each(data, function(i){
latlng = new google.maps.LatLng(this.lat, this.lng);
var marker = new google.maps.Marker(latlng);
markers.push(marker);
});
var markerCluster = new MarkerClusterer(map, markers);
});
}
知道为什么这会导致谷歌地图 main.js 以这种方式失败吗?如果我只添加 MarkerClusterer 而没有标记数组,则地图渲染不会出现错误。
当我添加标记数组时,地图会出现错误。
谢谢,
格兰特
I'm struggling trying to cluster 50 markers using the markerclusterer v3 with Google maps API v3.
I've followed the simple example found at: http://google-maps-utility-library-v3.googlecode.com/svn/trunk/markerclusterer/docs/examples.html to build my function however when the map is loaded I am getting the following error in firebug:
a is undefined
Ba(H,function(a){if(!a)return l;return...){return new P(this.T.d,this.P.b,i)}; main.js (line 13)
My function is just doing a simple json call to get the point from the server and then build the array of markers before adding them to the markerclusterer.
function addMarkerCluster(){
//get json data and create array of map markers and mark up the map using
//a map cluster
$.getJSON("feed/kml.php?action=json",
function(data){
var map;
var markers = [];
var latlng = new google.maps.LatLng(24.91654, 15.31326);
var myOptions = {
zoom: 3,
center: latlng,
mapTypeId: google.maps.MapTypeId.HYBRID
};
map = new google.maps.Map(document.getElementById("googlemap"), myOptions);
google.maps.event.addListener(map, "tilesloaded", function(){
attachFancyBox();
hideLoadDialog();
});
//loop through the data and add to the markers array the lat/lng of the centerpoints
//as google lat/lng objects.
$.each(data, function(i){
latlng = new google.maps.LatLng(this.lat, this.lng);
var marker = new google.maps.Marker(latlng);
markers.push(marker);
});
var markerCluster = new MarkerClusterer(map, markers);
});
}
Any idea why this is causing the google map main.js to fail in this way? If I just add the MarkerClusterer without the array of markers the map renders without errors.
When I add the array of markers then the map errors.
Thanks,
Grant
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
修复很简单,我会错过谷歌地图 api v3 需要传递一个对象的事实。解决办法是改变
Fix was simple I'd miss out the fact that the google maps api v3 needs to have a object passed to it. The fix was to change