def map_02_details(): # let's start again with a clean copy of the map of United State san_map = folium.Map(location=[latitude, longitude], zoom_start=4) # instantiate a mark cluster object for the incidents in the dataframe incidents = plugins.MarkerCluster().add_to(san_map) # loop through the dataframe and add each data point to the mark cluster for lat, lng, label, in zip(data.latitude, data.longitude, cdata1.Title): folium.Marker( location=[lat, lng], icon=None, popup=label, ).add_to(incidents) # add incidents to map incident_map2 = san_map.add_child(incidents) display(incident_map2) incident_map2.save('templates/map_02_details.html') return render_template("map_02_details.html")
def map_view(request): """ Main page - map of all the sensors """ gmaps = googlemaps.Client(key='AIzaSyCZO9lx7k1gFhU-Fv9hSZ9PUynZb0EjeBg') sensors = Sensor.objects.all() sensor_map = folium.Map(location=[50.064316, 19.985638], zoom_start=12, tiles='Stamen Terrain') for sensor in sensors: localisation = sensor.localisation sensor_id = sensor.sensor_id coordinates = (gmaps.geocode(localisation))[0]['geometry']['location'] popup = '%s; sensor_id = %i' % (localisation, sensor_id) folium.Marker([coordinates['lat'], coordinates['lng']], popup=popup).add_to(sensor_map) sensor_map.save('templates/map.html') return render_to_response('sensors_map.html')
def get_place_ui(place): return folium.Marker(place["geometry"]["coordinates"][::-1], popup=bju.dumps(place["properties"]))
# -*- coding: utf-8 -*- import os import pandas as pd from folium import folium from pandas import compat from folium.plugins import MarkerCluster os.chdir('../VKHCG/01-Vermeulen/00-RawData') compat.PY3 = True universities = pd.read_csv("uk_universities_locations2.csv") uk = folium.Map( location=[universities.lat.mean(axis=0), universities.lon.mean(axis=0)], zoom_start=5) marker_cluster = MarkerCluster("Universities").add_to(uk) #add a marker for each university for each in universities.iterrows(): folium.Marker(list([each[1]['lat'], each[1]['lon']]), popup=each[1]['Name']).add_to(marker_cluster) uk.save("./universities.html")