我最近开始使用 Google Maps API v3。
我需要绘制一些位置(可能是 3 个或 4 个),同时将地图集中在这些点上 - 而不是手动设置地图的经度和纬度以使其居中......
有人可以分享一些提示,或者指出我正确的方向吗?
提前致谢!担
function initialize() {
var latlng = new google.maps.LatLng(51.50816, 0.02712);
var myOptions = {
zoom: 12,
center: latlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var firstmap = new google.maps.Map(document.getElementById("map"),myOptions);
//EVENT MARKER
var point = new google.maps.LatLng(51.50816, 0.02712);
var marker = new google.maps.Marker({
position:point,
map:firstmap,
title: 'ExCel London',
draggable:false,
icon:'images/event.png'
})
var contentstring = '<div>Hello World</div>'
var infoWindow = new google.maps.InfoWindow({
content:contentstring
});
//HOTEL 1 MARKER
var point = new google.maps.LatLng(51.503146, -0.113259);
var marker = new google.maps.Marker({
position:point,
map:firstmap,
title: 'Waterloo Hotel',
draggable:false,
icon:'images/flag.png'
})
var contentstring = '<div>Hello World</div>';
var infoWindow = new google.maps.InfoWindow({
content:contentstring
});
google.maps.event.addListener(marker,'click',function(){
infoWindow.open(firstmap,marker);
})
};