You can download this code by clicking the button below.
This code is now available for download.
This function creates a map using the Folium library and adds a random number of markers to it.
Technology Stack : Folium, NumPy
Code Type : Map tag generation
Code Difficulty : Intermediate
def random_marker_map(center, zoom_level):
import folium
import random
import numpy as np
# Create a map centered on the given coordinates with the specified zoom level
m = folium.Map(location=center, zoom_start=zoom_level)
# Generate random coordinates around the center point
num_markers = random.randint(5, 15)
for _ in range(num_markers):
random_lat = center[0] + np.random.normal(0, 0.05)
random_lon = center[1] + np.random.normal(0, 0.05)
folium.Marker([random_lat, random_lon]).add_to(m)
return m