想将iserver图层和本地geojson数据叠加显示在地图上
但是现在geojson数据添加后并没有在地图上显示
iserver的坐标系是平面坐标系
如何添加json格式数据并在地图上显示呢
var boundaryurl =
'http://localhost:8000/iserver/services/map-hubei_province-2/rest/maps/boundary'
var riverUrl =
'http://localhost:8000/iserver/services/map-hubei_province-2/rest/maps/river'
var jsxUrl =
'http://localhost:8000/iserver/services/map-hubei-2/rest/maps/GRH_WTH_ALL'
// 方式一:1.调用 ol.supermap.initMap,根据 SuperMap iServer 地图服务的地图信息,创建地图和底图
// 2.调用 ol.source.TileSuperMapRest 创建叠加图层
ol.supermap
.initMap(boundaryurl, {
mapOptions: {
controls: ol.control
.defaults({ attributionOptions: { collapsed: false } })
.extend([new ol.supermap.control.Logo()]),
},
viewOptions: {
zoom: 3, //文字也变小了
},
})
.then(({ map, source }) => {
var Jinjing = new ol.layer.Tile({
source: new ol.source.TileSuperMapRest({
url: riverUrl,
tileGrid: source.getTileGrid(),
}),
})
map.addLayer(Jinjing)
var Jinjing2 = new ol.layer.Tile({
source: new ol.source.TileSuperMapRest({
url: jsxUrl,
tileGrid: source.getTileGrid(),
}),
})
map.addLayer(Jinjing2)
// 添加降雨量的json数据
// 还是不显示,为什么呢
var dropSource = new ol.source.Vector({
url: './drop.json',
format: new ol.format.GeoJSON(),
// features: (new ol.format.GeoJSON()).readFeatures(obj),
})
var dropLayer = new ol.layer.Vector({
source: dropSource,
})
map.addLayer(dropLayer)
var arr = map.getLayers().array_
console.log(arr,'arr');
})