【发布时间】:2022-01-01 10:44:53
【问题描述】:
我正在尝试向我的 openlayers 项目添加一个 azure 地图图层。我可以使用 this third party plugin and example 和我的 azure maps 键制作基本地图。但是,当我尝试从 Geoserver 添加其他层(例如 OSM 或 WMS 层)时,它会在控制台中引发错误:“未捕获的 TypeError:ol.source.OSM 不是构造函数”。我有许多不同的图层类型(OSM、WMS、XYZ),我想在 Azure 中添加它们,但我无法让其中任何一个工作,它们都抛出类似的错误。
有什么想法可以在 Openlayers 中在 Azure 地图旁边添加其他图层吗?
相关代码sn-p:
<!-- Add reference to the Azure Maps OpenLayers plugin.-->
<script src="./js/azure-maps-openlayers.js"></script>
<script type='text/javascript'>
var map;
function GetMap() {
//Add authentication details for connecting to Azure Maps.
var authOptions = {
authType: 'subscriptionKey',
subscriptionKey: 'aaaaaaaabbbbbbbbccccccccddddddddd'
};
//Create a map instance.
map = new ol.Map({
target: 'myMap',
layers: [
new ol.layer.Tile({
type: 'base',
visible: true,
source: new ol.source.AzureMaps({
authOptions: authOptions,
tilesetId: 'microsoft.imagery'
})
}),
new ol.layer.Tile({
type: 'overlay',
visible: false,
source: new ol.source.OSM()
})
],
view: new ol.View({
center: [0, 0],
zoom: 2
})
});
}
</script>
【问题讨论】:
标签: javascript azure openlayers openstreetmap