GPSから自分お位置をマーカーとして追加したいです。
(赤いマークなやつ)
途中まで記載したのですが、その部分が分からなくて止まっています。
教えていただけますか。
Python
1import location 2import time 3import photos 4import appex 5import ui 6import dialogs 7from random import randrange 8import folium 9 10location_options = [ 11 {'title': 'My Location', 'coords': (0, 0)}, 12] 13def get_location(): 14 location.start_updates() 15 loc = location.get_location() 16 location.stop_updates() 17 if loc: 18 return loc['latitude'], loc['longitude'] 19 20def main(): 21 opt = dialogs.list_dialog('Select Mode', location_options) 22 if opt is None: 23 return 24 elif opt['coords'] == (0, 0): 25 # Use current location 26 loc = get_location() 27 else: 28 loc = opt['coords'] 29 if loc: 30 w, h = 540, 540 # Size of the image (points) 31 map_w, map_h = 250, 250 # Size of the map (meters) 32 folium.Marker(location=[latitude, longtude], popup=name).add_to(loc) 33 lat, lng = loc 34 img = location.render_map_snapshot(lat, lng, width=map_w, height=map_h, img_width=w, img_height=h, map_type='satellite') 35 if not img: 36 print('Failed not render map') 37 return 38 jpeg_data = img.to_jpeg() 39 with open('.temp.jpg', 'wb') as f: 40 f.write(jpeg_data) 41 img.show() 42 #s = dialogs.alert('Save to Photos?', 'Do you want to save the image to your photo library?', 'Save to Photos') 43 #if s == 1: 44 #photos.create_image_asset('.temp.jpg') 45 46 47 else: 48 print('error') 49 50if __name__ == '__main__': 51 main() 52 53
![guest](/img/icon/icnUserSample.jpg)
あなたの回答
tips
プレビュー