2015-04-19 12 views

risposta

1

È possibile modificare l'origine opuscolo o scrivere la propria funzione per elaborare i livelli e impostare le proprietà che si stanno cercando.

6

In realtà, il trucco è solo quello di definire il livello feature con il suo type (deve essere un "Feature") e properties (utilizzare questi ultimi per registrare tutte le informazioni è necessario).

map.on('draw:created', function (event) { 
    var layer = event.layer, 
     feature = layer.feature = layer.feature || {}; // Initialize feature 

    feature.type = feature.type || "Feature"; // Initialize feature.type 
    var props = feature.properties = feature.properties || {}; // Initialize feature.properties 
    props.myId = 'This is myId'; 
    drawnItems.addLayer(layer); // whatever you want to do with the created layer 
}); 

Vedi anche Leaflet Draw not taking properties when converting FeatureGroup to GeoJson e update properties of geojson to use it with leaflet

Problemi correlati