1

I want to add the ability to edit a point layer in my leaflet-map.

When I displayed objects in this way, using custom markers and the markercluster plug-in did not have any problems:

var treeIconList = L.icon({
        iconUrl: '/site/images/list16-3.png'    });
var treeIconHvoya = L.icon({
        iconUrl: '/site/images/hvoya16.png'     });



var owsrootUrl = 'http://localhost:8080/geoserver/ows'; 

var defaultParameters = { 
service : 'WFS', 
version : '2.0.0', 
request : 'GetFeature', 
typeName : 'postgis01:flora', 
outputFormat : 'text/javascript', 
format_options : 'callback:getJson', 
SrsName : 'EPSG:4326' 
}; 

var parameters = L.Util.extend(defaultParameters); 
var URL = owsrootUrl + L.Util.getParamString(parameters); 

var WFSLayer = null; 

var markers = L.markerClusterGroup();

var ajax = $.ajax({ 
url : URL, 
dataType : 'jsonp', 
jsonpCallback : 'getJson', 
success : function (response) { 
WFSLayer = L.geoJson(response, { 
pointToLayer: function (feature, latlng) {

    switch (feature.properties.type) {
        case 'F': return L.marker(latlng, {icon: treeIconList});
        case 'T': return L.marker(latlng, {icon: treeIconHvoya});  
                }
        },
onEachFeature: function (feature, layer) { 
var input = L.DomUtil.create('input', 'my-input');
    input.value = feature.properties.type;
    L.DomEvent.addListener(input, 'change', function () {
      feature.properties.type = input.value;
    });
    layer.bindPopup(input);
} 
}).addTo(markers.addTo(mymap));
} 
}); 

After using the https://github.com/Flexberry/Leaflet-WFST plugin, no work custom markers, markercluster:

var treeIconList = L.icon({
        iconUrl: '/site/images/list16-3.png'   });
var treeIconHvoya = L.icon({
        iconUrl: '/site/images/hvoya16.png'    });    

var markers = L.markerClusterGroup();      
var points = new L.WFS({
   url: 'http://localhost:8080/geoserver/ows',
    typeNS: 'postgis01',
    typeName: 'flora',
    crs: L.CRS.EPSG3395,
    geometryField: 'shape',

    pointToLayer: function (feature, latlng) {

    switch (feature.properties.type) {
        case 'F': return L.marker(latlng, {icon: treeIconList});
        case 'T': return L.marker(latlng, {icon: treeIconHvoya});  
                }
        }
  }).addTo(markers.addTo(mymap));

What do you think is the problem? Or how else can you solve the task of editing a point layer in a leaflet or at least editing the attributes of individual objects of a point layer.

  • please add the relevant section of the WFS getCabablities file for the layer flora – Ian Turton Jun 6 '18 at 7:59
  • I think that L.WFSis not synchronous. I had to register an onLoad function to make it work, like this: points.on('load', function(){ markers.addLayer(points); }); – StackUnder Sep 3 '18 at 18:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.