| | import folium |
| | import json |
| | import os |
| |
|
| | def generate_map(geojson_file, output_file): |
| | |
| | with open(geojson_file) as f: |
| | geojson_data = json.load(f) |
| |
|
| | |
| | m = folium.Map(location=[-7.5, 112.5], zoom_start=7) |
| |
|
| | |
| | folium.GeoJson( |
| | geojson_data, |
| | name='geojson', |
| | tooltip=folium.GeoJsonTooltip(fields=['name'], aliases=['Region:']) |
| | ).add_to(m) |
| |
|
| | |
| | folium.LayerControl().add_to(m) |
| |
|
| | |
| | m.save(output_file) |
| | print(f'Map has been generated and saved to {output_file}') |
| |
|
| | if __name__ == '__main__': |
| | geojson_path = os.path.join('data', 'geojson', 'jatim.geojson') |
| | output_path = os.path.join('app', 'templates', 'map.html') |
| | generate_map(geojson_path, output_path) |