I have GeoJSON file named json_point2. This file holds point data as follows:
var json_point2={
"type": "FeatureCollection",
"crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:OGC:1.3:CRS84" } },
"features": [
{ "type": "Feature", "properties": { "Class": null }, "geometry": { "type": "Point", "coordinates": [ 40.193168611061743, 40.904508523555492 ] } },
{ "type": "Feature", "properties": { "Class": null }, "geometry": { "type": "Point", "coordinates": [ 40.191358449981372, 40.902051540140285 ] } },
When I click this point on my web apps, I want to enter input value on popup and save this value geojson Class properties.
I can click on the point with the following code and enter the attribute. But he does not record it in his database.
My code:
map.createPane('pane_point2');
map.getPane('pane_point2').style.zIndex = 602;
map.getPane('pane_point2').style['mix-blend-mode'] = 'normal';
var layer_point2 = new L.geoJson(json_point2, {
attribution: '<a href=""></a>',
pane: 'pane_point2',
onEachFeature: function (feature, layer) {
var input = L.DomUtil.create('input', 'my-input');
input.value = feature.properties.Class;
L.DomEvent.addListener(input, 'change', function () {
feature.properties.Class = input.value;
});
layer.bindPopup(input);
}
}).addTo(map);
L.DomUtil.create
doesn't change the .geojson file. For that purpose I would recommend you to use geojson.io service. After adding some features there you may easily rewrite your .geojson. It works great with the GitHub.