예제 #1
0
    def visualizarVehiculos(
        self
    ):  #Muestro los marcadores con las ubicaciones actualizadas en el mapa
        ip_request = requests.get('https://get.geojs.io/v1/ip.json')
        my_ip = ip_request.json()['ip']  #con mi ip obtengo mi geolocalizacion
        geo_request = requests.get('https://get.geojs.io/v1/ip/geo/' + my_ip +
                                   '.json')
        geo_data = geo_request.json()

        self.longitudActual = float(geo_data['longitude'])
        self.latitudActual = float(geo_data['latitude'])

        self.ids.mapview.center_on(
            self.latitudActual,
            self.longitudActual)  #mapa centrado en ubicacion actual
        self.ids.mapview.zoom = 5

        mapmarkerpopupUbicacionActual = MapMarkerPopup(lat=self.latitudActual,
                                                       lon=self.longitudActual,
                                                       popup_size=(120, 70))
        bubbleUbicacionActual = Bubble()
        labelUbicacionActual = Label(text="[b]Ubicaion actual![/b]",
                                     markup=True,
                                     halign="center")
        bubbleUbicacionActual.add_widget(labelUbicacionActual)
        mapmarkerpopupUbicacionActual.add_widget(
            bubbleUbicacionActual
        )  #creo un marcador con etique para saber la ubicacion actual, es de color rojo

        #self.ids.mapview.center_on(4.795100942698568, -75.6890602859938) #Me centra en la utp.
        if len(self.listaMarker) > 0:
            for marker in range(len(self.listaMarker)):
                self.ids.mapview.remove_widget(self.listaMarker[marker])
            self.listaMarker = [
            ]  #La reseteo para poder meter los mapMarker de los vehiculos actualizados.

        #Se hace la consulta a la BD para obtener las lat y lon de los vehiculos-----------------------BD
        self.listaMarker.append(mapmarkerpopupUbicacionActual)

        #hacer consulta base de datos
        pos = UbicacionVehiculo.obtenerData(UbicacionVehiculo)

        for e in pos:
            mapmarkerpopup = MapMarkerPopup(
                lat=float(e[1]),
                lon=float(e[2]),
                color=(0, 1, 1, 1),
                popup_size=(120, 70))  #acepta 1,0,1,1 o 0,0,0,1 o 0,1,1,1
            bubble = Bubble()
            label = Label(text="[b]" +
                          Vehiculo.getNamevehiculo(Vehiculo, e[0]) + "[/b]",
                          markup=True,
                          halign="center")
            bubble.add_widget(label)
            mapmarkerpopup.add_widget(bubble)
            self.listaMarker.append(mapmarkerpopup)

        for i in range(len(pos)):
            self.ids.mapview.add_widget(self.listaMarker[i])
예제 #2
0
    def build(self):

        layout = BoxLayout(orientation='vertical')
        self.mapview = MapView(zoom=7, lat=42.6394, lon=25.057)

        bubble = Bubble(orientation="horizontal", padding=5)
        text = "[b]Sample text here[/b]"
        label = Label(text=text, markup=True, halign="center")
        bubble.add_widget(label)
        marker = MapMarkerPopup(id="first",
                                lat=42.6394,
                                lon=25.057,
                                popup_size=('150dp', '100dp'))
        marker.add_widget(bubble)
        self.mapview.add_marker(marker)

        b = BoxLayout(orientation='horizontal',
                      height='52dp',
                      size_hint_y=None)
        b.add_widget(
            Button(text="Zoom in",
                   on_press=lambda a: setattr(self.mapview, 'zoom', self.
                                              mapview.zoom + 1)))
        b.add_widget(
            Button(text="Zoom out",
                   on_press=lambda a: setattr(self.mapview, 'zoom', self.
                                              mapview.zoom - 1)))

        layout.add_widget(b)
        layout.add_widget(self.mapview)
        return layout
예제 #3
0
 def build(self):
     #mapview = MapView(zoom=16, lat=35.689767500000, lon=139.767127800000)
     #lat: 35.681382 lon: 139.766084
     mapview = MapView(zoom=15, lat=35.681382, lon=139.766084)
     marker1 = MapMarkerPopup(lat=35.681382, lon=139.766084)
     mapview.add_marker(marker1)
     return mapview
예제 #4
0
 def add_rent(self, neigh, Min_price=0, Max_price=100000000):
     print(Min_price, Max_price)
     rent_list = gd.get_rent_codata(neigh)
     # print(rent_list)
     if rent_list == ['no data']:
         print('no rent data')
     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['size'] + '\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
예제 #5
0
    def lst_pts(self):
        import pandas as pd
        df = pd.read_csv('Tabela Psicologos - Página1.csv')
        self.lista = []
        for i in range(0, len(df)):
            lt = df.latitude[i]
            ln = df.longitude[i]
            self.lista.append((lt, ln))

            marker = MapMarkerPopup(lat=10, lon=15)
            self.add_widget(marker)
