def create_map(self, *args): _, latitude, longitude, markers = args markers = pickle.loads(markers) map = MapView(zoom=12, lat=latitude, lon=longitude, size_hint=(1, .8)) marker_layer = MarkerMapLayer() map.add_layer(marker_layer) for (lat, lon) in markers: # print(type(lat),type(lon)) map.add_marker(MapMarker(lat=lat, lon=lon, source='images/mmy_marker.png'), layer=marker_layer) return map
def mark_boys(self): # boy = MarkerMapLayer() self.add_layer(boy) longitude = -71.979914 latitude = 41.800495 m1 = MapMarker(lon=longitude, lat=latitude, source=r'blue_pin.png') m1.bind(on_press=pop_that) self.add_marker(m1, layer=boy)
def mark_girls(self): # used to draw in all girl's changing rooms # change icon to pink girl = MarkerMapLayer() self.add_layer(girl) longitude = -72.979914 latitude = 40.800495 m1 = MapMarker(lon=longitude, lat=latitude, source=r'pink_pin.png') m1.bind(on_press=pop_that) self.add_marker(m1, layer=girl)
def build(self): #Accessing settings database cur.execute("SELECT mode from settings where attribute='darkmode' ") GpsHelper().run() #App theme and UI color schemes darkmode_opt_list = cur.fetchall() darkmode_opt = darkmode_opt_list[0][0] self.theme_cls.primary_palette = "Cyan" self.theme_cls.primary_hue = "800" self.theme_cls.accent_palette = "Gray" self.theme_cls.accent_hue = "50" self.search_menu = SearchPopupMenu() self.tap_target_view = MDTapTargetView( widget=self.root.ids.button, title_text="Click here to locate you.", description_text="Make sure we are right over you", widget_position="left_bottom", ) if darkmode_opt == "on": print("dark mode on") self.theme_cls.theme_style = "Dark" self.root.ids.darkmode_switch.active = True else: print("light mode on") self.theme_cls.theme_style = "Light" self.root.ids.darkmode_switch.active = False if logged_in == True: self.root.ids.manager.current = "Home" self.root.ids.ecomap.add_marker(MapMarker(lat=60, lon=30)) myloc = MapMarker(lat=30.3433, lon=77.8839) self.root.ids.ecomap.add_marker(myloc) def repos(button): self.root.ids.ecomap.center_on(31.901303405681098, 76.5568) self.root.ids.ecomap.zoom = 18 self.tap_target_view.bind(on_close=repos) def drop_marker_db(button): pass # temp_marker = MapMarker(lat=val[0], lon=val[1]) # screen.ids.ecomap.add_marker(temp_marker) try: self.start_anim.cancel() except: pass self.start_anim = Clock.schedule_once(self.start_tp_anim, 3.5) elif logged_in == False: self.root.ids.parent_manager.current = "account_setup"
def update(self, dt): m1 = MapMarker(lat=dane(2), lon=dane(3)) # m1.source = marker_source self.mapview.add_marker(m1) if (self.m2): self.mapview.remove_marker(self.m2) self.m2 = m1
def __init__(self, **kwargs): super(ShowMe10Screen, self).__init__(**kwargs) self.latitude = self.my_map.lat self.longitude = self.my_map.lon self.marker = MapMarker(lat=self.latitude, lon=self.longitude) self.my_map.add_marker(self.marker)
def add_coordinates(self): newlat = self.lat newlon = self.lon for i in range(5): newlat = self.lat + (random.uniform(-100, 100) * .0001) newlon = self.lon + (random.uniform(-100, 100) * .0001) self.add_marker(MapMarker(lat=newlat, lon=newlon))
def draw_iss_path(self): # Path is drawn every 5 mins if self.utcnow() - self.last_path_update > 30: try: self.map.remove_layer(self.mmlayer) except: pass self.mmlayer = MarkerMapLayer() # Create markers showing the ISS's position every 5 mins for i in range(20): lat, lon = self.get_loc(datetime.now() + timedelta(0, i * 300)) self.mmlayer.add_widget( MapMarker(lat=lat, lon=lon, source=self.path_icon)) # Update the flag so we know when next update should be run self.last_path_update = self.utcnow() # Add the layer and call the reposition function otherwise the # markers don't show otherwise! self.map.add_layer(self.mmlayer) self.mmlayer.reposition()
def build(self): self.itu_lat = 55.6593807 self.itu_lon = 12.5910774 self.obs_dic = None self.old_time = 0.0 self.Layout = RelativeLayout(size=(900, 450)) self.mapview = MapView(zoom=17, lat=self.itu_lat, lon=self.itu_lon) self.Layout.add_widget(self.mapview) self.overlay = AnchorLayout(anchor_x='right', anchor_y='top') # btn = Button(text="test", size_hint=(.2, .2)) # btn = Button(background_normal='Settings G.png', size=(0.2, 0.2), pos=(100,100)) self.btn = Button(background_normal='Settings B.png', size_hint=(0.06, 0.1)) self.overlay.add_widget(self.btn) self.Layout.add_widget(self.overlay) self.btn.bind(on_press=self.show_dropdown) marker = MapMarker(anchor_x=0.5, anchor_y=0.5, lat=self.itu_lat, lon=self.itu_lon) self.mapview.add_marker(marker) return self.Layout
def pos_changed(self, instance, coord, gps): self.walking_widget.on_walk() self.positions.append((gps.lon, gps.lat)) self.map_view.add_marker( MapMarker(lat=gps.lon, lon=gps.lat, source='images/mmy_marker.png'), layer=self.marker_layer) #오류로 gps.lat과 gps.lon의 값이 바뀌어있음
def draw_marker(self): # tworzenie funkcji rysująćej marker na mapie self.list_of_points = [ ['wstep1.jpg', 0, 0], ['wieza.jpg', 48.85833, 2.29444], ['bigben.jpg', 51.50061, -0.124611], ['bazylika.jpg', 41.902161, 12.453814], ['kreml.jpg', 55.751797, 37.617274], ['wawel.jpg', 50.054287, 19.936383], ['piramidy.jpg', 29.978888, 31.1338888], ['niagara.jpg', 43.1001200, -79.0662700], ['pomnik.jpg', 38.889444, -77.03527777], ['tadz.jpg', 27.171666, 78.04194444], ['dis.jpg', 35.63277777, 139, 88055], ['brawo.gif', 1], ] # lista ze zdjęciami,gifem i współrzędnymi miejsc do pierwszej częsci oraz stronami wprowadzającymi do kolejnych częci try: self.my_map.remove_marker(self.marker) except: pass self.latitude = self.my_map.lat # szerokoć geograficzna z mapy self.longitude = self.my_map.lon # długoć geograficzna z mapy self.marker = MapMarker( lat=self.latitude, lon=self.longitude) # tworzenia markera na mapie self.my_map.add_marker(self.marker) # dodanie markera na mapie self.search_lat.text = "{:.5f}".format( self.latitude) # wyswietla 5miejsc po prezcinku self.search_long.text = "{:.5f}".format( self.longitude) # wyswietlanie współrzędnych self.latt = self.latitude self.lonn = self.longitude
def PlaceMarker(self, *args): x = self.Map.width/2 y = self.Map.height/2 newLoc = self.Map.get_latlon_at(x,y) CurMarker = MapMarker(lat=newLoc[0], lon=newLoc[1]) self.MapMarkers.append(CurMarker) self.Map.add_marker(CurMarker)
def mark_point(self, lat, lon, layer=None, markerSource="dot.png"): if lat != None and lon != None: marker = MapMarker(lat=lat, lon=lon, source=markerSource) #utworzenie markera self.my_map.add_marker(marker, layer=layer) #dodanie markera do mapy
def __init__(self, **kwargs): super(ShowMeScreen, self).__init__(**kwargs) self.latitude = self.my_map.lat self.longitude = self.my_map.lon self.marker = MapMarker(lat=self.latitude, lon=self.longitude) self.my_map.add_marker(self.marker) self.list_of_points = [["photo1.jpg", 52.22977, 21.01178], ["Wenecja.jpg", 45.43713, 12.33265], ["Rio.jpg", -22.90278, -43.20750], ["Krakow.jpg", 50.0614300, 19.9365800], ["Moskwa.jpg", 55.7522200, 37.6155600], ["Londyn.jpg", 51.5085300, -0.1257400], ["NowyJork.jpg", 40.7142700, -74.0059700], ["Paryz.jpg", 48.8534100, 2.3488000], ["Sydney.jpg", -33.8678500, 151.2073200], ["Dubaj.jpg", 25.0657000, 55.1712800]] self.quizLevels = len(self.list_of_points) self.currentLevel = 0 self.totalScore = 0 self.tolerance = 500000 self.current_step.text = "Step {} of {}".format( (self.currentLevel + 1), self.quizLevels)
def ZoomToCurrentLocation(self, *args): newloc = self.MyCurrentLocation self.Map.center_on(newloc[0],newloc[1]) self.ClearAllMapMarkers() self.Map.zoom = 16 CurMarker = MapMarker(lat=newloc[0], lon=newloc[1]) self.MapMarkers.append(CurMarker) self.Map.add_marker(CurMarker)
def build(self): global zoom1 global lon1 global lat1 map = MapView(zoom=zoom1, lat=lat1, lon=lon1, double_tap_zoom=False) marker_1 = MapMarker(lon=17.03, lat=51.1) map.add_marker(marker_1) return map
def on_location(self, **kwargs): if hasattr(self, "mgps"): self.mapview.remove_marker(self.mgps) self.gps = [kwargs['lat'], kwargs['lon']] self.mgps = MapMarker(lat=self.gps[0], lon=self.gps[1], source=self.gps_image) self.mapview.add_marker(self.mgps)
def search_location(self): #funkcja lokalizująca obiekty self.data_layer = MarkerMapLayer() self.my_map.add_layer(self.data_layer) self.lati = self.my_map.lat self.long = self.my_map.lon print(self.lati) print(self.long) list_of_points = [[ 'zegar_praga.jpg', 50 + 5 / 60 + 12 / 3600, 14 + 25 / 60 + 14 / 3600 ], ['sagrada_familia.jpg', 50.06465009, 19.94497990000002], ['sacre_coeur.jpg', 48.8863280, 2.3430490], ['london_eye.jpg', 51.5007316, -0.1186893], ['notre_dame.jpg', 48.8540278, 2.3473245], ['koloseum.jpg', 41.8895897, 12.4940828], ['fontanna.jpg', 41.9008219, 12.4830284], ['eiffel_tower.jpg', 48.8583157, 2.2943230], ['big_ben.jpg', 51.4995730, -0.1245830], ['arc.jpg', 48.8738178, 2.2950626], ['akropol.jpg', 37.9666670, 23.7166670]] try: self.my_map.remove_marker(self.marker) except: pass self.latitude = self.my_map.lat self.longitude = self.my_map.lon self.marker = MapMarker(lat=self.latitude, lon=self.longitude) self.my_map.add_marker(self.marker) #zmiana formatu wywietlania znakow self.search_lat.text = "{:5.5f}".format(self.latitude) self.search_long.text = "{:5.5f}".format(self.longitude) #użycie funkcji obliczającej odległosc for i in range(len(list_of_points)): if self.pic.source == list_of_points[i][0]: s = funkcja.Vincenty(self.lati * pi / 180, self.long * pi / 180, list_of_points[i][1] * pi / 180, list_of_points[i][2] * pi / 180) points = [] if s > 100: self.tekst.text = "Odleglosc pomiedzy {} m".format(round(s, 3)) score = 0 points.append(score) else: self.tekst.text = "zdobywasz punkt!" score = 1 points.append(score) sum_of_points = points.count(1) self.score.text = "Twoje punkty : {}".format(sum_of_points)
def on_location(self, **kwargs): self.current_lat = kwargs['lat'] self.current_lon = kwargs['lon'] self.mapview.center_on(self.current_lat, self.current_lon) marker = MapMarker(lat=self.current_lat, lon=self.current_lon) self.mapview.add_marker(marker) self.label.text = '\n'.join([f'{k} : {v}' for k, v in kwargs.items()]) print(self.current_lat, self.current_lon)
def build(self): self.mapview = MapView(lat=51.48, lon=-3.17, zoom=11) self.mapLayer = MarkerMapLayer() for i in locations: locationLat = float(locations[i][0]) locationLon = float(locations[i][1]) marker = MapMarker(lat=locationLat, lon=locationLon) self.mapLayer.add_widget(marker) self.mapview.add_layer(self.mapLayer) self.add_widget(self.mapview)
def on_checkbox_active(self, value): #print(value) if value == "Dewas": self.latitude = 22.962267 self.longitude = 76.050797 self.ids.mv.center_on(self.latitude, self.longitude) self.ids.mv.zoom = 11 #source = MapSource(url="map11.html",cache_key="my-custom-map", tile_size=512,image_ext="png", attribution="@ Myself") #self.ids.mv.map_source = source for i in range(1): request = requests.get(self.url + '?auth=' + self.auth_key) p = request.json() a = p["Dewas"] #print(a) for i, e in a.items(): la = e["lat"] lo = e["lon"] m = MapMarker(lon=lo, lat=la) self.ids.mv.add_marker(m) for i in range(5): time.sleep(5) la = 22.962267 + i * 0.1 lo = 76.050797 + i * 0.1 m = MapMarker(lon=lo, lat=la, size_hint=(50, 50), anchor_x=0.2, anchor_y=0.2, source=r"images\busicon.png") self.ids.mv.add_marker(m) elif value == "Ujjain": self.latitude = 23.18239 self.longitude = 75.77643 self.ids.mv.center_on(self.latitude, self.longitude) self.ids.mv.zoom = 11 for i in range(1): request = requests.get(self.url + '?auth=' + self.auth_key) p = request.json() a = p["Ujjain"]
def items_bind(self): self.widget_layout.clear_widgets() sql_connection = sqlite3.connect('Records/records.db') cursor = sql_connection.cursor() cursor.execute('select lat,lon,count from popularity') for (lat, lon, count) in cursor.fetchall(): if count < 3: self.map_view.add_marker(MapMarker( lat=lat, lon=lon, source='images/heart_yellow.png'), layer=self.marker_layer) elif 3 <= count < 7: self.map_view.add_marker(MapMarker( lat=lat, lon=lon, source='images/heart_green.png'), layer=self.marker_layer) else: self.map_view.add_marker(MapMarker( lat=lat, lon=lon, source='images/heart_red.png'), layer=self.marker_layer) sql_connection.close() self.widget_layout.add_widget(self.map_view) self.bind(is_screen=self.on_is_screen)
def draw_marker(self): data_lay = MarkerMapLayer() self.my_map.add_layer(data_lay) for i in range(len(self.lati)): marker = MapMarker(lat=self.lati[i], lon=self.loni[i], source="dot.png") self.my_map.add_marker(marker, layer=data_lay) self.my_map.set_zoom_at(10, self.lati[1], self.loni[1], scale=None) self.my_map.center_on(self.lati[1], self.loni[1])
def DBAlert(self, ActiveKods): """Now by using the system we implemented earlier we can call system with the kods and get lat and lon returned, this function will also make a marker, Since our Placefotovogn only runs at initialization, and there is no point in trying to place every marker again, we can just place it here""" self.latAlert, self.lonAlert = self.getLatLon(ActiveKods) self.placedVogne.append([self.latAlert, self.lonAlert]) self.foto = MapMarker(lat=self.latAlert, lon=self.lonAlert, source='images/fotovogn.png') self.MyApp.mapview.add_marker(self.foto) """Now lets alert the user""" self.anmiate_the_button(self.MyApp.buttonAlert)
def draw_markers(self, lats, lons, h_lat, h_lon): ''' Rysuj markery! I najtrudniejsze miejsce''' # Ale najpierw skasujmy stare markery self.remove_markers() self.data_layer = MarkerMapLayer() self.map_.add_layer(self.data_layer) # Nie chcemy za dużo punktów narysować if len(lats) > 50: print('ZA DUŻO PUNKTÓW GPS!!!!') co_ile = int(len(lats) / 50) print('Wybieramy co %d punkt aby wyświetlić 50/51 punktów') lats = lats[::co_ile] lons = lons[::co_ile] for lat, lon in zip(lats, lons): marker = MapMarker(lat=lat, lon=lon) self.map_.add_marker(marker, layer=self.data_layer) n = len(lats) # Ładnie centrujemy mapkę! self.map_.center_on(sum(lats) / n, sum(lons) / n) # Rysuj położenie najtrudniejszego odcinka marker = MapMarker(lat=h_lat, lon=h_lon, source='cluster.png') self.map_.add_marker(marker, layer=self.data_layer)
def draw_marker(self): try: self.my_map.remove_marker(self.marker) except: pass self.latitude = self.my_map.lat self.longitude = self.my_map.lon self.marker = MapMarker(lat=self.latitude, lon=self.longitude) self.my_map.add_marker(self.marker) self.search_lat.text = "{:.5f}".format(self.latitude) self.search_long.text = "{:.5f}".format(self.longitude)
def __init__(self, **kwargs): #super(ISSScreen, self).__init__(**kwargs) super(ISSScreen, self).__init__() self.name = kwargs["name"] # Set the path for the folder self.path = os.path.dirname(os.path.abspath(__file__)) # Set the path for local images self.imagefolder = os.path.join(self.path, "images") # Ephem calculates the position using the Two Line Element data # We need to make sure we have up to date info tle = self.get_TLE() # Create an iss object from which we can get positional data self.iss = ephem.readtle(*tle) # Run the calculations self.iss.compute() # Get positon of iss and place a marker there lat, lon = self.get_loc() self.marker = MapMarker(lat=lat, lon=lon) # Create a value to check when we last drew ISS path self.last_path_update = 0 # Create the path icon self.path_icon = os.path.join(self.imagefolder, "dot.png") # Create the world map #self.map = MapView(id="mpv",lat=0, lon=0, zoom=1, scale=1.5) self.map = MapView(lat=0, lon=0, zoom=1) x, y = self.map.get_window_xy_from(0, 0, 1) self.map.scale_at(1.2, x, y) # Add the ISS marker to the map and draw the map on the screen print("add map") self.map.add_widget(self.marker) print("add widget") self.add_widget(self.map) # Add a new layer for the path self.mmlayer = MarkerMapLayer() self.draw_iss_path() self.timer = None
def update_current_locmarker(self, lat, lng, zoom): """ update_current_locmarker(float, float, bool) updates the current location marker lat - Latitude coordinates lng - Longitude coords zoom - Zoom into marker if True else ignore Zoom """ self.center_on(lat, lng) if zoom: self.zoom = MockMapView.DEFAULT_ZOOM_IN if self._current_loc_marker: self.remove_marker(self._current_loc_marker) self._current_loc_marker = MapMarker(source="current_marker.png", lat=lat, lon=lng) self.add_marker(self._current_loc_marker)
def update_target_marker(self, lat, lng): """ update_target_locmarker(float, float) updates the target location marker lat - Latitude coordinates lng - Longitude coords """ if self._target_marker: self.remove_marker(self._target_marker) self._target_marker = MapMarker(source="target.png", lat=lat, lon=lng) self.add_marker(self._target_marker) # add coords to root windows textfields self.app.root.lat_text = str(lat) self.app.root.lon_text = str(lng) self.is_target_shown = True
def marcar_onibus(self): from geopy.distance import vincenty url = 'http://dadosabertos.rio.rj.gov.br/apiTransporte/apresentacao/rest/index.cfm/obterTodasPosicoes' resposta = requests.get(url) dados = json.loads(resposta.text) for i in range(len(dados['DATA'])): distancia = vincenty( self.meu_local, (dados['DATA'][i][3], dados['DATA'][i][4])).meters if distancia < 2000: self.mapa.add_marker( MapMarker(lat=dados['DATA'][i][3], lon=dados['DATA'][i][4], source='bolinha.png'))