I am trying to use geopy and the Google api. I am querying through models to pull address city,state address detail that will feed into geopy's locator and give me lat/lng for the Google Maps api. I would like to: a.) Get a unique set of lat/lng coordinates b.) Pull into template c.) Loop through list and post multiple pins on a map.
Here is what i currently have in views. Not sure how to get the loop in the context for rendering into the template.
def maps_multi(request):
address_list = CustomerOrder.objects.filter(city__icontains = 'CA').distinct() # pulls all unique addresses in California
address_list1 = address_list[0:2] # temporarily select first three addresses from list to test
geolocator = GoogleV3()
for x in address_list1:
add_list = []
add_city = x.city
location = geolocator.geocode(add_city)
add_list.append(location)
print(add_list)
context = {}
return render(request, 'orderdisplay/maps_multi.html', context)