let url =
"http://10.64.101.123/iserver/services/map-GZGQ-3/rest/maps/zjmaproad";
this.layerInfoService = new mapboxgl.supermap.LayerInfoService(url);
this.layerInfoService.getLayersInfo((result) => {
if (result.result.subLayers.layers) {
var layers1 = result.result.subLayers.layers;
for (var i = 0; i < layers1.length; i++) {
this.list1.push(layers1[i].name);
}
}
});
var index = this.strArr.indexOf(vals);
if (index > -1) {
this.strArr.splice(index, 1); //存在就删除//删除
} else {
this.strArr.push(vals);
}
const res2 = this.list1.filter(
(item1) =>
!this.strArr
.toString()
.split(",")
.some((item2) => item2 === item1)
);
this.list2 = [];
this.strArr
.toString()
.split(",")
.forEach((item) => {
this.list2.push(
new SuperMap.LayerStatus({
layerName: item,
isVisible: "true",
})
);
});
res2.forEach((item) => {
this.list2.push(
new SuperMap.LayerStatus({
layerName: item,
isVisible: "false",
})
);
});
var p = new SuperMap.SetLayerStatusParameters({
layerStatusList: this.list2,
});
this.layerInfoService.setLayerStatus(p, (e) => {
if (e.result) {
var t1 = e.result.newResourceID;
if (this.map.getLayer("simple-tiles")) {
this.map.removeLayer("simple-tiles");
this.map.removeSource("firstLayer");
}
this.map.addSource("firstLayer", {
type: "raster",
tiles: [
"http://10.64.101.123/iserver/services/map-GZGQ-3/rest/maps/zjmaproad/zxyTileImage.png?prjCoordSys=" +
encodeURIComponent('{"epsgCode":3857}') +
"&z={z}&x={x}&y={y}&noWrap=true&transparent=true&cacheEnabled=false&layersID=" +
t1,
],
tileSize: 256,
});
this.map.addLayer({
id: "simple-tiles",
type: "raster",
source: "firstLayer",
minzoom: 0,
maxzoom: 22,
});
this.map.on("click", (e) => {
console.log(e.features, "e.features++e.features", e);
var features = this.map.queryRenderedFeatures(e.point, {
layers: ["simple-tiles"],
});
console.log(features, "features");
if (features.length > 0) {
console.log(features[0].properties, "11111111111");
}
});
}
});
如何获取服务当中具体的某一座桥梁,某一条隧道啊