(对不起我的英语)我想做集群,但我有错误
Uncaught TypeError: Object [object Array] has no method 'getPosition' Coords i take from database
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));
};