コード例 #1
0
 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
コード例 #2
0
ファイル: main.py プロジェクト: guysoft/recycle_app_israel
class mapviewApp(App):
    
    def storeLocation(self, **kwargs):
        locationData = kwargs
        print("WEEEE")
        print(locationData)
        gps.stop()
        
        self.mapview.center_on(locationData["lat"], locationData["lon"])
        return locationData


    def getLocation(self):
        gps.configure(on_location=self.storeLocation)
        gps.start(minTime=1000, minDistance=1)
    
    
    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
コード例 #3
0
 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
コード例 #4
0
 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
コード例 #5
0
 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
コード例 #6
0
 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
コード例 #7
0
    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)
コード例 #8
0
    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()
コード例 #9
0
ファイル: main.py プロジェクト: Frixiol/KivyBusApp
    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)
コード例 #10
0
ファイル: main.py プロジェクト: ADutta007/KIVY
 def random_points(self):
     global marker_coord
     self.c = MapView.get_bbox(self)
     self.arr = np.array(self.c)
     # print(self.arr)
     self.lat_arr = np.random.uniform(low=self.arr[0],
                                      high=self.arr[2],
                                      size=(5))
     self.lon_arr = np.random.uniform(low=self.arr[1],
                                      high=self.arr[3],
                                      size=(5))
     marker_coord = (np.dstack((self.lat_arr, self.lon_arr))).reshape(-1, 2)
コード例 #11
0
ファイル: main.py プロジェクト: guysoft/recycle_app_israel
    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
コード例 #12
0
 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
コード例 #13
0
def map_tab():
    return MapView(lat=46.7734832, lon=103.2187417, zoom=6)
コード例 #14
0
# 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,
    ))
コード例 #15
0
 def __init__(self, **kwargs):
     super(RootWidget, self).__init__(**kwargs)
     mapview = MapView(zoom=14, lat=self.lat, lon=self.lon)
     self.add_widget(mapview)
コード例 #16
0
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
コード例 #17
0
ファイル: simple_map.py プロジェクト: zworkb/mapview
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))
コード例 #18
0
class AlertDetailScreen(Screen):
    main_screen_manager = ObjectProperty()
    backref = StringProperty()

    def __init__(self, **kwargs):
        super().__init__(**kwargs)

    def goto_backref(self, btn):
        if self.main_screen_manager:
            if self.backref == 'dashboard':
                self.main_screen_manager.show_dashboard(transition='right')
            else:
                self.main_screen_manager.show_alert_list(transition='right')

    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 draw_polygons(self, polygons):
        if not polygons:
            return

        polygons = [("severe", polygon) for polygon in polygons]
        geo_json = self.get_geojson(polygons)
        self.gj_layer = GeoJsonMapLayer(geojson=geo_json)
        if self.gj_layer:
            lon, lat = self.gj_layer.center
            self.lon = lon
            self.lat = lat
            self.mapview.lon = self.lon
            self.mapview.lat = self.lat
            min_lon, max_lon, min_lat, max_lat = self.gj_layer.bounds
            radius = haversine(min_lon, min_lat, max_lon, max_lat)
            zoom = get_zoom_for_radius(radius, lat)
            self.mapview.zoom = zoom
            self.mapview.center_on(lat, lon)
        self.mapview.add_widget(self.gj_layer)
        self.mapbox.add_widget(self.mapview)
        #Clock.schedule_once(self.create_marker, 1)

    def create_marker(self, dt):
        self.marker = MapMarker(lat=self.lat, lon=self.lon)
        self.mapview.add_widget(self.marker)

    def on_leave(self):
        self.clear_widgets()

    def get_geojson(self, polygons):
        features = []

        for sev, p in polygons:
            feat = self.get_feature_dict()
            poly = self.fix_polygon(p)
            feat["geometry"]["coordinates"].append(poly)
            feat["properties"]["color"] = self.get_color_for_severity(sev)
            features.append(feat)

        result = {"type": "FeatureCollection", "features": features}

        return result

    def get_feature_dict(self):
        return {
            "type": "Feature",
            "properties": {
                "color": "blue"
            },
            "geometry": {
                "type": "Polygon",
                "coordinates": []
            }
        }

    def get_color_for_severity(self, severity):
        sev_dict = {
            "extreme": "red",
            "severe": "orange",
            "moderate": "blue",
            "minor": "green",
            "unknown": "grey"
        }
        return sev_dict.get(severity.lower(), 'grey')

    def fix_polygon(self, polygon):
        p = list(polygon)
        for i in range(len(p)):
            p[i] = p[i][::-1]

        return p

    def get_category_display_text(self, category):
        db_val_to_category_val = {
            "geo": "Earthquakes",
            "met": "Weather",
            "safety": "Public Safety",
            "rescue": "Rescue",
            "fire": "Fire",
            "health": "Health",
            "env": "Environment",
            "transport": "Transportation",
            "infra": "Infrastructure",
            "cbrne": "CBRNE",
            "other": "Other"
        }
        return db_val_to_category_val.get(category, category.title())
コード例 #19
0
ファイル: New.py プロジェクト: Oladunsi/farmers_market_app
 def build(self):
     mapview = MapView(zoom=11, lat=50.6394, lon=3.057)
     return mapview
コード例 #20
0
 def build(self):
     mapview = MapView(zoom=10, lat=12.97, lon=77.59)
     return mapview
コード例 #21
0
ファイル: main.py プロジェクト: Frixiol/KivyBusApp
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)))
コード例 #22
0
 def build(self):
     mapview = MapView(zoom=10, lat=36, lon=-115)
     return mapview
コード例 #23
0
    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)
コード例 #24
0
class Forecast(Screen):
    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 marker_popup(self, *args):
        box = BoxLayout(orientation="vertical")
        text = "Vous êtes au: \n" + self.address
        label = Label(text=text, text_size=(Window.width * 0.9, None))
        ok_button = Button(text="OK", size_hint=(1, 0.2))
        ok_button.bind(on_press=self.marker_popup_dismiss)
        box.add_widget(label)
        box.add_widget(ok_button)
        self.mark_popup = Popup(title="Informations:", content=box)
        self.mark_popup.open()

    def marker_popup_dismiss(self, *args):
        self.mark_popup.dismiss()

    def get_dairy(self, *arg):
        my_app.sm.current = "Agenda"

    def update_clock(self, *args):
        self.time_label.text = main_time().strftime("%H:%M:%S")

        self.pos_label.text = f"{self.address} + {self.test} \n {self.lat}, {self.lon}"  #Une phrase super gavée longue pour tester ce que je veux faire
        self.current_loc.lat = float(self.lat)
        self.current_loc.lon = float(self.lon)

        if self.image_bool and self.lat != 0 and self.lon != 0:
            if get_current_weather(self.lat, self.lon) < 0.1:
                self.img.source = "./sun.png"
            else:
                self.img.source = "./umbrella.png"
            self.image_bool = False

    def update_image(self, *args):
        if get_current_weather(self.lat, self.lon) < 0.1:
            self.img.source = "./sun.png"
        else:
            self.img.source = "./umbrella.png"
コード例 #25
0
    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
コード例 #26
0
 def test_init_simple_map(self):
     """Makes sure we can initialize a simple MapView object."""
     kwargs = {}
     mapview = MapView(**kwargs)
     assert len(mapview.children) == 2