我有一张简单的谷歌地图,我已经在随机位置放置了标记。我使用map.fitBounds和bounds.extend API根据我的画布大小自动调整地图大小。有时,如果我减小画布大小,则符号在后台重复。
$(function(){
var map;
var markersArray = [];
var image = 'img/';
var bounds = new google.maps.LatLngBounds();
var loc;
var mapOptions = { mapTypeId: google.maps.MapTypeId.ROADMAP };
map = new google.maps.Map(document.getElementById("map_canvas"), mapOptions);
loc = new google.maps.LatLng(52.696361078274485, -103.0078125);
bounds.extend(loc);
addMarker(loc, 'Event A', "active");
loc = new google.maps.LatLng(66.37275500247456, -146.25);
bounds.extend(loc);
addMarker(loc, 'Event B', "active");
loc = new google.maps.LatLng(62.75472592723178, 81.9140625);
bounds.extend(loc);
addMarker(loc, 'Event C', "active");
loc = new google.maps.LatLng(77.54209596075547, -49.5703125);
bounds.extend(loc);
addMarker(loc, 'Event D', "active");
loc = new google.maps.LatLng("1.3887035","1.1807378");
bounds.extend(loc);
addMarker(loc, 'Event E', "active");
map.fitBounds(bounds);
//map.panToBounds(bounds);
function addMarker(location, name, active) {
var marker = new google.maps.Marker({
position: location,
map: map,
title: name,
});
}
});
我错过了什么?
答案 0 :(得分:0)
fiddle link http://jsfiddle.net/G6PLr/119/
总结一下,我做了以下事情: