使用 FusionTableLayers 代替普通标记怎么样?FusionTables 使您能够快速加载大量标记,并且您可以使用一些 SQL。
var infoWnd, map;
function initialize() {
var mapOptions = {
center: new google.maps.LatLng(41.850033, -87.6500523),
zoom: 12,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
map = new google.maps.Map(document.getElementById("map_canvas"),
mapOptions);
infoWnd = new google.maps.InfoWindow();
var layer = new google.maps.FusionTablesLayer({
query: {
select: '\'Geocodable address\'',
from: '1mZ53Z70NsChnBMm-qEYmSDOvLXgrreLTkQUvvg'
},
suppressInfoWindows : true
});
layer.setMap(map);
google.maps.event.addListener(layer, "click", onLayerClicked);
}
function onLayerClicked(evt) {
var imgUrl = "http://maps.googleapis.com/maps/api/streetview?" +
"size=400x300&" +
"sensor=false&" +
"location=" + evt.latLng.toUrlValue();
infoWnd.setPosition(evt.latLng);
infoWnd.setContent("<img src='" + imgUrl + "'>");
infoWnd.open(map);
return false;
}
google.maps.event.addDomListener(window, "load", initialize);