Skip to main content
100%

Leaflet.draw control for CartoDB

✓ Published0🌍 Public
Aandrewxhill
Last edited Jun 21, 2013
Created on Jun 21, 2013

This example shows a Leaflet map where users can draw, edit, and delete vector shapes, with changes persisted to a CartoDB backend. The code listens for drawing actions and converts edited or newly drawn layers into GeoJSON, sending them via POST requests to CartoDB’s SQL API. It uses the Leaflet.draw plugin and Leaflet’s layer management (e.g., `layers.eachLayer`, `layers.toGeoJSON`) to collect geometries and associated `cartodb_id` values. A custom SQL function (`osm2_upsert_leaflet_data`) handles inserts, updates, and deletions, and the response updates the layer’s ID after insertion.

AI-generated description

Similar vizzes