예제 #6
0
def mark(position, mapview, marker, result=[]):
    LAT, LON = position
    if not result:
        # m = marker(lat = LAT, lon = LON, source = "Map-Marker-PNG-Pic_3_1.png")
        bubble = Bubble(orientation="horizontal", padding=5)
        text = "[b]Self[/b]"
        label = Label(text=text, markup=True, halign="center")
        bubble.add_widget(label)
        m = MapMarkerPopup(lat=LAT,
                           lon=LON,
                           popup_size=(100, 50),
                           source="Map-Marker-PNG-Pic_3_1.png")
        m.add_widget(bubble)
    else:
        place_detail = get_place_details(result["place_id"])
        photo = get_photo_html(result)
        phone = get_phone_number(place_detail)
        name = result["name"]
        rating = get_rating(result)

        # m = marker(lat = LAT, lon = LON) marker has been replaced by mapmarkerpopup
        bubble = Bubble(orientation="vertical", padding=5)
        if photo:
            image = AsyncImage(source=photo, mipmap=True)
            bubble.add_widget(image)
        if len(name) > 30:
            index1 = name.find(",")
            index2 = name.find(" ", int(len(name) / 2))
            if index1 > 15:
                name = name[:index1] + "\n" + name[index1:]
            elif index2 > 20:
                name = name[:index2] + "\n" + name[index2:]

        text = "[b]" + name + "[/b]\n" + "Phone Number: " + phone + "\n" + "Rating: " + rating
        label = Label(text=text, markup=True, halign="center")
        bubble.add_widget(label)
        m = MapMarkerPopup(lat=LAT, lon=LON, popup_size=(250, 230))
        m.add_widget(bubble)
    marker_list.append(m)
    mapview.add_marker(m)
예제 #7
0
파일: HomePage.py 프로젝트: prathamzx/SIH19
 def startmap(self, res, result):
     print(result['location'])
     mapview = ""
     for i in range(len(result['location'])):
         print(result['location'][i]['latitude'])
         if result['location'][i]['longitude'] and result['location'][i][
                 'latitude']:
             if mapview == "":
                 mapview = MapView(zoom=11,
                                   lat=result['location'][i]['latitude'],
                                   lon=result['location'][i]['longitude'])
             mapview.add_marker(
                 MapMarkerPopup(lat=result['location'][i]['latitude'],
                                lon=result['location'][i]['longitude']))
     popup = Popup(content=mapview)
     popup.open()
예제 #8
0
 def add_shop(self, neigh, clist):
     shop_list = gd.get_shop_codata(neigh, clist)
     # print(shop_list)
     if shop_list == ['no data']:
         print('no shop data')
     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_widget(marker)
