lets_plot.geom_livemap#
- lets_plot.geom_livemap(*, location=None, zoom=None, projection=None, tiles=None, show_coord_pick_tools=None, data_size_zoomin=None, const_size_zoomin=None, **other_args)#
Display an interactive map.
- Parameters:
- locationlist
Initial position of the map. If not set, display the United States. There are [lon1, lat1, lon2, lat2,…, lonN, latN]: lon1, lon2,…, lonN are longitudes in degrees (positive in the Eastern hemisphere); lat1, lat2,…, latN are latitudes in degrees (positive in the Northern hemisphere).
- zoomint
Zoom of the map in the range 1 - 15.
- projectionstr, default=’epsg3857’
The map projection. There are: ‘epsg3857’ for Mercator projection; ‘epsg4326’ for Equirectangular projection. projection only works with vector map tiles (i.e. Lets-Plot map tiles).
- tilesstr
Tile provider:
pass a predefined constant from the tilesets module (Lets-Plot’s vector tiles, e.g. LETS_PLOT_COLOR, or external raster tiles, e.g. OPEN_TOPO_MAP);
pass a URL for a standard raster ZXY tile provider with {z}, {x} and {y} wildcards (e.g. ‘http://my.tile.com/{z}/{x}/{y}.png’) if the required tileset not present in the module;
pass the result of a call to a maptiles_zxy() function if further customisation is required (e.g. attribution or zoom).
More information about tiles can be found here: https://lets-plot.org/python/pages/basemap_tiles.html
- show_coord_pick_toolsbool, default=False
Show buttons “copy location” and “draw geometry”.
- data_size_zoominint, default=0
Control how zooming-in of the map widget increases size of geometry objects (circles, lines etc.) on map when the size is set by means of mapping between the data and the size aesthetic. 0 - size never increases; -1 - size will be increasing without limits; n - a number of zooming-in steps (counting from the initial state of the map widget) when size of objects will be increasing. Farther zooming will no longer affect the size.
- const_size_zoominint, default=-1
Control how zooming-in of the map widget increases size of geometry objects (circles, lines etc.) on map when the size is not linked to a data (i.e. constant size). 0 - size never increases; -1 - size will be increasing without limits; n - a number of zooming-in steps (counting from the initial state of the map widget) when size of objects will be increasing. Farther zooming will no longer affect the size.
- other_args
Other arguments passed on to the layer.
- Returns:
- LayerSpec
Geom object specification.
Notes
geom_livemap() draws a map, which can be dragged and zoomed.
By default the livemap area has a non-zero inset. You can get rid of this with the theme: theme(plot_inset=0).
Examples
1from lets_plot import * 2LetsPlot.setup_html() 3ggplot() + geom_livemap()
1from lets_plot import * 2from lets_plot import tilesets 3LetsPlot.setup_html() 4data = { 5 'city': ['New York City', 'Prague'], 6 'lon': [-73.7997, 14.418540], 7 'lat': [40.6408, 50.073658], 8} 9ggplot(data, aes(x='lon', y='lat')) + \ 10 geom_livemap(projection='epsg4326', tiles=tilesets.LETS_PLOT_DARK) + \ 11 geom_path(color='white', geodesic=True) + \ 12 geom_point(color='white', tooltips=layer_tooltips().line('@city')) + \ 13 ggtitle("The shortest path between New York and Prague")