解決策はそれほど遠くないことはわかっていますが、ユーザー入力に基づいて数値をマップ縮尺に割り当てる機能を実装するのに苦労しています。コードは一目瞭然ですが、入力を使用して 4 つのズーム状態からユーザーが選択し、ズームの開始点としてマップに数値を返すようにしたいと考えています。
zoom=5
while True:
where = raw_input('Where would you like a map of?')
try:
heatmap = folium.Map(location=geo(where), tiles='Stamen Toner', zoom_start=zoom)
pointmap = folium.Map(location=geo(where), tiles='Stamen Toner', zoom_start=zoom)
except AttributeError, GeocoderServiceError:
print "Cannot create map with the given location. Please try again."
else:
break
while True:
zoom_state = ['city', 'state', 'country', 'world']
zoom_state= raw_input('What level of detail would you like: city, state, country, or world?')
try:
for response in zoom_state:
if response is ['city']:
zoom == 9
if response is ['state']:
zoom == 7
if response is ['country']:
zoom == 5
if response is ['world']:
zoom == 9
except TypeError, IndexError:
print 'Please enter: city, state, country, or world. Try again'
continue
else:
break
heatmap = folium.Map(location=geo(where), tiles='Stamen Toner', zoom_start=zoom)
pointmap = folium.Map(location=geo(where), tiles='Stamen Toner', zoom_start=zoom)
現在のところ、zoom_state には何でも入れることができ、実行されます。
前もって感謝します!