django.admin.geomap
django.admin.geomap copied to clipboard
How to get map Location outside of Django Admin
Thank you very much for detailed explanation of this project.
But how do I do it if I want to render the map and get the longitude and latitude outside of the Django Admin. I want to do it on a Django template. Get the Longitude and Latitude based on user search for location.
Your resonse will be greatly appreciated.
Thanks.
Can you explain your "user search for location" case in more detail?
Using the library outside the admin site in templates is described here: https://github.com/vb64/django.admin.geomap#main-page-with-a-list-of-objects-on-the-map
import folium from folium import plugins
map = folium.Map(location=[location_data['lat'], location_data['lon']], zoom_start=8) coordinates = (location_data['lat'], location_data['lon']) icon=folium.Icon(color='red') folium.Marker(coordinates, icon=icon).add_to(map) plugins.Geocoder().add_to(map)
The last line adds a search box to the map and allow user to search for a location.
Thanks. I will try the link you sent.
Thanks for quick response.