【发布时间】:2017-09-26 01:10:57
【问题描述】:
我正在尝试在OpenLayers 3 中添加新的ESRI Vector Basemaps。我已经通过修改 OpenLayers 发布的Mapbox Example 来显示未设置样式的图层。
显然,我必须删除 style: createMapboxStreetsV6Style() 选项才能显示 esri 层。所以基本上地图不知道正确显示图层的样式信息。
我认为应该可以这样做,因为 ESRI's Leaflet port 和 example 已经在这样做了。我认为有关 esri 样式 ID 的信息可在此处Leaflet code 获得。
OpenLayers 应该已经能够使用所有这些信息,因为它能够显示 Mapbox 图层。我需要帮助的是,如何让它使用 ESRI 的样式信息。
这是我目前所拥有的 (codepen here):
var map = new ol.Map({
layers: [
new ol.layer.VectorTile({
source: new ol.source.VectorTile({
format: new ol.format.MVT(),
tileGrid: ol.tilegrid.createXYZ({maxZoom: 22}),
tilePixelRatio: 16,
url: 'https://basemaps.arcgis.com/v1/arcgis/rest/services/World_Basemap/VectorTileServer/tile/{z}/{y}/{x}.pbf'
})
})
],
target: 'map',
view: new ol.View({
center: [0, 0],
zoom: 2
})
});
.map {
background: #f8f4f0;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/openlayers/4.1.0/ol.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/openlayers/4.1.0/ol.css" rel="stylesheet"/>
<div id="map" class="map"></div>
【问题讨论】:
-
您是否尝试在gis.stackexchange.com 上发布此问题?您可能会在那里获得更多帮助。
-
不太确定我是否遵循,但在 OL 示例页面上有一个非常好的示例:openlayers.org/en/latest/examples/xyz-esri.html 通过修改地图对象中“url”属性的第二部分,您可以选择您想要的层。
-
@stopopol 该示例并未显示矢量底图。只是一个普通的图像瓷砖。矢量底图是动态样式:arcgis.com/home/…
标签: javascript gis openlayers openlayers-3 esri