def draw_mult_map(df_a, df_b): m = folium.Map(location=[df_a['lat'].mean(), df_b['long'].mean()], zoom_start=15, control_scale=True) feature_group_estaciones = folium.FeatureGroup( name='Estaciones de Bicicletas') feature_group_tiendas = folium.FeatureGroup(name='bicicleterias') marker_cluster_estaciones = MarkerCluster() marker_cluster_tiendas = MarkerCluster() for row in df_a.iterrows(): marker_estaciones = folium.Marker( location=[row[1]['lat'], row[1]['long']], popup=str(row[1]['nro_est']) + '. ' + str(row[1]['nombre']), icon=folium.Icon(color='green')) marker_cluster_estaciones.add_child(marker_estaciones) for row in df_b.iterrows(): marker_tiendas = folium.Marker( location=[row[1]['lat'], row[1]['long']], popup=row[1]['nombre'], icon=folium.Icon(color='red')) marker_cluster_tiendas.add_child(marker_tiendas) feature_group_estaciones.add_child(marker_cluster_estaciones) feature_group_tiendas.add_child(marker_cluster_tiendas) m.add_child(feature_group_estaciones) m.add_child(feature_group_tiendas) m.add_child(folium.LayerControl()) #OPTIONAL PLUGGINS #minimaps minimap = MiniMap(toggle_display=True) m.add_child(minimap) #measure tool m.add_child(MeasureControl()) #show de coordinates from cursor position MousePosition().add_to(m) #draw tools draw = Draw(export=True) draw.add_to(m) #full screen Fullscreen(position='topright', title='Expand me', title_cancel='Exit me', force_separate_button=True).add_to(m) return m
def gerarMapadePonto(listaDeCoordenadas, nomeDoMapa): mapa = folium.Map(location=[-8.05428, -34.8813], zoom_start=12) marker_cluster = MarkerCluster().add_to(mapa) draw = Draw() draw.add_to(mapa) if listaDeCoordenadas != None: for la, lo, rua, in zip(listaDeCoordenadas[0], listaDeCoordenadas[1], listaDeCoordenadas[2]): folium.Marker(location=[la, lo], popup=rua, icon=folium.Icon(color='red')).add_to(marker_cluster) mapa.save('app/templates/' + nomeDoMapa + ".html")
def map(): obj = f'data.geojson' mappy = folium.Map(width=950, height=950, location=[59.939095, 30.315856], zoom_start=11) # карта draw = Draw(export=True) folium.GeoJson(obj,name=obj).add_to(mappy) mappy.add_child(draw) folium.LayerControl().add_to(mappy) mappy.save('templates/map1.html') block() return mappy
def draw_map(df, cluster_marks=True): m = folium.Map(location=[df['lat'].mean(), df['long'].mean()], zoom_start=15, control_scale=True) if cluster_marks == True: mc = MarkerCluster() for row in df.iterrows(): mc.add_child( folium.Marker(location=[row[1]['lat'], row[1]['long']], popup=row[1]['nombre'])) m.add_child(mc) else: for row in df.iterrows(): folium.Marker(location=[row[1]['lat'], row[1]['long']], popup=row[1]['nombre']).add_to(m) #OPTIONAL PLUGGINS #minimaps minimap = MiniMap(toggle_display=True) m.add_child(minimap) #measure tool m.add_child(MeasureControl()) #show de coordinates from cursor position MousePosition().add_to(m) #draw tools draw = Draw(export=True) draw.add_to(m) #full screen Fullscreen(position='topright', title='Expand me', title_cancel='Exit me', force_separate_button=True).add_to(m) return m
def draw(): m = folium.Map(location=[55.8527, 37.5689], zoom_start=13) draw = Draw(export=True,filename='footprint.geojson',position='bottomright',draw_options={'polyline':False,'rectangle':True,'polygon':True,'circle':False,'marker':True,'circlemarker':False},edit_options={'edit':False}) m.add_child(draw) data = io.BytesIO() m.save(data, close_file=False) w1 = QWebEngineView() w1.setHtml(data.getvalue().decode()) w1.resize(640, 480) layout.replaceWidget(w,w1) label_obj1.setText(u"please input search date like YYYYmmdd:") line_edit_obj1 = QLineEdit() # 单行编辑框 line_edit_obj1.textChanged[str].connect(onChanged) layout.replaceWidget(cb,line_edit_obj1) layout.update() win.update()
# coding: utf-8 # In[1]: import folium import MySQLdb db = MySQLdb.connect("localhost","root","","folium" ) from folium.plugins import Draw, Fullscreen cursor = db.cursor() m = folium.Map(location=[-27.228989, -48.36525], zoom_start=12) draw = Draw(export=True) draw.add_to(m) m # In[1]: import os import geopandas gpd = geopandas.read_file( os.path.join(os.path.expanduser('~'), 'data.geojson') )
poly_line = TimestampedGeoJson(data={ "type": "FeatureCollection", "features": [ { "type": "Feature", "geometry": { "type": "LineString", "coordinates": coordinates, }, "properties": { "times": time, "style": { "color": "red", "weight": 2 } } } ] }, period="PT1M") poly_line.add_to(map) # Create a tool to measure distance and area tool_measure = MeasureControl() tool_measure.add_to(map) # Create tool to draw something tool_draw = Draw() tool_draw.add_to(map) map.save("Munich_with_points_and_lines_.html")
""" from PyQt5 import QtCore, QtWidgets, QtWebEngineWidgets from folium.plugins import Draw import folium, io, sys, json if __name__ == '__main__': app = QtWidgets.QApplication(sys.argv) m = folium.Map(location=[49, 11], zoom_start=13) draw = Draw(draw_options={ 'polyline': False, 'rectangle': True, 'polygon': True, 'circle': False, 'marker': True, 'circlemarker': False }, edit_options={'edit': False}) m.add_child(draw) data = io.BytesIO() m.save(data, close_file=False) class WebEnginePage(QtWebEngineWidgets.QWebEnginePage): def javaScriptConsoleMessage(self, level, msg, line, sourceID): coords_dict = json.loads(msg) coords = coords_dict['geometry']['coordinates'][0] print(coords)
def createMapFile(self, Latitude, Longitude, ImgName, ImgDate, Zip): dlg = wx.DirDialog(self, "Select Photo Directory:") if dlg.ShowModal() == wx.ID_CANCEL: return # the user changed their mind pathname = dlg.GetPath() self.botP.thumbnail.ShowDir(pathname + "/Thumbnails") coordsPopup = [] coordsSearch = [] points = [] draw = Draw() mymap = folium.Map(location=[38.0, -97.0],zoom_start=5, attr=self.__attrStringMain) resolution, width, height = 75, 7, 3 for j in range(0, len(Latitude)): coordsPopuptemp = [Latitude[j][0], Longitude[j][0]]# Popup needs (Lat, Long) format coordsSearchtemp = [Longitude[j][0], Latitude[j][0]] #Search function needs (Long, Lat) format coordsPopup.append(coordsPopuptemp) coordsSearch.append(coordsSearchtemp) #----------------Used for Searching-------------------------------------------------------------------- for x in range(0, len(coordsSearch)): point = Point(coordsSearch[x]) my_feature=Feature(geometry=point, properties={"name": ImgName[x][0]}) points.append(my_feature) feature_collection = FeatureCollection(points) glayer=folium.GeoJson(feature_collection, name='Search Layer', show=False).add_to(mymap) folium.plugins.Search(layer=glayer, search_label='name', search_zoom=20).add_to(mymap) #------------------------------------------------------------------------------------------------------ mc = MarkerCluster(name='Cluster Layer',overlay=True, control=True) for i in range(0, len(Zip)): self.c.execute(('SELECT Latitude from exifdata WHERE zip_id = {}').format(i+1)) LatitudeCluster = self.c.fetchall() self.c.execute(('SELECT Longitude from exifdata WHERE zip_id = {}').format(i+1)) LongitudeCluster = self.c.fetchall() self.c.execute(('SELECT name from exifdata WHERE zip_id = {}').format(i+1)) ImgNameCluster = self.c.fetchall() self.c.execute(('SELECT date_time from exifdata WHERE zip_id = {}').format(i+1)) ImgDateCluster = self.c.fetchall() for x in range(0, len(LatitudeCluster)): filename = os.path.join((pathname + "/Thumbnails"), ("T_" + ImgNameCluster[x][0])) encoded = base64.b64encode(open(filename, 'rb').read()).decode() htmlstr = '<div style="font-size: 10pt">{}</div><div style="font-size: 10pt">{}</div><div style="font-size: 10pt">{}</div>, <img src="data:image/jpeg;base64,{}", \ width="128px" height="128px">'.format(ImgNameCluster[x][0],ImgDateCluster[x][0],str(coordsPopup[x]),encoded) html = folium.Html(htmlstr, script=True) iframe = folium.IFrame(htmlstr, width=(width*resolution)+20, height=(height*resolution)+20) Popup=folium.Popup(html, max_width=500) folium.Marker(location=[LatitudeCluster[x][0], LongitudeCluster[x][0]], popup=Popup).add_to(mc) rm.RoutingMachine().add_to(mymap) mymap.add_child(mc) folium.TileLayer(tiles='Mapbox Bright', attr=self.__attrStringGeneral).add_to(mymap) folium.TileLayer(tiles='Mapbox Control Room', attr=self.__attrStringGeneral).add_to(mymap) folium.LayerControl().add_to(mymap) draw.add_to(mymap) try: mymap.save(self.OnSaveAs()) except FileNotFoundError: dlg = wx.MessageDialog(self, "Map Not Saved Correctly!", "Error!", wx.OK | wx.ICON_ERROR) dlg.ShowModal() dlg.Destroy()
def mapping(self, start, end, dis, arg): gmaps = googlemaps.Client( key='AIzaSyBjcH8wXlR_EZAIm8k8XFHgkJ6cOlEtpvM') now = datetime.now() directions_result = gmaps.directions(start, end, mode="driving", departure_time=now) DirectionResult = directions_result[0]['legs'] DirectionSteps = DirectionResult[0]['steps'] DecodedNp = np.zeros(shape=[1, 2]) for step in DirectionSteps: Temp = list(step['polyline'].values()) DecodedNp = np.concatenate( (DecodedNp, np.array(polyline.decode(Temp[0])))) DecodedPos = DecodedNp.tolist() m = folium.Map(location=DecodedPos[1], zoom_start=5, tiles="Stamen Toner") draw = Draw() draw.add_to(m) #folium.TileLayer('Mapbox Control Room').add_to(m) # 여러가지 타일들 "Mapbox Bright" #folium.TileLayer('Stamen Toner').add_to(m) #folium.TileLayer('openstreetmap').add_to(m) #folium.LayerControl().add_to(m) # 빠른 마커로딩과 동시에 안됨 convert_dis = dis try: convert_dis = float(convert_dis) except ValueError: pass if arg == 1: if convert_dis * 1000 < DirectionResult[0]['distance']['value']: folium.Circle(location=DecodedPos[1], popup='Available distance', radius=convert_dis * 1000, color='#8AC317', fill=True, fill_color='#BBFF33').add_to(m) #기본 길이단위 미터 ShortestPolyline = folium.PolyLine(locations=[DecodedPos[1:]], color='red', weight=5).add_to(m) attr = { 'fill': '#421100', 'font-weight': 'bold', 'font-size': '48' } folium.plugins.PolyLineTextPath(ShortestPolyline, text='\u00BB ', repeat=True, center=True, offset=16, attributes=attr).add_to( m) # 색깔 그림 폰트 등등 라인꾸미기 self.progressBar.setValue(50) elif arg == 2: folium.Circle(location=DecodedPos[1], popup='Available distance', radius=convert_dis * 1000, color='#8AC317', fill=True, fill_color='#BBFF33').add_to(m) #기본 길이단위 미터 self.progressBar.setValue(0) EV_data = self.EV_Discovery() Availiable_ChargerLocList = [] for i in range(len(EV_data)): Charger_distance = self.Distance(DecodedPos[1][0], DecodedPos[1][1], EV_data[i][0], EV_data[i][1]) if Charger_distance < convert_dis: Availiable_ChargerLocList.append(EV_data[i]) folium.plugins.FastMarkerCluster(Availiable_ChargerLocList).add_to( m) if len(Availiable_ChargerLocList) == 0: self.textBrowser.append("There are no availiable charger") self.progressBar.setValue(100) elif arg == 3: folium.Circle(location=DecodedPos[1], popup='Available distance', radius=convert_dis * 1000, color='#8AC317', fill=True, fill_color='#BBFF33').add_to(m) #기본 길이단위 미터 self.progressBar.setValue(0) EV_data = self.EV_Discovery() Availiable_ChargerLocList = [] for i in range(len(EV_data)): Charger_distance = self.Distance(DecodedPos[1][0], DecodedPos[1][1], EV_data[i][0], EV_data[i][1]) if Charger_distance < convert_dis: Availiable_ChargerLocList.append(EV_data[i]) print(len(Availiable_ChargerLocList)) if len(Availiable_ChargerLocList) == 0: if convert_dis * 1000 < DirectionResult[0]['distance']['value']: folium.Circle(location=DecodedPos[1], popup='Available distance', radius=convert_dis * 1000, color='#8AC317', fill=True, fill_color='#BBFF33').add_to(m) #기본 길이단위 미터 ShortestPolyline = folium.PolyLine(locations=[DecodedPos[1:]], color='red', weight=5).add_to(m) attr = { 'fill': '#421100', 'font-weight': 'bold', 'font-size': '48' } folium.plugins.PolyLineTextPath(ShortestPolyline, text='\u00BB ', repeat=True, center=True, offset=16, attributes=attr).add_to( m) # 색깔 그림 폰트 등등 라인꾸미기 self.progressBar.setValue(50) self.textBrowser.append("There are no availiable charger") else: self.progressBar.setValue(70) #Find Efficient Electric Charger location min_Dist = 10000000000 # Initial min value Efficient_ElecChargLoc = [] for i in range(len(Availiable_ChargerLocList)): Dist1 = self.Distance(DecodedPos[1][0], DecodedPos[1][1], Availiable_ChargerLocList[i][0], Availiable_ChargerLocList[i][1]) Dist2 = self.Distance(DecodedPos[-1][0], DecodedPos[-1][1], Availiable_ChargerLocList[i][0], Availiable_ChargerLocList[i][1]) if (Dist1 + Dist2 < min_Dist): min_Dist = Dist1 + Dist2 Efficient_ElecChargLoc = [ Availiable_ChargerLocList[i][0], Availiable_ChargerLocList[i][1] ] print(Efficient_ElecChargLoc) self.progressBar.setValue(80) folium.Marker(Efficient_ElecChargLoc, popup='Recommended Electric Charger', icon=folium.Icon(color='green')).add_to(m) reverse_geocode_result = gmaps.reverse_geocode( Efficient_ElecChargLoc) ElecLocStr = reverse_geocode_result[0]['formatted_address'] #Start to Electric charger directions_result = gmaps.directions(start, ElecLocStr, mode="driving", departure_time=now) DirectionResult = directions_result[0]['legs'] DirectionSteps = DirectionResult[0]['steps'] DecodedNp = np.zeros(shape=[1, 2]) for step in DirectionSteps: Temp = list(step['polyline'].values()) DecodedNp = np.concatenate( (DecodedNp, np.array(polyline.decode(Temp[0])))) DecodedPos = DecodedNp.tolist() StartToElecCharg = folium.PolyLine(locations=[DecodedPos[1:]], color='green', weight=5).add_to(m) attr = { 'fill': '#421100', 'font-weight': 'bold', 'font-size': '48' } folium.plugins.PolyLineTextPath(StartToElecCharg, text='\u00BB ', repeat=True, center=True, offset=16, attributes=attr).add_to( m) # Color, font #Electric charger to end directions_result = gmaps.directions(ElecLocStr, end, mode="driving", departure_time=now) DirectionResult = directions_result[0]['legs'] DirectionSteps = DirectionResult[0]['steps'] DecodedNp = np.zeros(shape=[1, 2]) for step in DirectionSteps: Temp = list(step['polyline'].values()) DecodedNp = np.concatenate( (DecodedNp, np.array(polyline.decode(Temp[0])))) DecodedPos = DecodedNp.tolist() ElecChargToEnd = folium.PolyLine(locations=[DecodedPos[1:]], color='green', weight=5).add_to(m) attr = { 'fill': '#421100', 'font-weight': 'bold', 'font-size': '48' } folium.plugins.PolyLineTextPath(ElecChargToEnd, text='\u00BB ', repeat=True, center=True, offset=16, attributes=attr).add_to( m) # 색깔 그림 폰트 등등 라인꾸미기 ''' marker_cluster = folium.plugins.MarkerCluster( locations=data, popups=['lon:{}<br>lat:{}'.format(lon, lat) for (lat, lon) in data], name='EVcharger',overlay=True,control=False,icon_create_function=None) marker_cluster.add_to(m)# ''' # self.progressBar.setValue(70) m.save('temp\RoutePlanner.html')
.openOn({{this._parent.get_name()}}); } {{this._parent.get_name()}}.on('click', latLngPop); {% endmacro %} """) locations = [] coordinates = {} detroit = [42.3316, -83.0467] folium_map = folium.Map(location=detroit, zoom_start=8) draw = Draw() draw.add_to(folium_map) fmtr = "function(num) {return L.Util.formatNum(num, 3) + ' deg ';};" mouse = plugins.MousePosition(position='topright', separator=' ', num_digits=10, prefix="Current Location:", lat_formatter=fmtr, lng_formatter=fmtr) mouse.add_to(folium_map) @app.route('/') def index(): folium_map.add_child(PopUp())
def index(): start_coords = (-15.79340,-47.88232) folium_map = folium.Map(location=start_coords, zoom_start=16) draw = Draw() draw.add_to(folium_map) folium_map.add_child(MeasureControl()) tooltip = 'Click me!' folium.Marker( [-15.796218,-47.872002 ], popup='<i>Estrada Parque Ceilândia, SIA</i>', icon=folium.Icon(color='black',icon='car', prefix='fa'), tooltip=tooltip).add_to(folium_map) folium.Marker( [-15.791077,-47.875543], popup='<b>QSB 12, Taguatinga, Região</b>', icon=folium.Icon(color='black',icon='car', prefix='fa'), tooltip=tooltip).add_to(folium_map) folium.Marker( [-15.787711,-47.878397], popup='<b>Bloco A / B, W1 Sul, SQS 104, Asa Sul</b>', icon=folium.Icon(color='black',icon='car', prefix='fa'), tooltip=tooltip).add_to(folium_map) folium.Marker( [-15.790932,-47.879212], popup='<b>Recanto das Emas, Região Integrada de Desenvol...</b>', icon=folium.Icon(color='black',icon='car', prefix='fa'), tooltip=tooltip).add_to(folium_map) folium.Marker( [-15.793678,-47.880199], popup='<b>Recanto das Emas, Região Integrada de Desenvol...</b>', icon=folium.Icon(color='black',icon='car', prefix='fa'), tooltip=tooltip).add_to(folium_map) folium.Marker( [-15.79628,-47.885885], popup='<b>Recanto das Emas, Região Integrada de Desenvol...</b>', icon=folium.Icon(color='black',icon='car', prefix='fa'), tooltip=tooltip).add_to(folium_map) folium.Marker( [-15.789507,-47.883203], popup='<b>Recanto das Emas, Região Integrada de Desenvol...</b>', icon=folium.Icon(color='black',icon='car', prefix='fa'), tooltip=tooltip).add_to(folium_map) folium.Marker( [-47.887988,-47.887988], popup='<b>Recanto das Emas, Região Integrada de Desenvol...</b>', icon=folium.Icon(color='black',icon='car', prefix='fa'), tooltip=tooltip).add_to(folium_map) folium.Marker( [-15.79436,-47.887602], popup='<b>Recanto das Emas, Região Integrada de Desenvol...</b>', icon=folium.Icon(color='black',icon='car', prefix='fa'), tooltip=tooltip).add_to(folium_map) folium.Marker( [-15.788743,-47.889705], popup='<b>Recanto das Emas, Região Integrada de Desenvol...</b>', icon=folium.Icon(color='black',icon='car', prefix='fa'), tooltip=tooltip).add_to(folium_map) folium.Marker( [-15.788826,-47.89346], popup='<b>Recanto das Emas, Região Integrada de Desenvol...</b>', icon=folium.Icon(color='black',icon='car', prefix='fa'), tooltip=tooltip).add_to(folium_map) formatter = "function(num) {return L.Util.formatNum(num, 3) + ' º ';};" MousePosition( position='topright', separator=' | ', empty_string='NaN', lng_first=True, num_digits=20, prefix='Coordinates:', lat_formatter=formatter, lng_formatter=formatter, ).add_to(folium_map) return folium_map._repr_html_()
def indeks(): basemaps = { 'Google Maps': folium.TileLayer( tiles= 'https://mt1.google.com/vt/lyrs=m&x={x}&y={y}&z={z}', attr= 'Google', name ='Google Maps', overlay = True, control = True ), 'Google Satellite': folium.TileLayer( tiles= 'https://mt1.google.com/vt/lyrs=s&x={x}&y={y}&z={z}', attr= 'Google', name ='Google Satellite', overlay = True, control = True ), 'Google Terrain': folium.TileLayer( tiles= 'https://mt1.google.com/vt/lyrs=p&x={x}&y={y}&z={z}', attr= 'Google', name ='Google Terrain', overlay = True, control = True ), 'Google Satellite Hybrid': folium.TileLayer( tiles= 'https://mt1.google.com/vt/lyrs=y&x={x}&y={y}&z={z}', attr= 'Google', name ='Google Satellite Hybrid', overlay = True, control = True ), 'Esri Satellite': folium.TileLayer( tiles= 'https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}', attr= 'Esri', name ='Esri Satellite', overlay = True, control = True ), 'Stamen Terrain' : folium.TileLayer( tiles= 'Stamen Terrain', attr= 'Stamen Terrain', name ='Stamen Terrain', overlay = True, control = True ), 'Stamen Toner' : folium.TileLayer( tiles= 'Stamen Toner', attr= 'Stamen Toner', name ='Stamen Toner', overlay = True, control = True ), 'CartoDB Positron' : folium.TileLayer( tiles= 'CartoDB Positron', attr= 'CartoDB Positron', name ='CartoDB Positron', overlay = True, control = True ), 'OpenStreetMap' : folium.TileLayer( tiles= 'OpenStreetMap', attr= 'OpenStreetMap', name ='OpenStreetMap', overlay = True, control = True ) } # Directory Path r = os.path.dirname(os.path.abspath(__file__)) # Baca Data Konversi shapefile ke json batas_desa = gpd.read_file(r+'/assets/Desa.shp') batas_desa.to_file(r+'/assets/Desa.json', driver='GeoJSON') batas_kecamatan = gpd.read_file(r+'/assets/Kecamatan.shp') batas_kecamatan.to_file(r+'/assets/Kecamatan.json', driver='GeoJSON') toko_modern_point = gpd.read_file(r+'/assets/Toko_Modern_Centroids.shp') toko_modern_point.to_file(r+'/assets/Toko_Modern_Centroids.json', driver='GeoJSON') # Membaca data DBF valuesdesa = gpd.read_file(r+'/assets/Desa.dbf') start_coord = [-6.1950, 106.5528] map = folium.Map(location=start_coord, zoom_start=11, control_scale=True, height=650, width="100%") # Chloroplet # batas_kecamatan = folium.Choropleth( # geo_data = batas_kecamatan, #data geojson # name = 'Kepadatan Penduduk Kecamatan', #nama # data = valueskecamatan, #data tabel # columns =['KECAMATAN', 'KEP_PEND'], #colom dari tabel # key_on ="properties.KECAMATAN", #kunci # fill_color = 'Spectral_r', #pallete # fill_opacity = 0.75, #transparansi fill # line_opacity = 0.3, #transparansi outline # legend_name = f"Kepadatan Penduduk per kecamatan Kabupaten Tangerang Tahun 2015", #legenda # smooth_factor= 0.05, # ).add_to(map) batas_desa = folium.Choropleth( geo_data = batas_desa, #data geojson name = 'Kepadatan Penduduk Desa & Kelurahan', #nama data = valuesdesa, #data tabel columns =['DESA_KEL', 'KEP_PEND'], #colom dari tabel key_on ="properties.DESA_KEL", #kunci fill_color = 'Spectral_r', #pallete fill_opacity = 0.75, #transparansi fill line_opacity = 0.3, #transparansi outline legend_name = f"Kepadatan Penduduk per desa/kel Kabupaten Tangerang Tahun 2015", #legenda smooth_factor= 0.05 ).add_to(map) # Toolkit and Pop Up style_function = "font-size: 10px; font-weight: bold" # batas_kecamatan.geojson.add_child(folium.features.GeoJsonTooltip(['KECAMATAN','KEP_PEND'], style=style_function, labels=True)) batas_desa.geojson.add_child(folium.features.GeoJsonTooltip(['DESA_KEL','KECAMATAN','KEP_PEND'], style=style_function, labels=True)) # Cluster Marker toko_modern_point["x"] = toko_modern_point["geometry"].x toko_modern_point["y"] = toko_modern_point["geometry"].y locations = list(zip(toko_modern_point["y"], toko_modern_point["x"], toko_modern_point['N_Alfamart'])) marker_cluster = MarkerCluster().add_to(map) for POINT_Y, POINT_X, NAMAOBJ in locations : folium.Marker(location=[POINT_Y, POINT_X],popup= NAMAOBJ, icons="darkblue", clustered_Marker= True, style=style_function, name = "Toko Modern").add_to(marker_cluster) # Basemap for basemap, TileLayer in basemaps.items(): basemaps[basemap].add_to(map) folium.LayerControl().add_to(map) #mouse position fmtr = "function(num) {return L.Util.formatNum(num,3) + ' degres';};" # Plugins Draw ( export=False, filename='/assets/test.geojson', position="topleft", draw_options = None, edit_options = None ).add_to(map) MousePosition ( position='bottomright', Separator = "|", prefix="Mouse:", lat_formatter=fmtr, lng_formatter=fmtr ).add_to(map) MeasureControl ( position='topright', primary_length_unit='meters', secondary_length_unit='kilometers', primary_area_unit='sqmeters', secondary_area_unit='acres' ).add_to(map) minimap = MiniMap() map.add_child(minimap) map.save(r+'/templates/map.php') return render_template('index.php',)
# 4-3-5. 마우스 포지션(위도, 경도) 찾기 기능 from folium.plugins import MousePosition MousePosition().add_to(map_pplace) # 4-3-6. 측정도구 기능 from folium.plugins import MeasureControl map_pplace.add_child(MeasureControl()) # 4-3-7. 그림 그리기 기능 (이거 되게 자주 쓰일듯!!!!!!) # export=True 옵션 : 내가 그린 영역을 JSON 파일로 뽑아내줌 # 주의점 : 서브그룹이 많으면 4-3-7에서의 export 기능이 안됨. 직접 돌려보면 알거임. fg = folium.FeatureGroup(name="전체") # 전체그룹 설정 g2 = plugins.FeatureGroupSubGroup(fg, '교통정보수집') g1 = plugins.FeatureGroupSubGroup(fg, '교통단속') # 서브그룹 틀 만들기 from folium.plugins import Draw Draw(export=True).add_to(map_pplace) # 4-3-8. 그룹 만들기 g3 = plugins.FeatureGroupSubGroup(fg, '기타') g4 = plugins.FeatureGroupSubGroup(fg, '생활방범') g5 = plugins.FeatureGroupSubGroup(fg, '쓰레기단속') g6 = plugins.FeatureGroupSubGroup(fg, '어린이보호') g7 = plugins.FeatureGroupSubGroup(fg, '재난재해') map_cctv.add_child(fg) # 서브 그룹 맵에 넣기 map_cctv.add_child(g1) map_cctv.add_child(g2) map_cctv.add_child(g3) map_cctv.add_child(g4) map_cctv.add_child(g5) map_cctv.add_child(g6)
attr = 'Esri', name = 'Esri Satellite', overlay = False, control = True ).add_to(m) # add geojson folium.GeoJson(gdf.to_json(), style_function=lambda x: style).add_to(m) # load openstreet map folium.TileLayer('openstreetmap').add_to(m) # load terrain map folium.TileLayer('Stamen Terrain').add_to(m) # add lat/lon popup after click on maps folium.LatLngPopup().add_to(m) # #folium.ClickForMarker().add_to(m) # open layer control in upper right corner of the map folium.LayerControl().add_to(m) # draw plugin Draw( export=True, filename='my_data.geojson', position='topleft', draw_options={'polyline': {'allowIntersection': False}}, edit_options={'poly': {'allowIntersection': False}} ).add_to(m)
group3 = folium.FeatureGroup(name="501 <= nums <= 1000") group4 = folium.FeatureGroup(name="nums > 1000") for k, v in info.items(): Rent, Return = k.split(":") if v < 5: continue elif 5 <= v <= 100: group1.add_child(folium.ColorLine(convert_float([data[Rent], data[Return]]), colors=[ 0, 1], colormap=['#007799', '#007799'], opacity=0.4, weight=0.5)) elif 101 <= v <= 500: group2.add_child(folium.ColorLine(convert_float([data[Rent], data[Return]]), colors=[ 0, 1], colormap=['#00AAAA', '#00AAAA'], weight=1.2)) elif 501 <= v <= 1000: group3.add_child(folium.ColorLine(convert_float([data[Rent], data[Return]]), colors=[ 0, 1], colormap=['#00FFCC', '#00FFCC'], opacity=0.8, weight=1.8)) else: group4.add_child(folium.ColorLine(convert_float([data[Rent], data[Return]]), colors=[ 0, 1], colormap=['#BBFF00', '#BBFF00'], weight=3)) myMap.add_child(group1) myMap.add_child(group2) myMap.add_child(group3) myMap.add_child(group4) folium.LayerControl().add_to(myMap) Draw(export=True).add_to(myMap) myMap.save("D:\\大學課程\\大二上\\社會科學程式設計\\Youbike專題\\White LineGraph.html")
popup='<h2>Mapa Clasico</h2>', fill_color='#07131d').add_to(mapa) marker = folium.Marker(location=[-34.969672, -71.230373], icon=folium.Icon(color='red', icon='info-sign'), popup='19473993-1').add_to(mapa) mapa.save("recursos/map.html") ########################################################## from folium.plugins import Draw m = folium.Map(location=[-34.9926116, -71.2527959], zoom_start=13) draw = Draw() draw.add_to(m) plug = plugins.TimestampedGeoJson({ 'type': 'FeatureCollection', }, period='PT1M', add_last_point=True) plug.add_to(m) m.save(os.path.join('recursos', 'dibujar.html')) ####################################### import json import numpy as np