您好,您可用使用
var layer = new ol.layer.Tile({ source: new ol.source.TileSuperMapRest({ url: url }), projection: 'EPSG:4326' }); map.addLayer(layer);
来添加到地图上,再用
map.removeLayer(layer);
移除地图
如果在新建map的时候不设置projection的话,如下,地图定位不到center
map = new Map({ target: 'mapContainer', controls: control.defaults({ attribution: false, rotate: false, zoom: false }), view: new View({ center: center, zoom: 10, // projection: 'EPSG:4326' }) })
在定义layer时设置projection好像不生效啊,如下
map.addLayer(new TileLayer({ source: new TileSuperMapRest({ url: 'http://localhost:8090/iserver/services/map-china400/rest/maps/China', wrapX: true }), projection: 'EPSG:3857' }))
我看openlayers官网的API TileLayer没有projection这个属性啊