0
This is a picture which shows the number of my shops at this place, but why on my map the number 90 is repeated?. I am using a styleFunc to determine the color, the cold is something like:openlayer3矢量圖層文本顯示重複
function styleFunction(feature) {
var destCount = feature.get("destCount");
var originCount = feature.get("originCount");
if (typeof originCount === "undefined") {
originCount = 0;
}
if (typeof destCount === "undefined") {
destCount = 0;
}
totalPointsCount = destCount + originCount;
totalPointsCount = totalPointsCount.toString();
return getStyle(feature.getProperties().type);
}
function styleFunction(feature) {
var destCount = feature.get("destCount");
var originCount = feature.get("originCount");
if (typeof originCount === "undefined") {
originCount = 0;
}
if (typeof destCount === "undefined") {
destCount = 0;
}
totalPointsCount = destCount + originCount;
totalPointsCount = totalPointsCount.toString();
return getStyle(feature.getProperties().type);
}
代碼創建基礎層是:
fetch('data/xml/service-meta-data.xml').then(function (response) {
return response.text();
}).then(function (text) {
var result = parser.read(text);
var options = ol.source.WMTS.optionsFromCapabilities(result, {
layer: 'China',
matrixSet: 'EPSG:3857'
});
var baseLayer = new ol.layer.Tile({
opacity: 1,
source: new ol.source.WMTS(options)
});
var map = new ol.Map({
layers: [
baseLayer,
vectorLayer
],
overlays: [infoOverlay],
target: 'map',
view: view
});
})
可以忽略所有的數據處理,並專注於stylefunc,誰能告訴我爲什麼這個數字是重複的?許多thxs
只需單擊上面的鏈接即可查看附件 –
當您將圖層發佈爲TileWMS時會發生此問題。你能發佈創建圖層的代碼嗎? –
創建地圖基礎層的代碼的簡單版本就像上面顯示的那樣,我該如何解決這個問題? –