pub struct MapHandle { /* private fields */ }Expand description
A handle to a MapLibre map instance.
This is a lightweight Clone wrapper. Store it in a Signal<Option<MapHandle>>
and set it in the on_ready callback.
Implementations§
Source§impl MapHandle
impl MapHandle
Add a navigation control (zoom +/- buttons and compass)
Remove a navigation control.
Sourcepub fn add_geolocate_control(&self, position: ControlPosition)
pub fn add_geolocate_control(&self, position: ControlPosition)
Add a geolocate control.
Sourcepub fn remove_geolocate_control(&self, position: ControlPosition)
pub fn remove_geolocate_control(&self, position: ControlPosition)
Remove a geolocate control.
Sourcepub fn add_scale_control(&self, position: ControlPosition)
pub fn add_scale_control(&self, position: ControlPosition)
Add a scale control.
Sourcepub fn remove_scale_control(&self, position: ControlPosition)
pub fn remove_scale_control(&self, position: ControlPosition)
Remove a scale control.
Sourcepub fn add_fullscreen_control(&self, position: ControlPosition)
pub fn add_fullscreen_control(&self, position: ControlPosition)
Add a fullscreen control.
Sourcepub fn remove_fullscreen_control(&self, position: ControlPosition)
pub fn remove_fullscreen_control(&self, position: ControlPosition)
Remove a fullscreen control.
Sourcepub fn add_attribution_control(&self, position: ControlPosition)
pub fn add_attribution_control(&self, position: ControlPosition)
Add an attribution control.
Sourcepub fn remove_attribution_control(&self, position: ControlPosition)
pub fn remove_attribution_control(&self, position: ControlPosition)
Remove an attribution control.
Source§impl MapHandle
impl MapHandle
Sourcepub fn eval(&self, js_code: &str)
pub fn eval(&self, js_code: &str)
Execute arbitrary JavaScript against this map’s instance.
The JS code receives map as a variable referencing the MapLibre map object.
This is a fire-and-forget operation.
pub async fn eval_async<T: DeserializeOwned>(&self, _js_code: &str) -> Option<T>
Source§impl MapHandle
impl MapHandle
Sourcepub fn set_feature_state(&self, feature: &FeatureIdentifier, state: Value)
pub fn set_feature_state(&self, feature: &FeatureIdentifier, state: Value)
Set feature state for styling (hover effects, selection, etc.)
Sourcepub fn remove_feature_state(&self, feature: &FeatureIdentifier)
pub fn remove_feature_state(&self, feature: &FeatureIdentifier)
Remove all feature state
Source§impl MapHandle
impl MapHandle
Sourcepub fn load_image(&self, id: &str, url: &str)
pub fn load_image(&self, id: &str, url: &str)
Load an image from a URL and add it to the map’s sprite
Sourcepub async fn load_image_async(&self, _id: &str, _url: &str) -> bool
pub async fn load_image_async(&self, _id: &str, _url: &str) -> bool
Load an image and wait for it to complete (returns true on success)
Sourcepub fn remove_image(&self, id: &str)
pub fn remove_image(&self, id: &str)
Remove an image from the map’s sprite
Source§impl MapHandle
impl MapHandle
Sourcepub fn on_layer_click(&self, layer_id: &str)
pub fn on_layer_click(&self, layer_id: &str)
Register a click handler on a layer (events dispatched via on_layer_click).
Sourcepub fn off_layer_click(&self, layer_id: &str)
pub fn off_layer_click(&self, layer_id: &str)
Unregister a click handler on a layer.
Sourcepub fn on_layer_hover(&self, layer_id: &str)
pub fn on_layer_hover(&self, layer_id: &str)
Register hover handlers on a layer (events dispatched via on_layer_hover).
Sourcepub fn off_layer_hover(&self, layer_id: &str)
pub fn off_layer_hover(&self, layer_id: &str)
Unregister hover handlers on a layer.
Source§impl MapHandle
impl MapHandle
Sourcepub fn add_layer(&self, options: LayerOptions)
pub fn add_layer(&self, options: LayerOptions)
Add a layer to the map
Sourcepub fn remove_layer(&self, id: &str)
pub fn remove_layer(&self, id: &str)
Remove a layer from the map
Sourcepub fn set_paint_property(&self, layer_id: &str, name: &str, value: Value)
pub fn set_paint_property(&self, layer_id: &str, name: &str, value: Value)
Set a paint property on a layer
Sourcepub fn set_layout_property(&self, layer_id: &str, name: &str, value: Value)
pub fn set_layout_property(&self, layer_id: &str, name: &str, value: Value)
Set a layout property on a layer
Sourcepub fn move_layer(&self, layer_id: &str, before_id: Option<&str>)
pub fn move_layer(&self, layer_id: &str, before_id: Option<&str>)
Move a layer to a different position in the layer stack
If before_id is Some, the layer is moved before that layer.
If before_id is None, the layer is moved to the top.
Sourcepub fn set_filter(&self, layer_id: &str, filter: Value)
pub fn set_filter(&self, layer_id: &str, filter: Value)
Set a filter on a layer
Source§impl MapHandle
impl MapHandle
Sourcepub fn add_marker(&self, id: &str, position: LatLng, options: MarkerOptions)
pub fn add_marker(&self, id: &str, position: LatLng, options: MarkerOptions)
Add a marker at the given position
Sourcepub fn remove_marker(&self, id: &str)
pub fn remove_marker(&self, id: &str)
Remove a marker
Sourcepub fn update_marker_position(&self, id: &str, position: LatLng)
pub fn update_marker_position(&self, id: &str, position: LatLng)
Update a marker’s position
Source§impl MapHandle
impl MapHandle
Sourcepub fn fly_to(&self, options: FlyToOptions)
pub fn fly_to(&self, options: FlyToOptions)
Fly to a location with animation
Sourcepub fn ease_to(&self, options: EaseToOptions)
pub fn ease_to(&self, options: EaseToOptions)
Ease to a location with animation
Sourcepub fn jump_to(&self, options: JumpToOptions)
pub fn jump_to(&self, options: JumpToOptions)
Jump to a location instantly (no animation)
Sourcepub fn fit_bounds(&self, bounds: Bounds, options: FitBoundsOptions)
pub fn fit_bounds(&self, bounds: Bounds, options: FitBoundsOptions)
Fit the map to the given bounds
Sourcepub fn reset_north(&self)
pub fn reset_north(&self)
Reset bearing to north (0 degrees)
Sourcepub fn set_move_event_throttle(&self, throttle_ms: u32)
pub fn set_move_event_throttle(&self, throttle_ms: u32)
Set throttle for on_move events in milliseconds (0 = every animation frame)
Source§impl MapHandle
impl MapHandle
Sourcepub fn set_padding(&self, padding: Padding)
pub fn set_padding(&self, padding: Padding)
Set viewport padding
Sourcepub async fn get_padding(&self) -> Option<Padding>
pub async fn get_padding(&self) -> Option<Padding>
Get current viewport padding
Source§impl MapHandle
impl MapHandle
Sourcepub fn add_popup(
&self,
id: &str,
position: LatLng,
html: &str,
options: PopupOptions,
)
pub fn add_popup( &self, id: &str, position: LatLng, html: &str, options: PopupOptions, )
Add a standalone popup at a position
Sourcepub fn remove_popup(&self, id: &str)
pub fn remove_popup(&self, id: &str)
Remove a popup
Source§impl MapHandle
impl MapHandle
pub async fn query_rendered_features( &self, _options: QueryOptions, ) -> Vec<QueryFeature>
pub async fn query_rendered_features_at( &self, _point: Point, _options: QueryOptions, ) -> Vec<QueryFeature>
pub async fn query_source_features( &self, _source_id: &str, _options: QueryOptions, ) -> Vec<QueryFeature>
Source§impl MapHandle
impl MapHandle
Sourcepub fn add_geojson_source(&self, id: &str, options: GeoJsonSourceOptions)
pub fn add_geojson_source(&self, id: &str, options: GeoJsonSourceOptions)
Add a GeoJSON source to the map
Sourcepub fn add_vector_source(&self, id: &str, options: VectorSourceOptions)
pub fn add_vector_source(&self, id: &str, options: VectorSourceOptions)
Add a vector tile source to the map
Sourcepub fn add_raster_source(&self, id: &str, options: RasterSourceOptions)
pub fn add_raster_source(&self, id: &str, options: RasterSourceOptions)
Add a raster tile source to the map
Sourcepub fn add_raster_dem_source(&self, id: &str, options: RasterDemSourceOptions)
pub fn add_raster_dem_source(&self, id: &str, options: RasterDemSourceOptions)
Add a raster DEM source (for terrain)
Sourcepub fn add_image_source(&self, id: &str, options: ImageSourceOptions)
pub fn add_image_source(&self, id: &str, options: ImageSourceOptions)
Add an image source to the map
Sourcepub fn update_geojson_source(&self, id: &str, data: Value)
pub fn update_geojson_source(&self, id: &str, data: Value)
Update the data of an existing GeoJSON source
Sourcepub fn remove_source(&self, id: &str)
pub fn remove_source(&self, id: &str)
Remove a source from the map
Source§impl MapHandle
impl MapHandle
Sourcepub fn set_terrain(&self, options: TerrainOptions)
pub fn set_terrain(&self, options: TerrainOptions)
Enable 3D terrain
Sourcepub fn remove_terrain(&self)
pub fn remove_terrain(&self)
Remove 3D terrain
Sourcepub fn set_sky(&self, options: SkyOptions)
pub fn set_sky(&self, options: SkyOptions)
Set sky properties
Sourcepub fn remove_sky(&self)
pub fn remove_sky(&self)
Remove sky
Sourcepub fn set_fog(&self, options: FogOptions)
pub fn set_fog(&self, options: FogOptions)
Set fog/atmosphere properties
Sourcepub fn remove_fog(&self)
pub fn remove_fog(&self)
Remove fog/atmosphere