I have a shapefile of a country on districts level. I want every district to be clickable on shapefile on Leaflet (Django) and get to another URL where it shows stats of that city or district on another page. How can I set dynamic URLs like each district have a unique id so URL will be based on id? I don't know how to get this process done.
Have a look at this answer:
https://gis.stackexchange.com/questions/42631/go-to-the-url-on-click-with-geojson
You want to set a click event on the layer. When clicked, run a function that opens a url based on one of attributes in your shapefile.
When instantiating the layer use:
onEachFeature: openShapeURL
Something like this:
function openShapeURL(e) {
window.open('http://www.google.com' + feature.properties.<YOUR-VARIABLE-HERE>,'_blank');
}