Leaflet-WFST
Leaflet-WFST copied to clipboard
WFS problems
Im trying to show Point features from a WFS :
https://api.dataforsyningen.dk/forvaltning2?token=9ca510be3c4eca89b1333cadbaa60c36&servicename=forvaltning2&SERVICE=WFS&REQUEST=Getfeature&VERSION=1.1.0&TYPENAMES=forvaltning:togstation&TYPENAME=forvaltning:togstation&STARTINDEX=0&COUNT=100000&SRSNAME=urn:ogc:def:crs:EPSG::25832
ERROR
But im getting this error - TypeError: undefined is not an object (evaluating 'featureInfo.attributes.targetNamespace.value')
Response
In the console I can see that the Response is 200 (ok)
WFS Layer
var togstationer = new L.WFS({
url:'https://api.dataforsyningen.dk/forvaltning2?token='+kftoken+'&servicename=forvaltning2&SERVICE=WFS&REQUEST=Getfeature&VERSION=1.1.0&TYPENAMES=forvaltning:togstation&TYPENAME=forvaltning:togstation&STARTINDEX=0&COUNT=100000&SRSNAME=urn:ogc:def:crs:EPSG::25832',
geometryField: 'gml:Point',
style: {
"color": "#ff7800",
"weight": 5,
"opacity": 1
},
}).addTo(map);
The entire code :
(function() {
// Set Kortforsyningen token, replace with your own token
var kftoken = '9ca510be3c4eca89b1333cadbaa60c36';
// Set the attribution (the copyright statement shown in the lower right corner)
// We do this as we want the same attributions for all layers
var myAttributionText = '© <a target="_blank" href="https://download.kortforsyningen.dk/content/vilk%C3%A5r-og-betingelser">Styrelsen for Dataforsyning og Effektivisering</a>';
// Make custom projection using proj4 and proj4leaflet
var crs = new L.Proj.CRS('EPSG:25832',
'+proj=utm +zone=32 +ellps=GRS80 +units=m +no_defs', {
resolutions: [1638.4,819.2,409.6,204.8,102.4,51.2,25.6,12.8,6.4,3.2,1.6,0.8,0.4,0.2,0.1]
});
// Make the map object using the custom projection
var map = new L.Map('map', {
crs: crs,
center: [55.709155, 11.459081], // Set center location
zoom: 9, // Set zoom level,
});
// Define layers
// Skærmkort [WMTS:topo_skaermkort]
var ortofoto = L.tileLayer.wms('https://services.kortforsyningen.dk/orto_foraar', {
layers: 'orto_foraar',
token: kftoken,
format: 'image/jpeg',
attribution: myAttributionText
});
// Skærmkort [WMTS:topo_skaermkort]
var topo = L.tileLayer.wms('https://services.kortforsyningen.dk/topo_skaermkort', {
layers: 'dtk_skaermkort',
token: kftoken,
format: 'image/png',
attribution: myAttributionText
}).addTo(map);
var togstationer = new L.WFS({
url:'https://api.dataforsyningen.dk/forvaltning2?token='+kftoken+'&servicename=forvaltning2&SERVICE=WFS&REQUEST=Getfeature&VERSION=1.1.0&TYPENAMES=forvaltning:togstation&TYPENAME=forvaltning:togstation&STARTINDEX=0&COUNT=100000&SRSNAME=urn:ogc:def:crs:EPSG::25832',
geometryField: 'gml:Point',
style: {
"color": "#ff7800",
"weight": 5,
"opacity": 1
},
}).addTo(map);
// var filter = new L.Filter.BBox('ogr_geometry', L.latLngBounds(L.latLng(40.712, -74.227), L.latLng(40.774, -74.125)), crs);
//filter.toGml();
// Hillshade overlay [WMS:dhm]
var hillshade = L.tileLayer.wms('https://services.kortforsyningen.dk/dhm', {
transparent: true,
layers: 'dhm_terraen_skyggekort_transparent_overdrevet',
token: kftoken,
format: 'image/png',
attribution: myAttributionText,
continuousWorld: true,
});
// Define layer groups for layer control
var baseLayers = {
"Ortofoto": ortofoto,
"Skærmkort": topo
};
var overlays = {
"togstationer" : togstationer,
"Hillshade": hillshade
};
// Add layer control to map
L.control.layers(baseLayers, overlays).addTo(map);
// Add scale line to map
L.control.scale({imperial: false}).addTo(map); // disable feet units
})();
thank you in advance
We use geoserver as server example and it always returns gml response with targetNamespace attribute. Your server answer doesn't contain this attribute. Which gis-server hosts your wfs data? Can you add attribute targetNamespace to server response?
Thank you for your reply.
We are using MapServer,unfortunately adding targetNamespace is not an option.
Do you by any chance have some boilerplate code that would work with for my API?