def open_webb_and_save(mapka, fileHtml): folium.raster_layers.TileLayer('Open Street Map').add_to(mapka) folium.raster_layers.TileLayer('StamenTerrain').add_to(mapka) folium.raster_layers.TileLayer('CartoDB Positron').add_to(mapka) folium.raster_layers.TileLayer('StamenToner').add_to(mapka) folium.raster_layers.TileLayer('CartoDB Dark_Matter').add_to(mapka) folium.raster_layers.TileLayer('Stamen Watercolor').add_to(mapka) folium.LayerControl().add_to(mapka) minimap = plugins.MiniMap(toggle_display=True) mapka.add_child(minimap) plugins.Fullscreen(position='topright').add_to(mapka) measureControl = plugins.MeasureControl(position='topleft', active_color='red', completed_color='red', primary_length_unit='km') mapka.add_child(measureControl) draw = plugins.Draw(position='topleft', export='True') draw.add_to(mapka) html_page = f'{fileHtml}' mapka.save(fileHtml) mapka.save(html_page) new = 2 webbrowser.open(html_page, new=new) tkinter.messagebox.showinfo("Analiza gpx", "Zakończono analizę pliku i dołączono mapę")
def _add_map_controls(map_instance, minimap=True, mouse_position=True, measure_controll=True, draw=True): """Add aditional map controlls and features to the map\n map_instance: The map instance that was used to initialize the add_map() function\n minimap: Add minimap in the bottom left\n mouse_position: Coordinate information on hover\n measure_controll: adds a feature that allows the user to measure distance on the map\n draw: Adds the ability to draw different geometries on a map and save it as geojson \nexample:\n m = add_map(data= gdf)\n add_layer(data= gdf, color_column= 'color_values').add_to(m)\n add_map_controls(m) m.save('my_map.html') #Used when needing to plot large amounts of data which notebook can't handle """ map_instance = map_instance folium.TileLayer('OpenStreetMap').add_to(map_instance) folium.TileLayer('CartoDB dark_matter').add_to(map_instance) folium.TileLayer('CartoDB positron').add_to(map_instance) folium.LayerControl().add_to(map_instance) plugins.Fullscreen(position='topleft', title='Expand me', title_cancel='Exit me', force_separate_button=False).add_to(map_instance) if minimap: plugins.MiniMap(tile_layer='OpenStreetMap', position='bottomleft', toggle_display=True, minimized=False).add_to(map_instance) else: pass if mouse_position: fmtr = "function(num) {return L.Util.formatNum(num, 3) + ' º ';};" plugins.MousePosition(position='bottomleft', separator=' | ', prefix="Mouse:", lat_formatter=fmtr, lng_formatter=fmtr).add_to(map_instance) else: pass if measure_controll: plugins.MeasureControl(secondary_length_unit='kilometers', secondary_area_unit='sqkilometers', position='bottomright').add_to(map_instance) else: pass if draw: plugins.Draw(export=True).add_to(map_instance) else: pass return (map_instance)
def setup_map(center, zoom_start=14, filename="draw.geojson"): """Create a basic folium map object""" map_ = folium.Map( location=center, zoom_start=zoom_start, tiles="cartodbdark_matter", ) plugins.Fullscreen(position="topleft").add_to(map_) plugins.Draw(filename=filename, export=True, position="topleft").add_to(map_) return map_
def make_map_and_marker(self): self.fileGPX = self.pathLbl["text"] self.fileHTML = self.htmlEnt.get() story = self self.storyTxt.delete(0.0, END) self.storyTxt.insert(0.0, story) pointsXY = self.points_xy() lat = float(sum(p[0] for p in pointsXY) / len(pointsXY)) lon = float(sum(p[1] for p in pointsXY) / len(pointsXY)) mapka = folium.Map(location=[lat, lon], zoom_start=13, control_scale=True) folium.PolyLine(pointsXY, color="blue", weight=3.5, opacity=1).add_to(mapka) folium.CircleMarker(location=[lat, lon], color='none', radius=25, fill_color='blue', popup=self, tooltip=self.fileGPX).add_to(mapka) folium.raster_layers.TileLayer('Open Street Map').add_to(mapka) folium.raster_layers.TileLayer('StamenTerrain').add_to(mapka) folium.raster_layers.TileLayer('CartoDB Positron').add_to(mapka) folium.raster_layers.TileLayer('StamenToner').add_to(mapka) folium.raster_layers.TileLayer('CartoDB Dark_Matter').add_to(mapka) folium.raster_layers.TileLayer('Stamen Watercolor').add_to(mapka) folium.LayerControl().add_to(mapka) minimap = plugins.MiniMap(toggle_display=True) mapka.add_child(minimap) plugins.Fullscreen(position='topright').add_to(mapka) measureControl = plugins.MeasureControl(position='topleft', active_color='red', completed_color='red', primary_length_unit='km') mapka.add_child(measureControl) draw = plugins.Draw(position='topleft', export='True') draw.add_to(mapka) mapka.save(self.fileHTML) html_page = f'{self.fileHTML}' mapka.save(html_page) new = 2 webbrowser.open(html_page, new=new) tkinter.messagebox.showinfo( "Analiza gpx", "Zakończono analizę pliku i dołączono mapę")
m.add_child(minimap) plugins.ScrollZoomToggler().add_to(m) plugins.Fullscreen(position='topright').add_to(m) #### GET LAT AND LONG TOOLS m.add_child(folium.LatLngPopup()) #### MEASURING TOOLS measure_control = plugins.MeasureControl(position='topleft', active_color='red', completed_color='blue', primary_length_unit='metres') m.add_child(measure_control) #### DRAWING TOOLS draw = plugins.Draw(export=True).add_to(m) ###### TOTAL NUMBERS LAYER fg = folium.FeatureGroup(name="Ukupne brojke").add_to(m) b = 0 for k in koordinate_lista: loc = [k[1], k[0]] try: pop = "<strong>NEW: </strong>" + str( uk_potvrdenih[b]) + '\n' + "<strong>DEATHS: </strong>" + str( uk_umrlih[b]) + '\n' + "<strong>RECOVERED: </strong>" + str( uk_oporavljenih[b]) except: pop = "<strong>NEW: </strong>" + str( uk_potvrdenih[b]) + '\n' + "<strong>DEATHS: </strong>" + str(
def __init__(self, **kwargs): import logging logging.getLogger("googleapiclient.discovery_cache").setLevel(logging.ERROR) if "ee_initialize" not in kwargs.keys(): kwargs["ee_initialize"] = True if kwargs["ee_initialize"]: ee_initialize() # Default map center location and zoom level latlon = [40, -100] zoom = 4 # Interchangeable parameters between ipyleaflet and folium if "center" in kwargs.keys(): kwargs["location"] = kwargs["center"] kwargs.pop("center") if "location" in kwargs.keys(): latlon = kwargs["location"] else: kwargs["location"] = latlon if "zoom" in kwargs.keys(): kwargs["zoom_start"] = kwargs["zoom"] kwargs.pop("zoom") if "zoom_start" in kwargs.keys(): zoom = kwargs["zoom_start"] else: kwargs["zoom_start"] = zoom if "add_google_map" not in kwargs.keys() and "basemap" not in kwargs.keys(): kwargs["add_google_map"] = True if "plugin_LatLngPopup" not in kwargs.keys(): kwargs["plugin_LatLngPopup"] = True if "plugin_Fullscreen" not in kwargs.keys(): kwargs["plugin_Fullscreen"] = True if "plugin_Draw" not in kwargs.keys(): kwargs["plugin_Draw"] = False if "Draw_export" not in kwargs.keys(): kwargs["Draw_export"] = True if "plugin_MiniMap" not in kwargs.keys(): kwargs["plugin_MiniMap"] = False if "plugin_LayerControl" not in kwargs.keys(): kwargs["plugin_LayerControl"] = False super().__init__(**kwargs) self.baseclass = "folium" if kwargs.get("add_google_map"): ee_basemaps["ROADMAP"].add_to(self) if kwargs.get("basemap"): ee_basemaps[kwargs.get("basemap")].add_to(self) if kwargs.get("plugin_LatLngPopup"): folium.LatLngPopup().add_to(self) if kwargs.get("plugin_Fullscreen"): plugins.Fullscreen().add_to(self) if kwargs.get("plugin_Draw"): plugins.Draw(export=kwargs.get("Draw_export")).add_to(self) if kwargs.get("plugin_MiniMap"): plugins.MiniMap().add_to(self) if kwargs.get("plugin_LayerControl"): folium.LayerControl().add_to(self) self.fit_bounds([latlon, latlon], max_zoom=zoom)
def addDrawTool(self): plugins.Draw(export=True, filename='data.geojson', position='topleft', draw_options=None, edit_options=None).add_to(self.my_map)
def get_context_data(self, **kwargs): context = super(AgentsView, self).get_context_data(**kwargs) figure = folium.Figure() m = folium.Map(location=[48.383022, 31.1828699], zoom_start=6, tiles='OpenStreetMap', control_scale=True) m.add_to(figure) # # add tiles to map, Create a tile layer to append on a Map # folium.raster_layers.TileLayer('Open Street Map').add_to(m) # folium.raster_layers.TileLayer('Stamen Terrain').add_to(m) # folium.raster_layers.TileLayer('Stamen Toner').add_to(m) # folium.raster_layers.TileLayer('Stamen Watercolor').add_to(m) # folium.raster_layers.TileLayer('CartoDB Positron').add_to(m) # folium.raster_layers.TileLayer('CartoDB Dark_Matter').add_to(m) # # add layer control to show different maps # folium.LayerControl().add_to(m) # add minimap to map minimap = plugins.MiniMap(toggle_display=True) m.add_child(minimap) # add full screen button to map plugins.Fullscreen(position='topright').add_to(m) draw = plugins.Draw(export=True) # add draw tools to map draw.add_to(m) # display(m) for agent in self.get_queryset(): if agent.vehicle.vehicle_code == '30': color = 'orange' icon = 'fa-truck' elif agent.vehicle.vehicle_code == '20': color = 'green' icon = 'fa-train' elif agent.vehicle.vehicle_code == '10': color = 'blue' icon = 'fa-anchor' elif agent.vehicle.vehicle_code == '40': color = 'purple' icon = 'fa-plane' elif agent.vehicle.vehicle_code == '70': color = 'gray' icon = 'fa-gus-pump' folium.Marker(location=[agent.latitude, agent.longitude], tooltip='Натисніть щоб дізнатися більше', popup=agent.name + ' ' + agent.notes, icon=folium.Icon(color=color, icon=icon, prefix='fa')).add_to(m) m = m._repr_html_() figure.render() context['agents'] = Agent.objects.all() context['country_counts'] = Agent.objects.values('country').annotate( Count('country')) context['sea'] = Agent.objects.filter(vehicle__vehicle_code='10') context['air'] = Agent.objects.filter(vehicle__vehicle_code='40') context['map'] = m return context
def run(self): """Run method that performs all the real work""" # Create the dialog with elements (after translation) and keep reference # Only create GUI ONCE in callback, so that it will only load when the plugin is started if self.first_start == True: self.first_start = False self.dlg = HTMLmapDialog() if self.dlg.radioButton.isChecked(): self.dlg.pushButton_1.clicked.connect( self.atualizarCoordenadaPartidaOSM) self.dlg.pushButton_2.clicked.connect( self.atualizarCoordenadaChegadaOSM) if self.dlg.radioButton_2.isChecked(): self.dlg.pushButton_1.clicked.connect( self.atualizarCoordenadaPartidaGoogle) self.dlg.pushButton_2.clicked.connect( self.atualizarCoordenadaChegadaGoogle) self.dlg.horizontalSlider.setValue(16) with open( r'C:\OSGeo4W64\apps\qgis\python\plugins\htmlmap\Base\fontawesone.txt', "r") as f: f.readline() for x in f: comboText = self.dlg.comboBox_4.addItem(x) comboText = self.dlg.comboBox_7.addItem(x) comboText = self.dlg.comboBox_10.addItem(x) icon_color = { 'beige', 'black', 'blue', 'cadetblue', 'darkblue', 'darkgreen', 'darkpurple', 'darkred', 'gray', 'green', 'lightblue', 'lightgray', 'lightgreen', 'lightred', 'orange', 'pink', 'purple', 'red', 'white' } add_icon_color = self.dlg.comboBox_3.addItems(icon_color) add_icon_color = self.dlg.comboBox_8.addItems(icon_color) # show the dialog self.dlg.show() # Run the dialog event loop result = self.dlg.exec_() # See if OK was pressed if result: # Do something useful here - delete the line containing pass and # substitute with your code. latPartida = self.dlg.lineEdit_5.text() lat = float(latPartida) longPartida = self.dlg.lineEdit_6.text() long = float(longPartida) if self.dlg.mGroupBox_8.isChecked(): latChegada = self.dlg.lineEdit_7.text() lat2 = float(latChegada) longChegada = self.dlg.lineEdit_8.text() long2 = float(longChegada) latcentral = (lat + lat2) / 2 longcentral = (long + long2) / 2 lat = latcentral long = longcentral #CRIAR O MAPA/TILE tiles = ('Open Street Map', 'Stamen Terrain', 'Stamen Toner', 'Stamen Watercolor', 'CartoDB Positron', 'CartoDB Dark_Matter') #IMAGEM DE SATÉLITE GOOGLE zoom = self.dlg.horizontalSlider.value() m = folium.Map(location=[lat, long], zoom_start=zoom, tiles=None, prefer_canvas=True) if self.dlg.comboBox.currentText() == 'Google Maps': folium.raster_layers.TileLayer( tiles='http://{s}.google.com/vt/lyrs=m&x={x}&y={y}&z={z}', attr='google', name='Google Maps', max_zoom=20, subdomains=['mt0', 'mt1', 'mt2', 'mt3'], overlay=False, control=True, ).add_to(m) if self.dlg.comboBox.currentText() == 'Google Earth': folium.raster_layers.TileLayer( tiles='http://{s}.google.com/vt/lyrs=s&x={x}&y={y}&z={z}', attr='google', name='Google Earth', max_zoom=20, subdomains=['mt0', 'mt1', 'mt2', 'mt3'], overlay=False, control=True).add_to(m) if self.dlg.comboBox.currentText( ) == 'Open Street Map' or 'Stamen Terrain' or 'Stamen Toner' or 'Stamen Watercolor' or 'CartoDB Positron' or 'CartoDB Dark_Matter': folium.raster_layers.TileLayer( tiles=self.dlg.comboBox.currentText(), attr='google', name=self.dlg.comboBox.currentText(), max_zoom=20, control_scale=True).add_to(m) #MINIMAP if self.dlg.checkBox.isChecked(): minimap = plugins.MiniMap(position='bottomright', toggle_display=True, width=100, height=100, zoom_level_offset=-4, center_fixed=False, zoom_animation=True, minimized=False) m.add_child(minimap) #DESENHAR NA TELA if self.dlg.checkBox_2.isChecked(): draw = plugins.Draw(position='bottomright', export=True) draw.add_to(m) #MEDIÇÃO EM TELA DE DISTANCIA E ÁREA if self.dlg.checkBox_3.isChecked(): measure_control = plugins.MeasureControl( position='topright', active_color='red', completed_color='red', primary_lenght_unit='meters') m.add_child(measure_control) # ADICIONAR ALGUMA IMAGEM NA TELA if self.dlg.checkBox_4.isChecked(): url = self.dlg.mQgsFileWidget_5.filePath() FloatImage(url, bottom=92, left=1).add_to(m) #TELA CHEIA if self.dlg.checkBox_5.isChecked(): plugins.Fullscreen(position='topleft').add_to(m) #LOCALIZAÇÃO DA PESSOA if self.dlg.checkBox_6.isChecked(): plugins.LocateControl(position='topleft').add_to(m) if self.dlg.checkBox_8.isChecked(): # If you want get the user device positon after load the map, set auto_start=True plugins.LocateControl(auto_start=True).add_to(m) #LATITUDE E LONGITUDE PARA CLIQUES NO MAPA if self.dlg.checkBox_7.isChecked(): m.add_child(folium.LatLngPopup()) subgrupos = folium.FeatureGroup(name='Estilos de Mapas', control=False, show=False) m.add_child(subgrupos) if self.dlg.mGroupBox.isChecked(): opcao1 = plugins.FeatureGroupSubGroup( subgrupos, self.dlg.lineEdit_11.text(), show=True) m.add_child(opcao1) if self.dlg.mGroupBox_2.isChecked(): opcao2 = plugins.FeatureGroupSubGroup( subgrupos, self.dlg.lineEdit_12.text(), show=True) m.add_child(opcao2) if self.dlg.mGroupBox_3.isChecked(): opcao3 = plugins.FeatureGroupSubGroup( subgrupos, self.dlg.lineEdit_10.text(), show=True) m.add_child(opcao3) if self.dlg.mGroupBox_8.isChecked(): opcao4 = plugins.FeatureGroupSubGroup(subgrupos, 'Rota', show=True) m.add_child(opcao4) #PONTO if self.dlg.mGroupBox.isChecked(): PontosEntrada = self.dlg.mQgsFileWidget.filePath() PontosJSON = 'C:/OSGeo4W64/apps/qgis/python/plugins/htmlmap/Base/Pontos_json.geojson' gj = folium.GeoJson(PontosJSON) popupPontos = self.dlg.lineEdit.text() processing.run( "native:reprojectlayer", { 'INPUT': PontosEntrada, 'TARGET_CRS': QgsCoordinateReferenceSystem('EPSG:4326'), 'OPERATION': '+proj=pipeline +step +inv +proj=utm +zone=22 +south +ellps=GRS80 +step +proj=unitconvert +xy_in=rad +xy_out=deg', 'OUTPUT': PontosJSON }) for feature in gj.data['features']: if feature['geometry']['type'] == 'Point': if self.dlg.comboBox_2.currentText() == 'Pin': icon = self.dlg.comboBox_4.currentText() color = self.dlg.mColorButton_11.color().name() icon_color = self.dlg.mColorButton_5.color().name() folium.Marker(location=list( reversed(feature['geometry']['coordinates'])), popup=popupPontos, icon=folium.Icon( icon=icon, color=color, icon_color=icon_color, prefix='fa')).add_to(opcao1) if self.dlg.comboBox_2.currentText( ) == 'Beautify Icon': icon = self.dlg.comboBox_4.currentText() icon_color = self.dlg.mColorButton_5.color().name() color = 'transparent' tamanho = self.dlg.doubleSpinBox_4.value() icon_size = (tamanho, tamanho) icon_plane = plugins.BeautifyIcon( icon=icon, icon_size=icon_size, border_color='transparent', background_color=color, innerIconStyle= 'font-size:20px;padding-top:1px;', text_color=icon_color) folium.Marker(location=list( reversed(feature['geometry']['coordinates'])), popup=popupPontos, icon=icon_plane).add_to(opcao1) #LINHA if self.dlg.mGroupBox_2.isChecked(): LinhaEntrada = self.dlg.mQgsFileWidget_2.filePath() LinhaJSON = 'C:/OSGeo4W64/apps/qgis/python/plugins/htmlmap/Base/Linha_json.geojson' espessura = self.dlg.doubleSpinBox_5.value() color = self.dlg.mColorButton.color().name() borda = self.dlg.mColorButton_13.color().name() popupLinhas = self.dlg.lineEdit_9.text() processing.run( "native:reprojectlayer", { 'INPUT': LinhaEntrada, 'TARGET_CRS': QgsCoordinateReferenceSystem('EPSG:4326'), 'OPERATION': '+proj=pipeline +step +inv +proj=utm +zone=22 +south +ellps=GRS80 +step +proj=unitconvert +xy_in=rad +xy_out=deg', 'OUTPUT': LinhaJSON }) styleLinha = { "fillOpacity": 1, 'fillColor': borda, 'color': color, "weight": espessura, "opacity": 1.0 } folium.GeoJson(LinhaJSON, style_function=lambda x: styleLinha, popup=popupLinhas).add_to(opcao2) #POLÍGONO if self.dlg.mGroupBox_3.isChecked(): PoligonoEntrada = self.dlg.mQgsFileWidget_3.filePath() popupPoligono = self.dlg.lineEdit_2.text() color = self.dlg.mColorButton_3.color().name() borda = self.dlg.mColorButton_2.color().name() transparencia = self.dlg.doubleSpinBox.value() PoligonoJSON = 'C:/OSGeo4W64/apps/qgis/python/plugins/htmlmap/Base/Poligono_json.geojson' processing.run( "native:reprojectlayer", { 'INPUT': PoligonoEntrada, 'TARGET_CRS': QgsCoordinateReferenceSystem('EPSG:4326'), 'OPERATION': '+proj=pipeline +step +inv +proj=utm +zone=22 +south +ellps=GRS80 +step +proj=unitconvert +xy_in=rad +xy_out=deg', 'OUTPUT': PoligonoJSON }) stylePoligono = { 'fillColor': color, "fillOpacity": transparencia, 'color': borda, "weight": self.dlg.doubleSpinBox_2.value() } folium.GeoJson( PoligonoJSON, style_function=lambda x: stylePoligono).add_to(opcao3) #ADICIONAR IMAGEM - CERTO # url = 'http://leafletjs.com/examples/custom-icons/{}'.format # icon_image = url('leaf-red.png') # icon3d = 'https://www.pngfind.com/pngs/m/218-2181815_download-setas-em-3d-png-images-background-setas.png' # icon = CustomIcon(icon3d,icon_size=(19,47)) # marker = folium.Marker(location=[-25.4528, -49.2323],icon=icon,popup='Árvore') # m.add_child(marker) # icon_plane = plugins.BeautifyIcon(icon='tree', border_color='transparent', backgroundColor = 'transparent', iconSize= (22,22), border_width = 0.1, text_color='#83ca57',inner_icon_style='font-size:20px;padding-top:1px;') # icon_number = plugins.BeautifyIcon(iconSize = (15, 15), border_width = 0, text_color='#000000', backgroundColor = 'transparent', number='A',inner_icon_style='font-size:15px') # coord_arvores = [-25.4523, -49.2326] # folium.Marker(location=coord_arvores,popup='Árvore', icon=icon_plane).add_to(m) # folium.Marker(location=[-25.4527, -49.2331],popup='Bloco', icon=icon_number).add_to(m) #folium.LayerControl(collapsed=True).add_to(m) #icon3d = r'C:\Users\fabri\Desktop\Imagem1.svg' #icon = CustomIcon(icon3d,icon_size=(19,47)) #marker = folium.Marker(location=[-25.4528, -49.2323],icon=icon,popup='Árvore') #m.add_child(marker) #ORIGEM latPartida = self.dlg.lineEdit_5.text() latPartida = float(latPartida) longPartida = self.dlg.lineEdit_6.text() longPartida = float(longPartida) startPoint = '%s, %s [EPSG:4326]' % ( longPartida, latPartida) #'-46.505448,-18.578563 [EPSG:4326]' if self.dlg.comboBox_9.currentText() == 'Pin': icon = self.dlg.comboBox_7.currentText() color = self.dlg.comboBox_3.currentText() icon_color = self.dlg.mColorButton_7.color().name() folium.Marker(location=[latPartida, longPartida], popup='Início', icon=folium.Icon(icon=icon, color=color, icon_color=icon_color, prefix='fa')).add_to(m) if self.dlg.comboBox_9.currentText() == 'Beautify Icon': icon = self.dlg.comboBox_7.currentText() #color = self.dlg.comboBox_7.currentText() color = 'transparent' icon_color = self.dlg.mColorButton_7.color().name() icon_size = (10, 10) icon_plane = plugins.BeautifyIcon( icon=icon, prefix='fa', icon_size=icon_size, border_color='transparent', background_color=color, innerIconStyle='font-size:20px;padding-top:1px;', text_color=icon_color) folium.Marker(location=[latPartida, longPartida], popup='Início', icon=icon_plane).add_to(m) #ROTA if self.dlg.mGroupBox_8.isChecked(): latPartida = self.dlg.lineEdit_5.text() latPartida = float(latPartida) longPartida = self.dlg.lineEdit_6.text() longPartida = float(longPartida) latChegada = self.dlg.lineEdit_7.text() latChegada = float(latChegada) longChegada = self.dlg.lineEdit_8.text() longChegada = float(longChegada) lat, long = [round(latPartida, 3), round(latChegada, 3) ], [round(longPartida, 3), round(longChegada, 3)] minlong, maxlong, minlat, maxlat = [ min(long) + 0.3, max(long) - 0.3, min(lat) + 0.3, max(lat) - 0.3 ] extensao = '%s, %s, %s, %s [EPSG:4326]' % (minlong, maxlong, minlat, maxlat) redeOSM = 'C:/OSGeo4W64/apps/qgis/python/plugins/htmlmap/Base/Curitiba_vias01.shp' #malhaRota = 'C:/OSGeo4W64/apps/qgis/python/plugins/htmlmap/Base/cortado.gpkg' #processing.run("native:extractbyextent", {'INPUT':redeOSM,'EXTENT':extensao,'CLIP':False,'OUTPUT':malhaRota}) startPoint = '%s, %s [EPSG:4326]' % ( longPartida, latPartida ) #'-46.505448,-18.578563 [EPSG:4326]' finalPoint = '%s, %s [EPSG:4326]' % ( longChegada, latChegada ) #'-46.507785,-18.577713 [EPSG:4326]' Ponto2 = '%s, %s' % (longChegada, latChegada) if self.dlg.comboBox_12.currentText() == 'Pin': icon = self.dlg.comboBox_10.currentText() color = self.dlg.comboBox_8.currentText() icon_color = self.dlg.mColorButton_8.color().name() folium.Marker(location=[latChegada, longChegada], popup='Chegada', icon=folium.Icon(icon=icon, color=color, icon_color=icon_color, prefix='fa')).add_to(opcao4) if self.dlg.comboBox_12.currentText() == 'Beautify Icon': icon = self.dlg.comboBox_10.currentText() icon_color = self.dlg.mColorButton_8.color().name() color = 'transparent' icon_size = (10, 10) icon_plane = plugins.BeautifyIcon( icon=icon, icon_size=icon_size, border_color='transparent', background_color=color, innerIconStyle='font-size:20px;padding-top:1px;', text_color=icon_color) folium.Marker(location=[latChegada, longChegada], popup='Chegada', icon=icon_plane).add_to(opcao4) rota = 'C:/OSGeo4W64/apps/qgis/python/plugins/htmlmap/Base/rota.geojson' processing.run( "native:shortestpathpointtopoint", { 'INPUT': redeOSM, 'STRATEGY': 0, 'DIRECTION_FIELD': None, 'VALUE_FORWARD': '', 'VALUE_BACKWARD': '', 'VALUE_BOTH': '', 'DEFAULT_DIRECTION': 2, 'SPEED_FIELD': None, 'DEFAULT_SPEED': 50, 'TOLERANCE': 0, 'START_POINT': startPoint, 'END_POINT': finalPoint, 'OUTPUT': rota }) with open(rota) as f: data = json.load(f) for feature in data['features']: coordenadasRota = (feature['geometry']['coordinates']) coord_list = [] for coord_pair in coordenadasRota: json_coord_pair = {} json_coord_pair = [(coord_pair[1]), (coord_pair[0])] coord_list.append(json_coord_pair) cor_rota = self.dlg.mColorButton_4.color().name() cor_simbolo = self.dlg.mColorButton_6.color().name() if self.dlg.mGroupBox_10.isChecked(): formato_simbolo = self.dlg.comboBox_5.currentText() if self.dlg.comboBox_5.currentText() == 'Arredondado': formato_simbolo = 'round' if self.dlg.comboBox_5.currentText() == 'Quadrado': formato_simbolo = 'butt' if self.dlg.comboBox_5.currentText() == 'Retangular': formato_simbolo = 'square' juncao = self.dlg.comboBox_6.currentText() if self.dlg.comboBox_6.currentText() == 'Arredondado': juncao = 'round' if self.dlg.comboBox_6.currentText() == 'Reto': juncao = 'mitter' if self.dlg.comboBox_6.currentText() == 'Cortado': juncao = 'bevel' plugins.AntPath( [coord_list], popup='Rota', color=cor_rota, weight=self.dlg.doubleSpinBox_8.value(), opacity=1, delay=self.dlg.spinBox_3.value(), line_cap=formato_simbolo, line_join=juncao, dash_array=[10, 20], pulse_color=cor_simbolo, reverse=True, hardwareAccelerated=True).add_to(opcao4) else: plugins.AntPath( [coord_list], popup='Rota', color=cor_rota, weight=self.dlg.doubleSpinBox_8.value(), opacity=1, pulse_color=cor_rota, delay=0).add_to(opcao4) #SALVAR MAPA folium.LayerControl(collapsed=True).add_to(m) salvarHTML = self.dlg.mQgsFileWidget_4.filePath() + ".html" m_save = m.save(salvarHTML) message = ("Finalizado: O arquivo foi processado e salvo.") self.iface.messageBar().pushMessage(message, level=0, duration=10)
m.add_child(fg1) m.add_child(fg2) m.add_child(fg3) m.add_child(fg4) # create Mini Map Minimap = plugins.MiniMap(toggle_display=True) # add mini map to the Map (m) m.add_child(Minimap) # Add full Screen plugins.Fullscreen(position='topright').add_to(m) # Adding Draw Tools to the Map (m) draw = plugins.Draw(export=True, ) m.add_child(draw) # Add Measure Control tools to the Map (m) measure = plugins.MeasureControl(position='topleft', active_color='yellow', completed_color='red', primary_length_unit='meters') m.add_child(measure) # Adding Longitude and latitude tool to the map (m) m.add_child(folium.LatLngPopup()) # Creating Layer control to the map (m) m.add_child(folium.LayerControl(collapsed=True, position='topleft'))
folium.Marker( location=[6.942936, 80.610974], icon=folium.Icon(color='blue', icon='bar-chart', prefix='fa'), popup=folium.Popup(max_width=500).add_child( folium.Vega(vis3, width=500, height=250)) ).add_to(dat_grphs) plugins.HeatMap(datalist).add_to(sensor_hMap) # add layer control: folium.LayerControl(collapsed=True).add_to(tea_map) # enable lat/lon popovers for convenience tea_map.add_child(folium.LatLngPopup()) # vector drawing plugins.Draw( export=False, filename='my_data.geojson', position='topleft', draw_options={'polyline': {'allowIntersection': False}}, edit_options={'poly': {'allowIntersection': False}} ).add_to(tea_map) # m.save(os.path.join('results', 'Plugins_1.html')) tea_map.save("tea_map.html") print("...all done..!")
addresses = pd.DataFrame(results) addresses.to_csv("addresses_results.csv") # Pass Data to Folium Map plugins.FastMarkerCluster(data=list(zip(correct_database['Latitude'].values, correct_database['Longitude'].values))).add_to(folium_map) # Create Fullscreen Button plugins.Fullscreen( position="topright", title="Expand me", title_cancel="Exit me", force_separate_button=True ).add_to(folium_map) # Create Minimap minimap = plugins.MiniMap(toggle_display=toggle_minimap_display) folium_map.add_child(minimap) # Locate Control folium.LayerControl().add_to(folium_map) plugins.LocateControl(auto_start=False).add_to(folium_map) # Create Draw Toolkit draw = plugins.Draw(export=toggle_draw_toolkit) draw.add_to(folium_map) folium_map.save("map.html") else: print("Please insert a valid 'Number_of_Addresses' input, either 'One' or 'Many'.") print("Process finished --- %s seconds ---" % (time.time() - start_time))