mappiamo / mapi-geoCMS

MAPPIAMO main repository. The geoCMS for mapping site built with <3, openstreetmap, leaflet, bootstrap, php, mysql....
http://www.mappiamo.org
GNU General Public License v2.0
24 stars 15 forks source link

Leaflet.draw cannot edit saved data #19

Closed CosmicLaca closed 9 years ago

CosmicLaca commented 9 years ago

The problem is on the file: manager\modules\mcontent\views\edit.php started on row: 242.

Problem details:


Looking for solutions to read and display saved data, and edit same data with leaflet.draw at same interface. For WKT.parser() data have to be indexed (but how?), or using another method L.polyline(x_Geoms).addTo(draw_layer); the lan/lot data must be changed to lon/lat (on client side).

sabas commented 9 years ago

x_Geoms = L.geoJson(geoj); The geojson layer in leaflet extends the featuregroup layer. Imo you have to convert the geojson to featuregroup So the idea would be to use the commented method, swapping the coordinates (http://jsperf.com/switch-elements). It's a linear operation [O(n)], so it should be feasible

CosmicLaca commented 9 years ago

To swapping coordinates I think is very dirty solution for unknown size GEOMETRYCOLLECTION(), so I dont wanna use it.

The feature group conversion not succeed or I dont know how to do it. I created layer for leaflet.daw on previously included .js like this: var draw_layer = L.featureGroup().addTo(map);

sabas commented 9 years ago

What about something like

var draw_layer = L.featureGroup().addTo(map);
function moveToFeatureGroup (feature, layer){
layer.addTo(draw_layer);
}
x_Geoms = L.geoJson(geoj, {onEachFeature: moveToFeatureGroup});
CosmicLaca commented 9 years ago

Thank you! I trying / testing this method, and I have result.

CosmicLaca commented 9 years ago

Thank you, this is good solution, uploading the first version for testing