Search code examples
mapsleafletgeojsonleaflet.drawdata-collection

Embed leaflet data collection or geojson.io map to form


I'm trying to figure out the most lightweight way to collect data for individual mapped polygons from non-technical users. Here's the end vision: users fill out a web form, draw a shape, and then they can easily email their formatted data to me or my colleagues (I know-- the email idea is probably horrifying readers, but I'm working within a lot of restrictive parameters beyond my control. Email is a known quantity.).

Is there a way to strip down something like geojson.io or even just a leaflet map with leaflet.draw and then pass resulting coordinates into text that can be emailed?

Again, my needs are basic. One shape would be mapped at a time. The fewer visual options and controls the better. My audience is largely very non-technical.

It looks like this user was trying to ask the same question, but didn't get far.

Thanks!


Solution

  • As explained here, you cannot send your geojson data directly but you can let the browser open a mail client with preset data.

      var text=JSON.stringify(drawnItems.toGeoJSON());
      window.open('mailto:[email protected]?subject=subject&body=' + text);
    

    Here is a full example