Skip to main content

MapHandle

Struct MapHandle 

Source
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

Source

pub fn add_navigation_control(&self, position: ControlPosition)

Add a navigation control (zoom +/- buttons and compass)

Source

pub fn remove_navigation_control(&self, position: ControlPosition)

Remove a navigation control.

Source

pub fn add_geolocate_control(&self, position: ControlPosition)

Add a geolocate control.

Source

pub fn remove_geolocate_control(&self, position: ControlPosition)

Remove a geolocate control.

Source

pub fn add_scale_control(&self, position: ControlPosition)

Add a scale control.

Source

pub fn remove_scale_control(&self, position: ControlPosition)

Remove a scale control.

Source

pub fn add_fullscreen_control(&self, position: ControlPosition)

Add a fullscreen control.

Source

pub fn remove_fullscreen_control(&self, position: ControlPosition)

Remove a fullscreen control.

Source

pub fn add_attribution_control(&self, position: ControlPosition)

Add an attribution control.

Source

pub fn remove_attribution_control(&self, position: ControlPosition)

Remove an attribution control.

Source§

impl MapHandle

Source

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.

Source

pub async fn eval_async<T: DeserializeOwned>(&self, _js_code: &str) -> Option<T>

Source§

impl MapHandle

Source

pub fn set_feature_state(&self, feature: &FeatureIdentifier, state: Value)

Set feature state for styling (hover effects, selection, etc.)

Source

pub fn remove_feature_state(&self, feature: &FeatureIdentifier)

Remove all feature state

Source§

impl MapHandle

Source

pub async fn get_zoom(&self) -> Option<f64>

Source

pub async fn get_center(&self) -> Option<LatLng>

Source

pub async fn get_bearing(&self) -> Option<f64>

Source

pub async fn get_pitch(&self) -> Option<f64>

Source

pub async fn get_bounds(&self) -> Option<Bounds>

Source§

impl MapHandle

Source

pub fn load_image(&self, id: &str, url: &str)

Load an image from a URL and add it to the map’s sprite

Source

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)

Source

pub async fn has_image(&self, _id: &str) -> bool

Check if an image exists in the map’s sprite

Source

pub fn remove_image(&self, id: &str)

Remove an image from the map’s sprite

Source§

impl MapHandle

Source

pub fn on_layer_click(&self, layer_id: &str)

Register a click handler on a layer (events dispatched via on_layer_click).

Source

pub fn off_layer_click(&self, layer_id: &str)

Unregister a click handler on a layer.

Source

pub fn on_layer_hover(&self, layer_id: &str)

Register hover handlers on a layer (events dispatched via on_layer_hover).

Source

pub fn off_layer_hover(&self, layer_id: &str)

Unregister hover handlers on a layer.

Source§

impl MapHandle

Source

pub fn add_layer(&self, options: LayerOptions)

Add a layer to the map

Source

pub fn remove_layer(&self, id: &str)

Remove a layer from the map

Source

pub fn set_paint_property(&self, layer_id: &str, name: &str, value: Value)

Set a paint property on a layer

Source

pub fn set_layout_property(&self, layer_id: &str, name: &str, value: Value)

Set a layout property on a layer

Source

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.

Source

pub fn set_filter(&self, layer_id: &str, filter: Value)

Set a filter on a layer

Source§

impl MapHandle

Source

pub fn add_marker(&self, id: &str, position: LatLng, options: MarkerOptions)

Add a marker at the given position

Source

pub fn remove_marker(&self, id: &str)

Remove a marker

Source

pub fn update_marker_position(&self, id: &str, position: LatLng)

Update a marker’s position

Source§

impl MapHandle

Source

pub fn fly_to(&self, options: FlyToOptions)

Fly to a location with animation

Source

pub fn ease_to(&self, options: EaseToOptions)

Ease to a location with animation

Source

pub fn jump_to(&self, options: JumpToOptions)

Jump to a location instantly (no animation)

Source

pub fn fit_bounds(&self, bounds: Bounds, options: FitBoundsOptions)

Fit the map to the given bounds

