从 ArcGIS WebMap 查找缩放级别
Finding Zoom level from ArcGIS WebMap
我正在将使用 ArcGIS Online 制作的 Web 地图加载到一个简单的查看器应用程序中。我希望位置和缩放级别与原始匹配。
我可以从 map.portalItem.extent
获取中心,但如何找到缩放?
app.map=new WebMap({ portalItem: { id: myId }});
app.map.load().then(function() {
app.center[0]=app.map.portalItem.extent.center.longitude;
app.center[1]=app.map.portalItem.extent.center.latitude;
app.zoom=???
});
...
app.mapView.when(function() { app.activeView.goTo({ center:app.center, zoom: app.zoom }) });
范围存储在 WebMap 中(不是缩放级别)- 但这没关系,因为您使用的 goTo()
function 需要许多不同的输入,包括范围。所以只需将您的代码更改为如下内容:
app.map=new WebMap({ portalItem: { id: myId }});
app.map.load().then(function() {
app.extent=app.map.portalItem.extent;
});
...
app.mapView.when(function() { app.activeView.goTo(app.extent) });
我正在将使用 ArcGIS Online 制作的 Web 地图加载到一个简单的查看器应用程序中。我希望位置和缩放级别与原始匹配。
我可以从 map.portalItem.extent
获取中心,但如何找到缩放?
app.map=new WebMap({ portalItem: { id: myId }});
app.map.load().then(function() {
app.center[0]=app.map.portalItem.extent.center.longitude;
app.center[1]=app.map.portalItem.extent.center.latitude;
app.zoom=???
});
...
app.mapView.when(function() { app.activeView.goTo({ center:app.center, zoom: app.zoom }) });
范围存储在 WebMap 中(不是缩放级别)- 但这没关系,因为您使用的 goTo()
function 需要许多不同的输入,包括范围。所以只需将您的代码更改为如下内容:
app.map=new WebMap({ portalItem: { id: myId }});
app.map.load().then(function() {
app.extent=app.map.portalItem.extent;
});
...
app.mapView.when(function() { app.activeView.goTo(app.extent) });