def test_polyline_popups(): m = Map([43, -100], zoom_start=4) features.PolyLine([[40, -80], [45, -80]], popup="PolyLine").add_to(m) features.PolyLine([[40, -90], [45, -90]], popup=Popup("PolyLine")).add_to(m) features.MultiPolyLine([[[40, -110], [45, -110]]], popup="MultiPolyLine").add_to(m) features.MultiPolyLine([[[40, -120], [45, -120]]], popup=Popup("MultiPolyLine")).add_to(m) m._repr_html_()
def test_polyline_popups(): m = Map([43, -100], zoom_start=4) features.PolyLine([[40, -80], [45, -80]], popup='PolyLine').add_to(m) features.PolyLine([[40, -90], [45, -90]], popup=Popup('PolyLine')).add_to(m) features.PolyLine([[[40, -110], [45, -110]]], popup='MultiPolyLine').add_to(m) features.PolyLine([[[40, -120], [45, -120]]], popup=Popup('MultiPolyLine')).add_to(m) m._repr_html_() bounds = m.get_bounds() assert bounds == [[40, -120], [45, -80]], bounds
def displayMapId(fromId, toId, DBPath, i): """ display the trajectory from GPS point id from fromId to toId in the database Args: fromId: start GPS point id toId: end GPS point id i: the i-th table """ conn = preprocess.DBUtil.get_conn(DBPath) # find all points fetchAllPointSql = 'select id,lat,lon ' + \ 'from GPS_points_' + str(i) + \ ' where id>=' + str(fromId) + \ ' and id<=' + str(toId) allPointRecords = preprocess.DBUtil.fetchAll(conn, fetchAllPointSql) if allPointRecords is None: print('fetch point set Fail!') return preprocess.DBUtil.closeDB(conn) """ records: type list-> [(1, 36.98919, 111.823906666667).....] (id, lat, lon) id: 0 lat: 1 lon: 2 """ mapOsm = folium.Map(location=[allPointRecords[0][1], allPointRecords[0][2]], zoom_start=18) pointLat = [] pointLon = [] for item in allPointRecords: pointLat.append(item[1]) pointLon.append(item[2]) # folium.CircleMarker([item[1], item[2]], # radius=3, # popup=str(item[0])).add_to(mapOsm) features.PolyLine( list(zip(pointLat, pointLon)), color='red', weight=2, popup='trajectory').add_to(mapOsm) mapOsm.save('temp/myOsm.html')
map_osm.add_child(marker) # draw line(在两个经纬诚度之间连线) kw = dict(opacity=1.0, weight=2) line1 = folium.PolyLine(locations=[(36.9841, 111.8194), (36.9841, 111.8205)], color='red', **kw) map_osm.add_child(line1) # draw trajectory1(轨迹画出) point_lat = [36.9860, 36.9861, 36.9860, 36.9858, 36.9857, 36.9856, 36.9855] point_lon = [ 111.8217, 111.8213, 111.8211, 111.8212, 111.8213, 111.8212, 111.8212 ] color_line = features.PolyLine(list(zip(point_lat, point_lon)), color='red', weight=2, popup='轨迹1') color_line.add_to(map_osm) # draw trajectory2(轨迹画出) Traj_data = [[36.9857, 111.8194, 2.4], [36.9856, 111.8193, 2.2], [36.9853, 111.8192, 2.1], [36.9851, 111.8195, 2.33]] columns = ['Longitude', 'Latitude', 'Speed'] df = DataFrame(Traj_data, columns=columns) """ print(df.head()) output: Longitude Latitude Speed 0 36.9857 111.8194 2.40 1 36.9856 111.8193 2.20 2 36.9853 111.8192 2.10