Source

pub fn pan_to(&self, position: LatLng)

Pan to a coordinate

Source

pub fn pan_by(&self, x: i32, y: i32)

Pan by pixel offset (instant, no animation)

Source

pub fn zoom_to(&self, zoom: f64)

Set zoom level

Source

pub fn zoom_in(&self)

Zoom in one level

Source

pub fn zoom_out(&self)

Zoom out one level

Source

pub fn rotate_to(&self, bearing: f64)

Set bearing (rotation)

Source

pub fn set_pitch(&self, pitch: f64)

Set pitch (tilt)

Source

pub fn reset_north(&self)

Reset bearing to north (0 degrees)

Source

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

Source

pub fn set_padding(&self, padding: Padding)

Set viewport padding

Source

pub async fn get_padding(&self) -> Option<Padding>

Get current viewport padding

Source§

impl MapHandle

Source

pub fn add_popup( &self, id: &str, position: LatLng, html: &str, options: PopupOptions, )

Add a standalone popup at a position

Source

pub fn remove_popup(&self, id: &str)

Remove a popup

Source§

impl MapHandle

Source

pub async fn query_rendered_features( &self, _options: QueryOptions, ) -> Vec<QueryFeature>

Source

pub async fn query_rendered_features_at( &self, _point: Point, _options: QueryOptions, ) -> Vec<QueryFeature>

Source

pub async fn query_source_features( &self, _source_id: &str, _options: QueryOptions, ) -> Vec<QueryFeature>

Source§

impl MapHandle

Source

pub fn add_geojson_source(&self, id: &str, options: GeoJsonSourceOptions)

Add a GeoJSON source to the map

Source

pub fn add_vector_source(&self, id: &str, options: VectorSourceOptions)

Add a vector tile source to the map

Source

pub fn add_raster_source(&self, id: &str, options: RasterSourceOptions)

Add a raster tile source to the map

Source

pub fn add_raster_dem_source(&self, id: &str, options: RasterDemSourceOptions)

Add a raster DEM source (for terrain)

Source

pub fn add_image_source(&self, id: &str, options: ImageSourceOptions)

Add an image source to the map

Source

pub fn update_geojson_source(&self, id: &str, data: Value)

Update the data of an existing GeoJSON source

Source

pub fn remove_source(&self, id: &str)

Remove a source from the map

Source§

impl MapHandle

Source

pub fn set_style(&self, url: &str)

Change the map’s style URL

Source§

impl MapHandle

Source

pub fn set_terrain(&self, options: TerrainOptions)

Enable 3D terrain

Source

pub fn remove_terrain(&self)

Remove 3D terrain

Source

pub fn set_sky(&self, options: SkyOptions)

Set sky properties

Source

pub fn remove_sky(&self)

Remove sky

Source

pub fn set_fog(&self, options: FogOptions)

Set fog/atmosphere properties

Source

pub fn remove_fog(&self)

Remove fog/atmosphere

Source§

impl MapHandle

Source

pub fn map_id(&self) -> &str

Get the internal map ID (useful for debugging).

Trait Implementations§

Source§

impl Clone for MapHandle

Source§

fn clone(&self) -> MapHandle

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for MapHandle

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for MapHandle

Source§

fn eq(&self, other: &MapHandle) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for MapHandle

Source§

impl StructuralPartialEq for MapHandle

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> InitializeFromFunction<T> for T

Source§

fn initialize_from_function(f: fn() -> T) -> T

Create an instance of this type from an initialization function
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<Ret> SpawnIfAsync<(), Ret> for Ret

Source§

fn spawn(self) -> Ret

Spawn the value into the dioxus runtime if it is an async block
Source§

impl<T, O> SuperFrom<T> for O
where O: From<T>,

Source§

fn super_from(input: T) -> O

Convert from a type to another type.
Source§

impl<T, O, M> SuperInto<O, M> for T
where O: SuperFrom<T, M>,

Source§

fn super_into(self) -> O

Convert from a type to another type.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> DependencyElement for T
where T: 'static + PartialEq + Clone,