This repl creates SVG element with Python from a provided shapefile and then adds some editing features with JavaScript.
The Python packages should install themselves if using Replit, but you will need to make sure everything gets installed if using another method.
Use fiona version 1.8.20 (not 1.8.21 or later) for replit (and maybe elsewhere if you get errors). python3 -m poetry add fiona==1.8.20
To view this on TripleLog, click here.
Modify the template.html and/or create.html files in the templates directory.
Three shapefiles are provided, but you can download more from Natural Earth, the U.S. Census, or wherever else. Other formats like geoJSON also will easily work. If the shapefiles are very complex, then you may wish to simplify the curves. If the geoType is not a polygon or multipolygon you will need to figure out what to do.
The geo data is read and a viewBox and scaled version of the desired regions are created and fed into a template.
A Flask server is started to allow for a simple UI (at the /create url by default) to dictate details of the map which gets posted to the server where the SVG is generated.
The Python server will create an HTML file that includes lots of JavaScript functions to edit the map. You can read/edit this JS in the script tag at the bottom of the template.html file. You might wish to create a separate JS file.