Google maps 谷歌地图集群
(对不起我的英语) 我想创建群集,但有错误Google maps 谷歌地图集群,google-maps,cluster-computing,Google Maps,Cluster Computing,(对不起我的英语) 我想创建群集,但有错误 未捕获的TypeError:对象[Object Array]没有方法“getPosition” 我从数据库中获取的坐标 function initialize() { var latlng = new google.maps.LatLng(56.323678, 44.0); var myOptions = { zoom: 7, center: latlng,
未捕获的TypeError:对象[Object Array]没有方法“getPosition” 我从数据库中获取的坐标
function initialize() {
var latlng = new google.maps.LatLng(56.323678, 44.0);
var myOptions = {
zoom: 7,
center: latlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById("map_canvas"),
myOptions);
setMarkers(map, markers);
}
var markers = [ <? for ($i=0; $i<count($cords); $i++)
{if((float)$cords["$i"]["location_lat"]<>0 AND (float)$cords["$i"]["location_lng"]<>0 ){echo "[".(float)$cords["$i"]["location_lat"].",
".(float)$cords["$i"]["location_lng"]." ,
'".$cords["$i"]["image"]."',
'".$cords["$i"]["name"]."']";
if ($i+1<count($cords))echo ",\n\r";}}?> ];
var infowindow = new google.maps.InfoWindow({
});
function setMarkers(map, locations) {
var markerCluster = new MarkerClusterer(map, locations);
var latlngbounds = new google.maps.LatLngBounds();
for (var i = 0; i < markers.length; i++) {
var myLatLng = new google.maps.LatLng(locations[i][0], locations[i][1]);
latlngbounds.extend(myLatLng);
var marker = new google.maps.Marker({
position: myLatLng,
map: map,
title: locations[i][3]
});
google.maps.event.addListener(marker, 'click', (function(marker, i) {
return function() {
infowindow.setContent("<img src='image/"+ locations[i][2] +"' height='150' width='300'> <br> <b>"+ locations[i][3] +"</b> " );
infowindow.open(map, this);
}
})(marker, i));
}
map.setCenter( latlngbounds.getCenter(), map.fitBounds(latlngbounds));
};
函数初始化(){
var latlng=新的google.maps.latlng(56.323678,44.0);
变量myOptions={
缩放:7,
中心:拉特林,
mapTypeId:google.maps.mapTypeId.ROADMAP
};
var map=new google.maps.map(document.getElementById(“map_canvas”),
肌肽);
设置标记(地图、标记);
}
var markers=[我想您还没有声明要执行“getPosition”的数组的索引,
你的代码太乱了。。
:)