def add_temp(self, neigh, boolt, password): print('###add_temp_func###') temp_list = gd.get_temp_codata(neigh) # print(temp_list) if boolt == True: if temp_list == ['no data']: print('') else: for temp in temp_list: lon = float(temp['coor'][1]) lat = float(temp['coor'][0]) marker = MapMarkerPopup(lat=lat, lon=lon, source="廟_標點.png") marker.add_widget( Button(text=neigh + '\n' + temp['name'], font_name='msjhbd.ttc', font_size=15, size_hint=[None, None], size=[100, 100])) self.map.add_widget(marker) if (password == 1): self.add1_temp_list.append(marker) elif (password == 2): self.add2_temp_list.append(marker) print('hoooooo') elif (password == 3): self.add3_temp_list.append(marker) else: print("")
def add_rent(self, password, neigh, Min_price=0, Max_price=100000000): neigh = self.spinner.text + neigh # print(Min_price, Max_price) rent_list = gd.get_rent_codata(neigh) # print(rent_list) if rent_list == ['no data']: print('') else: cou = 1 for rent in rent_list: if (int(rent['price']) >= Min_price) & (int(rent['price']) <= Max_price): lon = float(rent['coor'][1]) lat = float(rent['coor'][0]) marker = MapMarkerPopup(lat=lat, lon=lon, source="店面_標點.png") rent_button = Button(text=neigh + '\n' + '店面' + str(cou) + '\n' + '$' + rent['price'] + '/月', font_name='msjhbd.ttc', font_size=15, size_hint=[None, None], size=[100, 100]) rent_button.bind( on_press=partial(webbrowser.open, rent['web'])) marker.add_widget(rent_button) self.map.add_widget(marker) cou += 1 if (password == 1): self.add1_rent_list.append(marker) elif (password == 2): self.add2_rent_list.append(marker) elif (password == 3): self.add3_rent_list.append(marker)
def add_shop(self, neigh, clist, password): shop_list = gd.get_shop_codata(neigh, clist) # print(shop_list) #self.add1 += 1 #print(self.add1) print('###add_shop_func###') if shop_list == ['no data']: print('') else: for shop in shop_list: lon = float(shop['coor'][1]) lat = float(shop['coor'][0]) marker = MapMarkerPopup(lat=lat, lon=lon, source="競爭對手_標點.png") marker.add_widget( Button(text=neigh + '\n' + shop['name'] + '\n' + shop['class'], font_name='msjhbd.ttc', font_size=15, size_hint=[None, None], size=[150, 150])) self.map.add_marker(marker) if (password == 1): self.add1_shop_list.append(marker) elif (password == 2): self.add2_shop_list.append(marker) elif (password == 3): self.add3_shop_list.append(marker)
def addArretMarker(self, ligne): for arret in data_stop[ligne]: print(arret) arret_marker = MapMarkerPopup( lat=data_stop[ligne][arret]["latitude"], lon=data_stop[ligne][arret]["longitude"], source="bus_stop.png") arret_marker.add_widget( Label(pos=(0, -40), text=data_stop[ligne][arret]["name"], color=(0, 0, 0, 1))) self.arret_list.append(arret_marker) self.mapview.add_marker(arret_marker)
def on_touch_down(self, touch): super().on_touch_down(touch) posts = fetchFromDB() for event in posts: lat = event['lat'] lon = event['lon'] marker = MapMarkerPopup(lon=lon, lat=lat, source="small_marker.png") self.ids.map_view.add_marker(marker) btn = Button(text='Event: ' + event['Event'] + '\n\n\n' + 'Description:' + event['Description'], size_hint=(3, 2), font_size=20) btn.bind(on_release=callback) marker.add_widget(btn)
def distance_meet(self, i): global marker_coord, gncn, nnpal self.comp_logo.append(i) self.remove_widget(self.marker[i]) self.marker[i] = MapMarkerPopup(lat=float(marker_coord[i][0]), lon=float(marker_coord[i][1]), source=self.marker_image[i]) print("kando!!!!!!") Clock.schedule_once(lambda dt: (self.add_widget(self.marker[i])), 2) if (self.marker_image[i] == "new_nepal.png"): # vibrator.vibrate(time=2) nnpal = nnpal + 1 cam = Camera(resolution=(320, 240), play=True) # self.add_widget(cam) # self.vector.pop(i) # marker_coord = np.delete(marker_coord, i, 0) elif (self.marker_image[i] == "greencoin.png"): # vibrator.vibrate(time=2) gncn = gncn + 1 cam = Camera(resolution=(320, 240), play=True)
def _markBase(self): """ Método que cria um novo MapMarkerPopup para marcar a base de lançamento e desabilita o botão """ marker = MapMarkerPopup(lat=self._instDados['Latitude'], lon=self._instDados['Longitude'], source='imgs/markerBase.png') self.ids.mapa.add_widget(marker) self.ids.mapa.center_on(self._instDados['Latitude'], self._instDados['Longitude']) self.ids.bttnMarkBase.disabled = True
def addBusMarker(self, bus_taken): info = data_bus[bus_taken] if self.bus_onMap == True: self.mapview.remove_marker(self.bus_marker) self.removeArretMarker() else: self.bus_onMap = True self.bus_marker = MapMarkerPopup(lat=info["latitude"], lon=info["longitude"], source="bus_marker2.png", size=(20, 20)) self.bus_marker.add_widget( Label(pos=(0, -40), text=bus_taken, color=(0, 0, 0, 1))) self.mapview.add_marker(self.bus_marker) self.mapview.get_latlon_at(Window.size[0] / 2, Window.size[1] / 2, zoom=None) self.addArretMarker("Ligne-" + info["ligne"])
def setInitialLocation(self): global final_location, location_marker, userlogged locationlist = usersDB.getAccountData(userlogged, 'location') location_marker = MapMarkerPopup(lat=locationlist[0], lon=locationlist[1], source="icons/you.png") self.parent.get_screen( "kv_locationmapview").ids.locationmapview.add_widget( location_marker) final_location = locationlist print("DEBUG: Initial location has been set.")
def setMarker(self): global location_marker, final_location latitude = self.ids.locationmapview.lat longitude = self.ids.locationmapview.lon if self.ids.locationsetlabel.text == 'Your Location': self.ids.locationmapview.remove_marker(location_marker) location_marker = MapMarkerPopup(lat=latitude, lon=longitude, source="icons/you.png") self.ids.locationmapview.add_widget(location_marker) self.ids.locationsetlabel.text = 'Location Updated!' final_location = "[" + str(latitude) + ", " + str(longitude) + "]" elif self.ids.locationsetlabel.text == 'Location Updated!': self.ids.locationmapview.remove_marker(location_marker) location_marker = MapMarkerPopup(lat=latitude, lon=longitude, source="icons/you.png") self.ids.locationmapview.add_widget(location_marker) final_location = "[" + str(latitude) + ", " + str(longitude) + "]" print("DEBUG: New location marker has been set.")
def on_enter(self, value): marker = MapMarkerPopup(lat=33.6405, lon=-117.8443) print("enter pressed")
class MapScreen(Screen): def __init__(self, **kwargs): super(MapScreen, self).__init__(**kwargs) self.fl = FloatLayout() with self.fl.canvas: Color(1, 1, 1, .8, mode='rgba') Rectangle(size=Window.size) self.mapview = MapView(zoom=13, lat=48.35, lon=-1.2, pos_hint={"top": 0.9}, size_hint=(1, .7)) self.arret_list = [] self.bus_onMap = None self.arret_onMap = None self.button_menu = Button(height=40, width=40, size_hint=(None, None), pos=(20, 0), pos_hint={'top': 0.97}) self.button_menu.bind(on_press=lambda x: self.get_coo()) self.button_tr_info = Button(size_hint=(1 / 3, .1), pos=(0, 0), pos_hint={'top': 0.1}, text="Menu") self.button_tr_info.bind(on_press=self.pressMenu) self.button_tr_map = Button(size_hint=(1 / 3, .1), pos=(Window.size[0] / 3, 0), pos_hint={'top': 0.1}, text="Map") self.button_tr_map.bind(on_press=self.pressMap) self.button_tr_bus = Button(size_hint=(1 / 3, .1), pos=(Window.size[0] / 1.5, 0), pos_hint={'top': 0.1}, text="Bus") self.button_tr_bus.bind(on_press=self.pressBus) self.fl.add_widget(self.button_menu) self.fl.add_widget(self.button_tr_info) self.fl.add_widget(self.button_tr_map) self.fl.add_widget(self.button_tr_bus) self.fl.add_widget(self.mapview) self.add_widget(self.fl) def pressMenu(self, *args): busapp.screenmanager.current = "Menu principal" def pressMap(self, *args): busapp.screenmanager.current = "Menu map" def pressBus(self, *args): busapp.screenmanager.current = "Menu bus" def addBusMarker(self, bus_taken): info = data_bus[bus_taken] if self.bus_onMap == True: self.mapview.remove_marker(self.bus_marker) self.removeArretMarker() else: self.bus_onMap = True self.bus_marker = MapMarkerPopup(lat=info["latitude"], lon=info["longitude"], source="bus_marker2.png", size=(20, 20)) self.bus_marker.add_widget( Label(pos=(0, -40), text=bus_taken, color=(0, 0, 0, 1))) self.mapview.add_marker(self.bus_marker) self.mapview.get_latlon_at(Window.size[0] / 2, Window.size[1] / 2, zoom=None) self.addArretMarker("Ligne-" + info["ligne"]) def addArretMarker(self, ligne): for arret in data_stop[ligne]: print(arret) arret_marker = MapMarkerPopup( lat=data_stop[ligne][arret]["latitude"], lon=data_stop[ligne][arret]["longitude"], source="bus_stop.png") arret_marker.add_widget( Label(pos=(0, -40), text=data_stop[ligne][arret]["name"], color=(0, 0, 0, 1))) self.arret_list.append(arret_marker) self.mapview.add_marker(arret_marker) def removeArretMarker(self): for arret in self.arret_list: self.mapview.remove_marker(arret) self.arret_list.clear() def get_coo(self): print(self.arret_list) print( str( self.mapview.get_latlon_at(Window.size[0] / 2, Window.size[1] / 2, zoom=None)))
def actualizar_mapa(self, lon1, lat1): self.ids.mapview.center_on(float(lon1), float(lat1)) marker = MapMarkerPopup(lon=float(lon1), lat=float(lat1), source="gps.png") self.ids.mapview.add_widget(marker)
def dibujar(self, lat1, lon1): marker = MapMarkerPopup(lon=float(lon1), lat=float(lat1), source="output-onlinepngtools.png", popup_size=(10, 10)) self.ids.mapview.add_widget(marker)
def loadDoctors(self): # Creates a delete list for marker/list widgets global delete_list delete_list = [] # Loads all doctors and calculate their distance through Harverstine formula results = usersDB.getDoctors() list_of_doctors = {} for doctor in results: location = usersDB.getAccountData(doctor, 'location') list_of_doctors[doctor] = location sorted_list = self.calculateHaversine(list_of_doctors) print("DEBUG: List has been sorted.\n", sorted_list) # Appends the sorted doctor list to the list view screen for doctors in sorted_list: distance = "" doctor_email = doctors[0] if (doctors[1] > 999): distance = str(round((doctors[1] / 1000), 1)) + "K KM" elif (doctors[1] <= 999): distance = (str(doctors[1]) + " KM") primary_text = usersDB.getAccountData( doctor_email, 'fname') + " " + usersDB.getAccountData( doctor_email, 'lname') secondary_text = usersDB.getAccountData(doctor_email, 'profession') profile = ThreeLineAvatarListItem( text=primary_text, secondary_text=secondary_text, tertiary_text=distance, on_release=lambda doctor_email: self.loadDoctorBooking( doctor_email)) exist = True try: image = open("profiles/" + doctor_email + ".jpg") image.close() except IOError: exist = False if exist == True: picture = ImageLeftWidget(source="profiles/" + doctor_email + ".jpg") else: picture = ImageLeftWidget(source="profiles/default.png") profile.add_widget(picture) self.parent.get_screen( "kv_doctorlistview").ids.doctor_list.add_widget(profile) print("DEBUG: Added a doctor to list") # Creates a marker for the user's location in map view screen, appends to delete list for later user_location = usersDB.getAccountData(userlogged, 'location') user_marker = MapMarkerPopup(lat=user_location[0], lon=user_location[1], source="icons/you.png") self.parent.get_screen( "kv_doctormapview").ids.automaticmapview.add_widget(user_marker) delete_list.append(user_marker) # Creates map marker for all doctors in map view screen, appends to the delete list for later for doctor in results: location = usersDB.getAccountData(doctor, 'location') marker = MapMarkerPopup(lat=location[0], lon=location[1], source='icons/marker.png') existinMap = True try: imagemap = open("profiles/" + doctor_email + ".jpg") imagemap.close() except IOError: existinMap = False if existinMap == True: marker.add_widget( Button(background_normal="profiles/" + doctor + ".jpg")) else: marker.add_widget( Button(background_normal="profiles/default.png")) self.parent.get_screen( "kv_doctormapview").ids.automaticmapview.add_widget(marker) delete_list.append(marker) print("DEBUG: Added a doctor to map") print("DEBUG: Successfully loaded doctors to list/map view.")