【发布时间】:2018-05-31 13:01:40
【问题描述】:
我正在开发 GIS,但无法显示图层切换器。在这种情况下,我使用了 Open Layers 3。
map = new ol.Map({
controls: ol.control.defaults({
attribution: false
}).extend([mousePositionControl,zoomslider]),
target: document.getElementById('map'),
layers: [
new ol.layer.Group({
'title': 'BaseMaps',
layers: [
new ol.layer.Tile({
title: 'RoadMaps',
source: new ol.source.OSM({
url: 'http://mt{0-3}.google.com/vt/lyrs=m&x={x}&y={y}&z={z}',
attributions: [
new ol.Attribution({ html: '© Google' }),
new ol.Attribution({ html: '<a href="https://developers.google.com/maps/terms">Terms of Use.</a>' })
]
})
}),
new ol.layer.Tile({
title: 'Satelite',
type: 'base',
visible: false,
source: new ol.source.OSM({
url: 'http://mt{0-3}.google.com/vt/lyrs=m&x={x}&y={y}&z={z}',
attributions: [
new ol.Attribution({ html: '© Google' }),
new ol.Attribution({ html: '<a href="https://developers.google.com/maps/terms">Terms of Use.</a>' })
]
})
}),
new ol.layer.Tile({
title: 'OSM',
type: 'base',
visible: true,
source: new ol.source.OSM()
})
]
peta_highlight,
layers['layer_kategori'],
})
],
view: new ol.View({
projection: "EPSG:3857",
})
});
layerSwitcher = new ol.control.LayerSwitcher({
tipLabel: 'Légende' // Optional label for button
});
map.addControl(layerSwitcher);
此时我的代码仍然无法正常工作,三张地图无法在我的网站上显示。
【问题讨论】:
-
查看示例代码,了解如何在打开的图层中显示图层切换器:github.com/walkermatt/ol3-layerswitcher
标签: php google-maps gis mapbox openlayers-3