django.admin.geomap icon indicating copy to clipboard operation
django.admin.geomap copied to clipboard

How to get map Location outside of Django Admin

Open bioscom opened this issue 2 years ago • 2 comments

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.

bioscom avatar Aug 14 '23 15:08 bioscom

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

vb64 avatar Aug 14 '23 15:08 vb64

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.

bioscom avatar Aug 14 '23 17:08 bioscom