当我使用样式化的 Google 地图时,它会忽略我设置的 maxZoom 和 minZoom,完全删除缩放栏。如果我不包含 StyledMapType,则缩放限制有效。我错过了什么吗?还是 StyledMapType 不支持 maxZoom/minZoom?
谢谢您的帮助。
function initialize() {
map = new google.maps.Map(document.getElementById('map-canvas'), {
center: new
google.maps.LatLng(29.45, -95.75),
zoom: 10
});
var style = [
{
featureType: 'all',
elementType: 'all',
stylers: [
{ saturation: -99 }
]
},
{
featureType: 'road.local',
elementType: 'all',
stylers: [
{ visibility: 'off' }
]
},
{
featureType: 'administrative.land_parcel',
elementType: 'all',
stylers: [
{ visibility: 'off' }
]
}
];
var styledMapType = new google.maps.StyledMapType(style, {
map: map,
name: 'Styled Map'
});
map.mapTypes.set('map-style', styledMapType);
google.maps.event.addListenerOnce(map, "projection_changed", function(){
map.setMapTypeId('map-style');
layer_0 = new google.maps.FusionTablesLayer({
query: {
select: "col3",
from: "14XfhpSuNK0aSJkbnb5UFrsE1UPRE_wr4d9IwKjW7"
},
map: map,
styleId: 2,
templateId: 2
});
setZoomLimit(map, google.maps.StyledMapType);
setZoomLimit(map, google.maps.MapTypeId.ROADMAP);
setZoomLimit(map, google.maps.MapTypeId.HYBRID);
setZoomLimit(map, google.maps.MapTypeId.SATELLITE);
setZoomLimit(map, google.maps.MapTypeId.TERRAIN);
map.setMapTypeId(google.maps.StyledMapType);
});
layer_0 = new google.maps.StyledMapType({
query: {
select: "col3",
from: "14XfhpSuNK0aSJkbnb5UFrsE1UPRE_wr4d9IwKjW7"
},
map: map,
styleId: 2,
templateId: 2
});
}
function setZoomLimit(map, mapTypeId){
var mapTypeRegistry = map.mapTypes;
var mapType = mapTypeRegistry.get(mapTypeId);
mapType.maxZoom = 13;
mapType.minZoom = 8; }