我在使用Google Maps API V3时遇到了问题。地图正确加载但部分隐藏了zoomControl。 panControl显示并且工作正常,但在屏幕截图中它没有打开。
我尝试过设置:zoomControl: true
和disableDefaultUI: true
也无济于事。
我的javascript如下:
function initializeMap(manuId, lat, lng, centerLat, centerLng,zoom){
var latlng = new google.maps.LatLng(centerLat, centerLng);
var myOptions = {
zoom: zoom,
center: latlng,
disableDefaultUI: true,
zoomControl: true,
mapTypeId: google.maps.MapTypeId.ROADMAP,
scrollwheel: false,
draggable : true
};
var mapDiv = document.getElementById("map_canvas");
if(!mapDiv){
var mapDiv = document.getElementById("map_canvas_"+manuId);
}
var map = new google.maps.Map(mapDiv,
myOptions);
var myLatlng = new google.maps.LatLng(lat,lng);
var marker = new google.maps.Marker({
position: myLatlng,
map: map
});
getPolygon(manuId, map);
}
var map;
function showManuMap(manuId, container, manuLat, manuLon, locLat, locLon, zoom){
showManuMap(manuId, container, manuLat, manuLon, locLat, locLon, zoom, null);
}
function showManuMap(manuId, container, manuLat, manuLon, locLat, locLon, zoom, marker){
map = new google.maps.Map(jQuery("#" + container)[0], {
zoom: zoom,
center: new google.maps.LatLng(manuLat, manuLon),
mapTypeId: google.maps.MapTypeId.ROADMAP,
disableDefaultUI: true,
zoomControl: true,
scrollwheel: false,
draggable : true
});
if (locLat && locLon) {
new google.maps.Marker({
position: new google.maps.LatLng(locLat, locLon),
map: map,
icon : "https://www.google.com/intl/en_us/mapfiles/ms/micons/blue-dot.png"
});
}
if (marker != null) {
new google.maps.Marker({
position: new google.maps.LatLng(manuLat, manuLon),
map: map,
icon: marker
});
} else {
new google.maps.Marker({
position: new google.maps.LatLng(manuLat, manuLon),
map: map
});
}
if (manuId) {
getPolygon(manuId, map);
}
}
答案 0 :(得分:1)
没有更多信息,有点难以确定,但是当我在我的页面中包含Twitter引导程序时,我遇到了这个问题。具体来说,它将所有img标签设置为最大宽度为100%。我通过“#my-map-canvas img {max-width:none}”解决了这个问题,其中#my-map-canvas是我地图画布的id。
答案 1 :(得分:0)
取自Google的API页面:https://developers.google.com/maps/documentation/javascript/controls#Adding_Controls_to_the_Map
向地图添加控件
您可能希望通过删除,添加或修改UI行为或控件来定制界面,并确保将来的更新不会改变此行为。如果您只想添加或修改现有行为,则需要确保将控件明确添加到您的应用程序中。
默认情况下,某些控件会显示在地图上,而除非您特别要求,否则其他控件将不会显示。在地图中添加或删除控件在以下MapOptions对象的字段中指定,您将其设置为true以使其可见或设置为false以隐藏它们:
{
panControl: boolean,
zoomControl: boolean,
mapTypeControl: boolean,
scaleControl: boolean,
streetViewControl: boolean,
overviewMapControl: boolean
}