0
geopyとGoogle APIを使用しようとしています。私は、モデルを介して住所を取得し、geopyのロケータにフィードし、Google Maps APIの緯度/経度を知らせる住所詳細を取得しています。 a。)ユニークなlat/lng座標のセットを取得する b)テンプレート をプルダウンします。c)リストをループし、複数のピンをマップに配置します。Django - geopyを使用してGoogleマップテンプレートを設定する
ここに私が現在持っているものがあります。テンプレートにレンダリングするためのコンテキストでループを取得する方法が不明です。
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)