Ich lade Funktionen von einem Server und füge sie als Quelle für eine Vektorebene hinzu.Funktionen, die nicht angezeigt werden
var map = new ol.Map({
target: 'map',
interactions: ol.interaction.defaults().extend([
new ol.interaction.DragRotate()
]),
controls: ol.control.defaults().extend([
new ol.control.FullScreen(),
new ol.control.ScaleLine()
]),
layers: [
new ol.layer.Tile({
source: new ol.source.OSM()
}),
new ol.layer.Tile({
source: new ol.source.TileWMS({
url: 'https://server.com/wms?',
params: {
'LAYERS': 'operational_structures',
'TILED': true
}
}),
maxResolution: 500,
opacity: 0.3
}),
new ol.layer.Vector({
source: new ol.source.Vector({
url: function (extent, resolution, projection) {
return 'https://server/wms?Request=GetFeature&BBOX='
+ extent.join(',');
},
format: new ol.format.GeoJSON(),
strategy: ol.loadingstrategy.bbox
}),
style: new ol.style.Style({
image: new ol.style.Circle({
radius: 10,
fill: new ol.style.Fill({color: 'rgba(255, 0, 0, 0.1)'}),
stroke: new ol.style.Stroke({color: 'red', width: 1})
})
})
})
],
view: new ol.View({
center: ol.proj.fromLonLat([0, 0]),
zoom: 4
})
});
alles funktioniert gut mit dem Abrufen aller Funktionen. Ich kann sie unter Verwendung layer.getSource().getFeatures()
zugreifen. Meine Daten sehen so aus:
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"properties": {
"id": 1,
"ref": "GIS_af05"
},
"geometry": {
"type": "Point",
"coordinates": [ -119383.2138463442, 7156374.7828825945 ]
}
},
{
"type": "Feature",
"properties": {
"id": 2,
"ref": "GIS_af06" },
"geometry": {
"type": "Point",
"coordinates": [ -117573.06816312684, 7163838.359699009 ]
}
},
{
"type": "Feature",
"properties": {
"id": 3,
"ref": "GIS_af21" },
"geometry": {
"type": "Point",
"coordinates": [ -128431.22137966838, 7169061.1280527115 ]
}
}]
}
Aber aus unbekannten Gründen werden sie nicht angezeigt. Fehle ich etwas?
EDIT:
So fand ich heraus, dass es mit den Vorsprüngen vermasselt wird. Es versucht, die Feature-Koordinaten von ESPG:4326
in ESPG:3857
zu konvertieren. Das Problem ist, dass sie bereits ESPG:3857
sind. Wie kann ich das verhindern?
Können Sie den Rest des Codes zur Verfügung stellen? Vor allem die Karteninitialisierung. – ohvitorino
sollten Sie nicht http: // server/wfs anstelle von wms in Ihrer Vektorschicht aufrufen? –
@HichamZouarhi Dies ist nur ein API-Name. Eigentlich rufe ich 'server/wmf? Service = wfs & ...' an, aber ich habe es weg gelassen, weil es nicht erwähnenswert ist. Wie gesagt: Die Daten werden als geoJSON erkannt und ich kann auf die von ihr geladenen "ol.Feature" -Objekte zugreifen. – gerric