gpt4 book ai didi

javascript - Google map MapType 接口(interface)中 maxZoom 属性的用途?

转载 作者:行者123 更新时间:2023-12-03 09:55:47 24 4
gpt4 key购买 nike

详细介绍 MapTypes 接口(interface)的 Google map API 指南对“必需”属性做了以下说明:

maxZoom (required) specifies the maximum zoom level at which to display tiles of this map type.

但是,在 Google 给出的示例中:

https://developers.google.com/maps/documentation/javascript/examples/maptype-base

甚至不包括 maxZoom 属性。

如果修改代码以包含 maxZoom 属性(如下所示),则该属性不会产生任何影响 - 应该吗?一些澄清会很好......

<!DOCTYPE html>
<html>
<head>
<title>Overlay map types</title>
<style>
html, body, #map-canvas {
height: 100%;
margin: 0px;
padding: 0px;
}
</style>
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp"></script>
<script>
/** @constructor */
function CoordMapType(tileSize) {
this.tileSize = tileSize;
this.maxZoom = 12; // <--- THIS HAS NO EFFECT ??
}

CoordMapType.prototype.getTile = function (coord, zoom, ownerDocument) {
var div = ownerDocument.createElement('div');
div.innerHTML = coord.toString() + '<br>zoom: ' + zoom.toString();
div.style.width = this.tileSize.width + 'px';
div.style.height = this.tileSize.height + 'px';
div.style.fontSize = '10';
div.style.borderStyle = 'solid';
div.style.borderWidth = '1px';
div.style.borderColor = '#AAAAAA';
return div;
};

var map;
var chicago = new google.maps.LatLng(41.850033, -87.6500523);

function initialize() {
var mapOptions = {
zoom: 10,
center: chicago
};
map = new google.maps.Map(document.getElementById('map-canvas'),
mapOptions);

// Insert this overlay map type as the first overlay map type at
// position 0. Note that all overlay map types appear on top of
// their parent base map.
map.overlayMapTypes.insertAt( 0, new CoordMapType(new google.maps.Size(256, 256)));
}

google.maps.event.addDomListener(window, 'load', initialize);

</script>
</head>
<body>
<div id="map-canvas"></div>
</body>
</html>

最佳答案

在 Google map 文档中标题为“MapType 对象规范”的部分中发现了这一点...

maxZoom Type: number

The maximum zoom level for the map when displaying this MapType. Required for base MapTypes, ignored for overlay MapTypes.

因此,overlay MapTypes 不需要 maxZoom 属性;这对应于我的原始代码示例中的行为。

关于javascript - Google map MapType 接口(interface)中 maxZoom 属性的用途?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30746936/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com