def element_detail(request, elem_id): element = get_object_or_404(Element, id=elem_id) location = ElementAddress.objects.get(element=element) locations = [] for loc in ElementAddress.objects.filter(element=element): tmp = {} tmp['city'] = loc.city tmp['state'] = loc.state for i in loc.location: print(type(i)) tmp['more'] = geolocator.geocode(loc.location) map = folium.Map(location=loc.location) folium.Marker(location=loc.location).add_to(map) tmp['map'] = map._repr_html_() locations.append(tmp) context = { 'element': element, 'locations': locations, } return render(request, 'element-detail.html', context)
def element_detail(request, elem_id): element = get_object_or_404(Element, id=elem_id) location = ElementAddress.objects.get(element=element) location_geocoded = geolocator.geocode(location.location) folium.Map(location=location.location).save('restaurant/map.html') # elements = Element.objects.filter(category=category_obj) # addresses = element.address.all() context = { 'element': element, 'location': location_geocoded, # 'addresses': addresses } return render(request, 'element-detail.html', context)
def element_detail(request, elem_id): element = get_object_or_404(Element, id=elem_id) location = ElementAddress.objects.get(element=element) location_geocoded = geolocator.geocode(location.location) map = folium.Map(location=location.location) folium.Marker(location=location.location).add_to(map) context = { 'element': element, 'location': location_geocoded, 'map': map._repr_html_(), } return render(request, 'element-detail.html', context)
def element_detail(request, elem_id): element = get_object_or_404(Element, id=elem_id) location = ElementAddress.objects.get(element=element) location_geocoded = geolocator.geocode(location.location) map = folium.Map(location=location.location) folium.Marker(location=location.location).add_to(map) context = { 'element': element, 'location': location_geocoded, 'map': map, } return render(request, 'element-detail.html', context) map = folium.Map(location=[40.7118, -74.0131], zoom_start=12) for coord in coords: folium.Marker(location=[coord[0], coord[1]]).add_to(map)
def element_detail(request, elem_id): element = get_object_or_404(Element, id=elem_id) location = ElementAddress.objects.get(element=element) locations = [] for loc in ElementAddress.objects.get(element=element): tmp = [] tmp.append(loc.city) tmp.append(loc.state) tmp.append(geolocator.geocode(location.location)) map = folium.Map(location=location.location) folium.Marker(location=location.location).add_to(map) tmp.append(map._repr_html_()) context = { 'element': element, 'locations': locations, } return render(request, 'element-detail.html', context)