嗯,我有几个问题让谷歌地图使用v3 API工作。谷歌地图缩放和描述对话框不能正常工作
看看这里:[通过海报删除]
两个图,实际上,工作,但缩放级别好像它是随机的。初始化地图时,缩放设置为12。此外,如果您单击标记,说明框缺少角落并且无法关闭。下面是我使用激活这些地图的JavaScript功能:通过刚才removeing
body img {
max-width: 520px !important;
height: auto !important;}
从样式表
var mapHash = [];
var bound = new google.maps.LatLngBounds();
finishedCoding = false;
function initMap(map_container_div,lat,lng) {
var latlng = new google.maps.LatLng(lat,lng);
var myOptions = {
zoom:12,
center:latlng,
mapTypeId:google.maps.MapTypeId.ROADMAP,
streetViewControl: false
};
var map = new google.maps.Map(document.getElementById(map_container_div), myOptions);
if (!getMap(map_container_div)) {
var mapInfo = {
mapkey:'',
map:'',
geocoder : new google.maps.Geocoder()
};
mapInfo.map = map;
mapInfo.geocoder = new google.maps.Geocoder();
mapInfo.mapKey = map_container_div;
mapHash.push(mapInfo);
}
}
function placeMarker(myAddress, mapId, description, title) {
mapIndex = getMap(mapId)
//alert(myAddress + mapId + map)
mapHash[mapIndex].geocoder.geocode({
'address':myAddress
}, function (results, status) {
if (status == google.maps.GeocoderStatus.OK) {
mapIndex = getMap(mapId)
var marker = new google.maps.Marker({
map:mapHash[mapIndex].map,
position:results[0].geometry.location,
title: title
});
bound.extend(results[0].geometry.location);
mapHash[mapIndex].map.fitBounds(bound);
finishedCoding = true;
placeDesc(marker,description,mapId);
}
});
}
function placeDesc(marker,myDesc,mapId) {
mapIndex = getMap(mapId);
var infowindow = new google.maps.InfoWindow({
content: myDesc
});
google.maps.event.addListener(marker, 'click', function() {
infowindow.open(mapHash[mapIndex],marker);
});
}
function getMap(mapKey) {
for (var i = 0 ; i < mapHash.length ; i++) {
if (mapHash[i].mapKey == mapKey) {
return i;
}
}
return false;
}
function startmap(mapidd,address,description,title,lat,lng) {
initMap(mapidd,lat,lng)
placeMarker(address,mapidd,description,title)
}
这实际上没有区别。 =/ – Jared
其实我只是发送你的解决方案 “说明框缺少角落,无法关闭。” 并获得放置setZoom选项。如果你再次放置该样式表,那么你观察与描述框相同的问题。 –
嗯你是对的,这确实解决了角落问题,但由于某些原因,点击x时对话框仍然不会关闭。与我需要的setZoom函数相比,这并没有什么大不了的。谢谢你。 – Jared