예제 #9
0
 def add_temp(self, neigh, boolt):
     temp_list = gd.get_temp_codata(neigh)
     # print(temp_list)
     if boolt == True:
         if temp_list == ['no data']:
             print('no temple data')
         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)
     else:
         print("do not show temple")
    def lugaresParaUbicacionActual(
            self):  #Los lugares cercanos a mi ubicacion actual me los muestra.
        for marker in range(len(self.listaMarker)):
            self.ids.mapview.remove_widget(self.listaMarker[marker])
        self.listaMarker = []
        CLIENT_ID = ''  # your Foursquare ID
        CLIENT_SECRET = ''  # your Foursquare Secret
        VERSION = '20190717'
        LIMIT = 50
        neighborhood_latitude = self.latitudActual
        neighborhood_longitude = self.longitudActual
        radius = 500
        url = 'https://api.foursquare.com/v2/venues/explore?&client_id={}&client_secret={}&v={}&ll={},{}&radius={}&limit={}'.format(
            CLIENT_ID, CLIENT_SECRET, VERSION, neighborhood_latitude,
            neighborhood_longitude, radius, LIMIT)
        results = requests.get(url).json()
        lugares = results['response']['groups'][0]['items']
        lugaresCercanos = json_normalize(lugares)

        filtered_columns = [
            'venue.name', 'venue.categories', 'venue.location.lat',
            'venue.location.lng'
        ]
        lugaresCercanos = lugaresCercanos.loc[:, filtered_columns]
        # filter the category for each row
        lugaresCercanos['venue.categories'] = lugaresCercanos.apply(
            lambda categorias: categorias, axis=1)
        # clean columns
        lugaresCercanos.columns = [
            col.split(".")[-1] for col in lugaresCercanos.columns
        ]

        self.ids.mapview.center_on(
            self.latitudActual,
            self.longitudActual)  #mapa centrado en ubicacion actual
        self.ids.mapview.zoom = 17

        mapmarkerpopupUbicacionActual = MapMarkerPopup(lat=self.latitudActual,
                                                       lon=self.longitudActual,
                                                       popup_size=(120, 70))
        bubbleUbicacionActual = Bubble()
        labelUbicacionActual = Label(text="[b]Ubicaion actual![/b]",
                                     markup=True,
                                     halign="center")
        bubbleUbicacionActual.add_widget(labelUbicacionActual)
        mapmarkerpopupUbicacionActual.add_widget(bubbleUbicacionActual)
        self.listaMarker.append(mapmarkerpopupUbicacionActual)
        #El for es para obtener la ubicacion de los lugares cercanos que necesito, y poner los marcadores
        for lat, lng, categoria in zip(lugaresCercanos.lat,
                                       lugaresCercanos.lng,
                                       lugaresCercanos.categories):
            mapmarkerpopup = MapMarkerPopup(lat=lat,
                                            lon=lng,
                                            color=(1, 0, 1, 1),
                                            popup_size=(300, 70))
            bubble = Bubble()
            label = Label(text=categoria, halign="center")
            bubble.add_widget(label)
            mapmarkerpopup.add_widget(bubble)
            self.listaMarker.append(mapmarkerpopup)

        for i in range(len(self.listaMarker)):
            self.ids.mapview.add_widget(self.listaMarker[i])
    def PonMarcador(self, diccomercio, tipocomercio):
        """Funcion que agrega marcadores al mapa dependiendo del botón que se haya pulsado, recibe un diccionario del
        comercio que se agregarán marcadores y una cadena sobre el tipo de negocio, se realiza un ciclo for doble para
        obtener los elementos del diccionario, posteriormente se realiza una comparación con los valores y se agrega el
        marcador al mapa"""

        print(tipocomercio)
        for keys, values in diccomercio.items():
            for vkeys, vvalues in values.items():
                if vkeys == 'direccion':
                    dir = vvalues

                if vkeys == 'colonia':
                    col = vvalues

                if vkeys == 'tel':
                    tel = vvalues

                if vkeys == 'cp':
                    cp = vvalues

                if vkeys == 'municipio':
                    mun = vvalues

                if vkeys == 'lat':
                    nlat = vvalues
                    # print("lat: "+str(nlat))

                if vkeys == 'lon':
                    nlon = vvalues
                    # print("lon: "+str(nlon))

            print("lat: " + str(nlat) + " lon: " + str(nlon))

            cadena_final = f'Dir: {dir}\nCol: {col}\nCP: {cp}\nMun: {mun}\nTel: {tel}\n\n'

            if tipocomercio == 'hbe':
                self.marcador = MapMarkerPopup(lat=nlat, lon=nlon, source= "imagenes/pingris.png")
                self.marcador.add_widget(MDLabel(size_hint=(5, .5), text=cadena_final))
                self.mapview.add_marker(self.marcador)

                self.marcadoreshbe.append(self.marcador)

            if tipocomercio == 'che':
                self.marcador = MapMarkerPopup(lat=nlat, lon=nlon, source="imagenes/pinrojo.png")
                self.marcador.add_widget(MDLabel(size_hint=(5, .5), text=cadena_final))

                self.mapview.add_marker(self.marcador)
                self.marcadoresches.append(self.marcador)

            if tipocomercio == 'comer':
                self.marcador = MapMarkerPopup(lat=nlat, lon=nlon, source="imagenes/pinverde.png")
                self.marcador.add_widget(MDLabel(size_hint=(5, .5), text=cadena_final))
                self.mapview.add_marker(self.marcador)
                self.marcadorescomer.append(self.marcador)

            if tipocomercio == 'sor':
                self.marcador = MapMarkerPopup(lat=nlat, lon=nlon, source="imagenes/pinazul.png")
                self.marcador.add_widget(MDLabel(size_hint=(5, .5), text=cadena_final))

                self.mapview.add_marker(self.marcador)
                self.marcadoressor.append(self.marcador)

            if tipocomercio == 'busqueda':
                cadena_analizar = f'{dir} {col} {cp} {mun} {tel}'
                if self.a == 0:
                    colorpin = "imagenes/pinrojo.png"
                if self.a == 1:
                    colorpin = "imagenes/pinazul.png"
                if self.a == 2:
                    colorpin = "imagenes/pinverde.png"
                if self.a == 3:
                    colorpin = "imagenes/pingris.png"

                if ((cadena_analizar.lower()).find(self.entrada) != -1):
                    print("Contains given substring ")

                    self.marcador = MapMarkerPopup(lat=nlat, lon=nlon, source=colorpin)
                    self.marcador.add_widget(MDLabel(size_hint=(5, .5), text=cadena_final))

                    self.mapview.add_marker(self.marcador)
                    self.marcadoresbusqueda.append(self.marcador)
                else:
                    print("Doesn't contains given substring")