我目前正在尝试从Geoserver获取矢量平铺线几何的起点和终点。
以下部分是用于获取该值的代码:
this.featuresMap.set(finalURL, this.mapService.map.querySourceFeatures(this.cId, { sourceLayer: finalURL }));
startFeature = this.featuresMap.get(finalURL)[0]; //First entity
startFeature['properties']['order'] = 0;
endFeature = this.featuresMap.get(finalURL)[this.featuresMap.get(finalURL).length - 1]; //Latest entity
endFeature['properties']['order'] = 1;
this.objectMap.addSource(finalURL + 'startEndPoints', {
"type": "geojson",
"data": {
"type": "FeatureCollection",
"features": [startFeature, endFeature]
}
});
this.objectMap.addLayer({
"id": finalURL + 'startEndPoints_layer',
"type": "circle",
"source": finalURL + 'startEndPoints',
"paint": {
"circle-radius": 6,
"circle-color": [
"case",
["==", ['get', 'order'], 0], "blue",
["==", ['get', 'order'], 1], "red",
"black"
]
},
});
当显示/隐藏一个特定图层时,结果会有所不同,因为在该图层的可见性每次更改中,点的位置都是不同的。
可能与矢量图块和缩放级别有关,还是与执行代码的地图事件/生命周期有关?