File size: 1,285 Bytes
79c9006
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
from flask import Flask, render_template
import folium

app = Flask(__name__)

@app.route('/')
def index():
    return render_template('index.html')

@app.route('/admin')
def admin():
    # Create a map centered on Delhi
    delhi_coordinates = [28.6139, 77.2090]
    folium_map = folium.Map(location=delhi_coordinates, zoom_start=12)

    # Add predefined markers in Delhi
    markers = [
        {"name": "India Gate", "coordinates": [28.6129, 77.2295]},
        {"name": "Red Fort", "coordinates": [28.6562, 77.2410]},
        {"name": "Qutub Minar", "coordinates": [28.5245, 77.1855]},
    ]

    # Add markers to the map
    for marker in markers:
        folium.Marker(
            location=marker["coordinates"],
            popup=marker["name"],
            icon=folium.Icon(color="blue", icon="info-sign"),
        ).add_to(folium_map)

    # Use a valid Folium tile layer
    folium.TileLayer('OpenStreetMap').add_to(folium_map)

    # Add Layer Control for toggling between tile layers
    folium.LayerControl().add_to(folium_map)

    # Generate the map HTML
    map_html = folium_map._repr_html_()

    # Render the template with the map
    return render_template('admin.html', map=map_html)

if __name__ == '__main__':
    app.run(host='0.0.0.0', port=7860, debug=True)