def test_init_geojson(self): """Providing the geojson directly, polygons should get added.""" options = {} mapview = MapView(**options) geojson = {} kwargs = {"geojson": geojson} maplayer = GeoJsonMapLayer(**kwargs) mapview.add_layer(maplayer) Clock.tick() assert maplayer.source == "" assert maplayer.geojson == geojson assert len(maplayer.canvas_line.children) == 0 assert len(maplayer.canvas_polygon.children) == 3 assert len(maplayer.g_canvas_polygon.children) == 0 geojson = load_json("maps-devrel-google.json") kwargs = {"geojson": geojson} maplayer = GeoJsonMapLayer(**kwargs) mapview = MapView(**options) mapview.add_layer(maplayer) Clock.tick() assert maplayer.source == "" assert maplayer.geojson == geojson assert len(maplayer.canvas_line.children) == 0 assert len(maplayer.canvas_polygon.children) == 3 assert len(maplayer.g_canvas_polygon.children) == 132
def build(self): global epiloges_arr global App_Usr App_Usr = User(0, "d4gl4s") # #gia gps #gps.configure(on_location = self.on_gps_location) #gps.start() #end gia gps # self._main_layout = GridLayout(cols=2) self._main_layout.add_widget( MapView(zoom=15, lat=38.246700, lon=21.734823, size_hint=(1, .8)) ) #dhmiourgia xarth, ayto prepei na allaksei ws pros tis suntetagmenes kai to zoom!! #gia epiloges self._epiloges = BoxLayout(orientation='vertical', size_hint_x=.3) for i in range(0, 7): btn = Epiloges_Button(text=epiloges_arr[i]) if i == 0: btn.bind(on_press=self.map_callback) #map callback if i == 1: btn.bind(on_press=self.profile_callback) #profile button if i == 2: btn.bind( on_press=self.locations_callback) #gia known locations if i == 3: btn.bind(on_press=self.friends_callback) #gia friends if i == 4: btn.bind(on_press=self.events_callback) #gia known events if i == 5: btn.bind( on_press=self.friend_request_callback) #gia friend request self._epiloges.add_widget(btn) self._main_layout.add_widget(self._epiloges) return self._main_layout
def __init__(self, **kwargs): super(MapScreen, self).__init__(**kwargs) # Initialisation self.box_layout = BoxLayout() self.map_view = MapView(lat=10, lon=10, zoom=5) # Adds the map self.box_layout.add_widget(self.map_view)
def load_map(self, lokation): self.coords = findkoordinater( lokation, 0) #Sætter coords til at være findkordinater self.newMap = MapView( zoom=10, lat=self.coords[0], lon=self.coords[1]) #Laver mapview med data fra coords self.ids.map_view.add_widget( self.newMap) #tilføjer MapView som widget til boxlayout i MyApp.kv
def map_callback(self, instance, *pos): #allazw to _main_layout self._main_layout.clear_widgets() self._main_layout.add_widget( MapView(zoom=11, lat=50.6394, lon=3.057, size_hint=(1, .8)) ) #dhmiourgia xarth, ayto prepei na allaksei ws pros tis suntetagmenes kai to zoom!! self._main_layout.add_widget(self._epiloges) return self._main_layout
def build(self): self.title = "Eaglesoft Map" print(MapSource.providers.keys()) box_layout = BoxLayout() map_view = MapView(lat=30.005630, lon=73.257950, zoom=8) map_view.map_source = "osm" map_marker = MapMarker() map_marker.lat = 30.005630 map_marker.lon = 73.257950 map_marker.source = "map-marker.png" map_view.add_widget(map_marker) box_layout.add_widget(map_view) return box_layout
def on_enter(self): self.mapbox = self.ids.map_box self.mapview = MapView() self.mapview.zoom = 5 self.mapview.center_on(40.5960129, -99.5961643) import random import glob counties = glob.glob('*.polygon') county = random.choice(counties) with open(county, 'r') as f: polygons = eval(f.read()) #self.draw_polygons(polygons) polygon_draw_thread = threading.Thread(target=self.draw_polygons, args=(polygons, )) polygon_draw_thread.start()
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 build(self): parent = FloatLayout() #initializing map mapview = MapView(zoom=14, lat=33.6405, lon=-117.8443) parent.add_widget(mapview) #initialize starting address text box starting_address = TextInput(pos=(0, 60), size_hint=(.4, None), height=60, multiline=False, text="Starting Address") starting_address.bind(on_text_validate=self.on_enter) parent.add_widget(starting_address) #initialize destination address text box dest_address = TextInput(pos=(0, 0), size_hint=(.4, None), height=60, multiline=False, text="Destination Address") dest_address.bind(on_text_validate=self.on_enter) parent.add_widget(dest_address) return parent
def build(self): layer = ClusteredMarkerLayer() a = MapMarker() # self.mapview.add_marker(, cls=MapMarker) layer.add_marker(lon=32.092, lat=34.807, cls=MapMarker) self.mapview = MapView(zoom=15, lat=32.092, lon=34.807) self.mapview.map_source.min_zoom = 14 # self.mapview.add_widget(layer) data = get_geo_data() places = data["places"] for place in places: if place["categories"][0]["id"] == "45": pin_color = "data/pin-red.png" else: pin_color = "data/pin-blue.png" marker = MapMarker(lat=float(place["location"]["lat"]), lon=float(place["location"]["lng"]),source=pin_color) # layer.add_marker(marker) self.mapview.add_marker(marker) if platform == "android": print("gps.py: Android detected. Requesting permissions") request_android_permissions() try: print(self.getLocation()) except NotImplementedError: print("location not NotImplemented") return self.mapview
def __init__(self, **kwargs): super(RootWidget, self).__init__(**kwargs) mapview = MapView(zoom=14, lat=self.lat, lon=self.lon) self.add_widget(mapview)
# coding=utf-8 """ This example demonstrate how to use the MBTilesMapSource provider. It supports v1.1 version of .mbtiles of Mapbox. See more at http://mbtiles.org/ It currently require a Kivy version that can load data from a buffer. This is not the case on every platform at 1.8.1, but we're going to fix it. """ import sys from kivy.base import runTouchApp from kivy_garden.mapview import MapView from kivy_garden.mapview.mbtsource import MBTilesMapSource source = MBTilesMapSource(sys.argv[1]) runTouchApp( MapView( map_source=source, lat=source.default_lat, lon=source.default_lon, zoom=source.default_zoom, ))
import sys from kivy.base import runTouchApp from kivy_garden.mapview import MapSource, MapView kwargs = {} if len(sys.argv) > 1: kwargs["map_source"] = MapSource(url=sys.argv[1], attribution="") runTouchApp(MapView(**kwargs))
class Resultat(Screen): coords = ListProperty( (0, 0)) #Laver en ListProperty for klasse variabel coords mark_coords = None #Sætter klassevariabel mark_coords til at være None. markerList = [] #laver en liste for klassevariabel markerList ADA = False #Sætter klassevariabel ADA til False UNISEX = False #Sætter klassevariabel UNISEX til False newMap = MapView() #Lavet et en tom MapView til klassevariabel newMap def load_map(self, lokation): self.coords = findkoordinater( lokation, 0) #Sætter coords til at være findkordinater self.newMap = MapView( zoom=10, lat=self.coords[0], lon=self.coords[1]) #Laver mapview med data fra coords self.ids.map_view.add_widget( self.newMap) #tilføjer MapView som widget til boxlayout i MyApp.kv def criteria(self, ada, unisex): if ada == "down": #Hvis id'en ADA's state er down self.ADA = True #Sæt ada til at være true else: self.ADA = False #ellers skal det være false if unisex == "down": #Hvis id'en Unisex's state er down self.UNISEX = True #Sæt unisex til at være True else: self.UNISEX = False #ellers skal det være false def load_markers(self, antal, lokation): link = link_constructer( antal, self.ADA, self.UNISEX, lokation) #Bruger link_constructor fra data_toiley.py data = data_constructer( link) #Bruger data_constructer fra data_toilet.py for address in range( len(data[0]) ): #Laver en løkke som går fra n til længden af data[0] for at finde hvor mange markers der skal laves self.mark_coords = findkoordinater( data[0][address], 0 ) #Sætter mark_coords til at være findkordinater af [0][n] for at få koordinater if self.mark_coords != None: #Er self.mark_coords None? newMarker = MapMarker( lat=self.mark_coords[0], lon=self.mark_coords[1], source="marker1.png" ) #laver en MapMarker med data fra self.mark_coords og bliver gemt i newMarker self.newMap.add_widget( newMarker) #tilføjer newMarker som widget til newMap self.markerList.append( newMarker ) #tilføjer newMarker til klasse variablen markerList #print("dette er",self.mark_coords) def remove_markers(self): self.ids.map_view.remove_widget( self.newMap) #fjerner newMap fra map_view i MyApp.kv for marker in self.markerList: #Går igennem hver marker i markerList self.newMap.remove_widget( marker) #fjerner widget marker fra newMap
def build(self): mapview = MapView(zoom=11, lat=50.6394, lon=3.057) return mapview
def build(self): mapview = MapView(zoom=10, lat=12.97, lon=77.59) return mapview
def map_tab(): return MapView(lat=46.7734832, lon=103.2187417, zoom=6)
def __init__(self, **kwargs): super().__init__(**kwargs) self.current_time = datetime.now() #test variable self.test = "" self.type = "" self.status = "" #image self.image_bool = True #gps config and start, get lat and lon values self.address = "" self.lat = 0 self.lon = 0 main_layout = BoxLayout(orientation="vertical") actual_forecast = GridLayout(cols=2, size_hint=(1, 0.3)) #size_hint= (1, 1)) Clock.schedule_interval(self.update_image, 300) self.img = Image(source="./umbrella.png", size_hint=(0.4, 1), pos_hint={ "center_x": 0.5, "center_y": 0.5 }) info = BoxLayout(orientation="vertical") Clock.schedule_interval(self.update_clock, 1) self.time_label = Label(text=self.current_time.strftime("%H:%M:%S")) info.add_widget(self.time_label) self.pos_label = Label(text=f"{self.address} + {self.test}", text_size=(info.width * 3, None)) info.add_widget(self.pos_label) actual_forecast.add_widget(self.img) actual_forecast.add_widget(info) main_layout.add_widget(actual_forecast) # if platform == "android": # Clock.schedule_interval(self.gps_run, 10) self.next_forecast = BoxLayout(orientation="vertical") next = Label(text="Prévisions à venir", size_hint=(1, 0.2), text_size=(Window.width * 0.9, None)) self.next_forecast.add_widget(next) self.map = MapView(zoom=11, lat=float(self.lat), lon=float(self.lon)) self.current_loc = MapMarker(lat=float(self.lat), lon=float(self.lon), source="./marker.png") self.current_loc.bind(on_press=self.marker_popup) self.map.add_marker(self.current_loc) self.next_forecast.add_widget(self.map) main_layout.add_widget(self.next_forecast) button = Button(text="Agenda", size_hint=(1, 0.2)) button.bind(on_press=self.get_dairy) main_layout.add_widget(button) self.add_widget(main_layout)
def test_init_simple_map(self): """Makes sure we can initialize a simple MapView object.""" kwargs = {} mapview = MapView(**kwargs) assert len(mapview.children) == 2
source = "https://storage.googleapis.com/maps-devrel/google.json" options = {} layer = GeoJsonMapLayer(source=source) if layer.geojson: # try to auto center the map on the source lon, lat = layer.center options["lon"] = lon options["lat"] = lat min_lon, max_lon, min_lat, max_lat = layer.bounds radius = haversine(min_lon, min_lat, max_lon, max_lat) zoom = get_zoom_for_radius(radius, lat) options["zoom"] = zoom view = MapView(**options) view.add_layer(layer) if layer.geojson: # create marker if they exists count = 0 def create_marker(feature): global count geometry = feature["geometry"] if geometry["type"] != "Point": return lon, lat = geometry["coordinates"] marker = MapMarker(lon=lon, lat=lat) view.add_marker(marker) count += 1
def build(self): mapview = MapView(zoom=10, lat=36, lon=-115) return mapview