pub struct MapState { /* private fields */ }Expand description
The central state object consumed by renderers each frame.
Owns the camera, layer stack, terrain manager, camera animator, and all per-frame derived data (zoom level, viewport bounds, frustum, mesh caches).
§Field visibility
All fields are private. Use accessor methods for reads and targeted setters for writes:
| Need | Method |
|---|---|
| Read camera | camera() |
| Set viewport size | set_viewport |
| Set camera target | set_camera_target |
| Set camera distance | set_camera_distance |
| Set camera pitch/yaw | set_camera_pitch, set_camera_yaw |
| Toggle projection | set_camera_mode |
| Set camera FOV | set_camera_fov_y |
| Read constraints | constraints() |
| Set max pitch | set_max_pitch |
| Add a layer | push_layer |
| Read layers | layers() |
| Read vector meshes | vector_meshes() |
| Read model instances | model_instances() |
| Dispatch input | handle_input |
| Animate camera | fly_to |
| Check animator | animator() |
| Replace terrain | set_terrain |
| Read terrain state | terrain() |
Implementations§
Source§impl MapState
impl MapState
Sourcepub fn style_source_is_used(&self, source_id: &str) -> bool
pub fn style_source_is_used(&self, source_id: &str) -> bool
Return true if the attached style currently uses the given source id.
Sourcepub fn style_layer_ids_using_source(&self, source_id: &str) -> Vec<&str>
pub fn style_layer_ids_using_source(&self, source_id: &str) -> Vec<&str>
Return the ordered style layer ids that currently reference the given source id.
Sourcepub fn reload_style_source(
&mut self,
source_id: impl Into<String>,
source: StyleSource,
) -> Result<bool, StyleError>
pub fn reload_style_source( &mut self, source_id: impl Into<String>, source: StyleSource, ) -> Result<bool, StyleError>
Replace a source in the attached style document and re-apply the style.
Sourcepub fn clear_style_source(
&mut self,
source_id: &str,
) -> Result<Option<StyleSource>, StyleError>
pub fn clear_style_source( &mut self, source_id: &str, ) -> Result<Option<StyleSource>, StyleError>
Remove a source from the attached style document and re-apply the style.
Source§impl MapState
impl MapState
Sourcepub fn pick(&self, query: PickQuery, options: PickOptions) -> PickResult
pub fn pick(&self, query: PickQuery, options: PickOptions) -> PickResult
Execute a pick operation against the current map state.
Sourcepub fn pick_at_screen(&self, x: f64, y: f64, options: PickOptions) -> PickResult
pub fn pick_at_screen(&self, x: f64, y: f64, options: PickOptions) -> PickResult
Pick using logical screen-space coordinates relative to the viewport.
This is a convenience wrapper around Self::pick for the common
cursor-driven interaction path used by hover and click handling.
Sourcepub fn pick_at_geo(&self, coord: GeoCoord, options: PickOptions) -> PickResult
pub fn pick_at_geo(&self, coord: GeoCoord, options: PickOptions) -> PickResult
Pick using a geographic coordinate.
This is a convenience wrapper around Self::pick for workflows that
already resolved the target point in geospatial coordinates.
Sourcepub fn pick_along_ray(
&self,
origin: DVec3,
direction: DVec3,
options: PickOptions,
) -> PickResult
pub fn pick_along_ray( &self, origin: DVec3, direction: DVec3, options: PickOptions, ) -> PickResult
Pick along a world-space ray in the active scene projection.
This is a convenience wrapper around Self::pick for renderers or
host integrations that already computed a world-space interaction ray.
Sourcepub fn query_rendered_features(
&self,
query: PickQuery,
options: QueryOptions,
) -> Vec<QueriedFeature>
pub fn query_rendered_features( &self, query: PickQuery, options: QueryOptions, ) -> Vec<QueriedFeature>
Query rendered vector features near the given query position.
Sourcepub fn query_rendered_features_at_screen(
&self,
x: f64,
y: f64,
options: QueryOptions,
) -> Vec<QueriedFeature>
pub fn query_rendered_features_at_screen( &self, x: f64, y: f64, options: QueryOptions, ) -> Vec<QueriedFeature>
Query rendered features at a logical screen-space coordinate.
This is the convenience wrapper for cursor-driven workflows that already operate in viewport pixel coordinates.
Sourcepub fn query_rendered_features_at_geo(
&self,
coord: GeoCoord,
options: QueryOptions,
) -> Vec<QueriedFeature>
pub fn query_rendered_features_at_geo( &self, coord: GeoCoord, options: QueryOptions, ) -> Vec<QueriedFeature>
Query rendered features at a geographic coordinate.
This is the convenience wrapper for callers that already resolved the interaction point in geospatial coordinates.
Sourcepub fn query_rendered_features_along_ray(
&self,
origin: DVec3,
direction: DVec3,
options: QueryOptions,
) -> Vec<QueriedFeature>
pub fn query_rendered_features_along_ray( &self, origin: DVec3, direction: DVec3, options: QueryOptions, ) -> Vec<QueriedFeature>
Query rendered features along a world-space ray.
This is the convenience wrapper for renderer integrations that already computed a world-space interaction ray and want the standard rendered feature query behavior.
Sourcepub fn query_rendered_features_in_box(
&self,
x1: f64,
y1: f64,
x2: f64,
y2: f64,
options: QueryOptions,
) -> Vec<QueriedFeature>
pub fn query_rendered_features_in_box( &self, x1: f64, y1: f64, x2: f64, y2: f64, options: QueryOptions, ) -> Vec<QueriedFeature>
Query rendered vector features whose geometry intersects a screen-space rectangle defined by two corner points.
The two corners are resolved to geographic coordinates via the current camera projection and then all visible features whose geometry overlaps the resulting bounding box are returned.
This is the Rustial equivalent of the Mapbox / MapLibre
queryRenderedFeatures([sw, ne]) overload that accepts a bounding box
instead of a single point.
§Arguments
x1,y1– first corner in logical viewport pixels.x2,y2– second corner in logical viewport pixels.options– layer/source filtering and tolerance controls.
§Sorting
Results are sorted by layer-stack order (top-most layer first) and de-duplicated so the same feature is not returned twice from overlapping streamed tiles.
Sourcepub fn query_source_features(
&self,
source_id: &str,
source_layer: Option<&str>,
) -> Vec<QueriedFeature>
pub fn query_source_features( &self, source_id: &str, source_layer: Option<&str>, ) -> Vec<QueriedFeature>
Query currently loaded features for a style source.
Source§impl MapState
impl MapState
Sourcepub fn update_terrain(&mut self)
pub fn update_terrain(&mut self)
Run just the terrain update (used by tests and manual pipelines).
Source§impl MapState
impl MapState
Sourcepub fn with_terrain(
terrain_config: TerrainConfig,
terrain_cache_size: usize,
) -> Self
pub fn with_terrain( terrain_config: TerrainConfig, terrain_cache_size: usize, ) -> Self
Create a map state with terrain support.
§Arguments
terrain_config– Terrain settings (enabled flag, mesh resolution, elevation source, vertical exaggeration, skirt depth).terrain_cache_size– Maximum number of elevation grids to keep in the LRU cache.
Sourcepub fn zoom_level(&self) -> u8
pub fn zoom_level(&self) -> u8
Current integer zoom level (0-22).
Derived from Camera::meters_per_pixel during update.
Returns 0 before the first update.
Sourcepub fn fractional_zoom(&self) -> f64
pub fn fractional_zoom(&self) -> f64
Continuous fractional zoom level (e.g. 8.73).
Derived from Camera::near_meters_per_pixel using the same
formula as zoom_level, but without rounding
to an integer. Useful for debug displays and smooth zoom
interpolation.
Sourcepub fn viewport_bounds(&self) -> &WorldBounds
pub fn viewport_bounds(&self) -> &WorldBounds
Viewport bounding box in Web Mercator world space from the last
update.
Includes an overscan margin for tile prefetching.
Sourcepub fn camera_velocity_config(&self) -> &CameraVelocityConfig
pub fn camera_velocity_config(&self) -> &CameraVelocityConfig
Read-only access to the camera-motion prediction configuration.
Sourcepub fn set_camera_velocity_config(&mut self, config: CameraVelocityConfig)
pub fn set_camera_velocity_config(&mut self, config: CameraVelocityConfig)
Replace the camera-motion prediction configuration.
Sourcepub fn camera_motion_state(&self) -> &CameraMotionState
pub fn camera_motion_state(&self) -> &CameraMotionState
Smoothed camera pan velocity and translated viewport prediction.
Sourcepub fn predicted_viewport_bounds(&self) -> &WorldBounds
pub fn predicted_viewport_bounds(&self) -> &WorldBounds
Predicted viewport bounds after the configured look-ahead interval.
Sourcepub fn scene_viewport_bounds(&self) -> &WorldBounds
pub fn scene_viewport_bounds(&self) -> &WorldBounds
Viewport bounding box in the active planar scene projection.
Sourcepub fn frustum(&self) -> Option<&Frustum>
pub fn frustum(&self) -> Option<&Frustum>
View frustum from the last update.
None only before the first update() call.
Sourcepub fn renderer_world_origin(&self) -> DVec3
pub fn renderer_world_origin(&self) -> DVec3
Renderer/world origin used by the current render compatibility path.
This remains Web Mercator backed for the current raster/terrain stack, even when the camera itself uses a different planar projection.
Sourcepub fn scene_world_origin(&self) -> DVec3
pub fn scene_world_origin(&self) -> DVec3
Active scene origin in the camera’s currently selected planar projection.
Projection-specialized geometry paths such as terrain, vectors, symbols, models, and Bevy geo-entities should use this origin so their world coordinates remain aligned under non-Mercator planar projections.
Sourcepub fn terrain_meshes(&self) -> &[TerrainMeshData]
pub fn terrain_meshes(&self) -> &[TerrainMeshData]
Terrain meshes produced during the last update.
Empty when terrain is disabled or no elevation data is cached.
Sourcepub fn hillshade_rasters(&self) -> &[PreparedHillshadeRaster]
pub fn hillshade_rasters(&self) -> &[PreparedHillshadeRaster]
Prepared DEM-derived hillshade rasters from the last update.
Sourcepub fn visible_tiles(&self) -> &[VisibleTile]
pub fn visible_tiles(&self) -> &[VisibleTile]
Visible tiles from the last update.
Sourcepub fn loading_placeholders(&self) -> &[LoadingPlaceholder]
pub fn loading_placeholders(&self) -> &[LoadingPlaceholder]
Loading placeholders from the last update.
One entry per visible tile that has no data yet. Empty when all visible tiles are loaded.
Sourcepub fn placeholder_style(&self) -> &PlaceholderStyle
pub fn placeholder_style(&self) -> &PlaceholderStyle
Active placeholder style.
Sourcepub fn set_placeholder_style(&mut self, style: PlaceholderStyle)
pub fn set_placeholder_style(&mut self, style: PlaceholderStyle)
Replace the placeholder style.
Sourcepub fn coordinator_stats(&self) -> &CoordinatorStats
pub fn coordinator_stats(&self) -> &CoordinatorStats
Read-only access to the cross-source tile request coordinator’s most recent diagnostics.
Sourcepub fn coordinator_config(&self) -> &CoordinatorConfig
pub fn coordinator_config(&self) -> &CoordinatorConfig
Read-only access to the cross-source coordinator configuration.
Sourcepub fn set_coordinator_config(&mut self, config: CoordinatorConfig)
pub fn set_coordinator_config(&mut self, config: CoordinatorConfig)
Replace the cross-source coordinator configuration.
Takes effect on the next frame. Set global_request_budget to
0 to disable coordination entirely.
Sourcepub fn set_prefetch_route(&mut self, route: Vec<GeoCoord>)
pub fn set_prefetch_route(&mut self, route: Vec<GeoCoord>)
Set an optional navigation route for route-aware tile prefetch.
When set, the tile update loop will speculatively prefetch tiles along the route ahead of the current camera position, spending remaining speculative budget after viewport-prediction and zoom-direction prefetch.
The route should be a polyline of geographic coordinates ordered
from origin to destination. Pass an empty slice or call
clear_prefetch_route to disable.
Sourcepub fn clear_prefetch_route(&mut self)
pub fn clear_prefetch_route(&mut self)
Clear the navigation route used for route-aware tile prefetch.
Sourcepub fn prefetch_route(&self) -> Option<&[GeoCoord]>
pub fn prefetch_route(&self) -> Option<&[GeoCoord]>
Read-only access to the active prefetch route, if any.
Sourcepub fn tile_pipeline_diagnostics(&self) -> Option<TilePipelineDiagnostics>
pub fn tile_pipeline_diagnostics(&self) -> Option<TilePipelineDiagnostics>
Return a diagnostics snapshot for the first visible tile layer, if any.
Sourcepub fn tile_lifecycle_diagnostics(&self) -> Option<TileLifecycleDiagnostics>
pub fn tile_lifecycle_diagnostics(&self) -> Option<TileLifecycleDiagnostics>
Return recent tile lifecycle diagnostics for the first visible tile layer, if any.
Sourcepub fn background_color(&self) -> Option<[f32; 4]>
pub fn background_color(&self) -> Option<[f32; 4]>
Return the effective background Colour from the top-most visible
BackgroundLayer, if any.
This gives renderers a backend-owned clear colour similar to MapLibre’s background layer instead of relying only on hard-coded renderer defaults.
Sourcepub fn hillshade(&self) -> Option<HillshadeParams>
pub fn hillshade(&self) -> Option<HillshadeParams>
Return the effective hillshade parameters from the top-most visible
HillshadeLayer, if any.
Sourcepub fn set_fog(&mut self, config: Option<FogConfig>)
pub fn set_fog(&mut self, config: Option<FogConfig>)
Set the fog/atmosphere configuration override.
When set, the provided FogConfig values
override the automatic pitch-based fog computation. None fields
in the config fall back to the auto-computed defaults.
Pass None to revert to fully automatic fog.
Sourcepub fn computed_fog(&self) -> &ComputedFog
pub fn computed_fog(&self) -> &ComputedFog
Sourcepub fn set_lights(&mut self, config: Option<LightConfig>)
pub fn set_lights(&mut self, config: Option<LightConfig>)
Set the lighting configuration override.
When set, the provided LightConfig
values override the style document’s "lights" configuration and
the engine defaults.
Pass None to revert to the style document’s or default lighting.
Sourcepub fn lights(&self) -> Option<&LightConfig>
pub fn lights(&self) -> Option<&LightConfig>
Return the current lighting configuration override, if any.
Sourcepub fn computed_lighting(&self) -> &ComputedLighting
pub fn computed_lighting(&self) -> &ComputedLighting
Return the pre-computed lighting parameters for the current frame.
Recomputed each frame during update().
Renderers should read these values directly instead of hardcoding
light directions.
Sourcepub fn computed_shadow(&self) -> &ComputedShadow
pub fn computed_shadow(&self) -> &ComputedShadow
Return the pre-computed shadow cascade parameters for the current frame.
ComputedShadow::enabled is
true only when the directional light has cast_shadows = true and
lighting is not in flat mode.
Sourcepub fn set_sky(&mut self, config: Option<SkyConfig>)
pub fn set_sky(&mut self, config: Option<SkyConfig>)
Set the sky / atmosphere configuration override.
When set, the provided SkyConfig
enables a procedural sky background. Pass None to disable.
Sourcepub fn computed_sky(&self) -> &ComputedSky
pub fn computed_sky(&self) -> &ComputedSky
Return the pre-computed sky parameters for the current frame.
Recomputed each frame during update().
Sourcepub fn style_time(&self) -> f64
pub fn style_time(&self) -> f64
Current monotonic style time (seconds), used for transition interpolation.
Sourcepub fn layer_transitions(&self) -> &HashMap<StyleLayerId, LayerTransitionState>
pub fn layer_transitions(&self) -> &HashMap<StyleLayerId, LayerTransitionState>
Per-layer transition state map.
Sourcepub fn resolved_transitions(
&self,
layer_id: &str,
) -> Option<ResolvedTransitions>
pub fn resolved_transitions( &self, layer_id: &str, ) -> Option<ResolvedTransitions>
Resolve current transitioned property values for a layer.
Returns None if no transition state has been recorded for the
given layer yet.
Sourcepub fn set_visible_tiles(&mut self, tiles: Vec<VisibleTile>)
pub fn set_visible_tiles(&mut self, tiles: Vec<VisibleTile>)
Override the visible tile set for this frame.
Sourcepub fn set_terrain_meshes(&mut self, meshes: Vec<TerrainMeshData>)
pub fn set_terrain_meshes(&mut self, meshes: Vec<TerrainMeshData>)
Override the terrain meshes for this frame (useful for testing).
Sourcepub fn set_hillshade_rasters(&mut self, rasters: Vec<PreparedHillshadeRaster>)
pub fn set_hillshade_rasters(&mut self, rasters: Vec<PreparedHillshadeRaster>)
Override the prepared hillshade rasters for this frame (useful for testing).
Sourcepub fn set_viewport(&mut self, width: u32, height: u32)
pub fn set_viewport(&mut self, width: u32, height: u32)
Set the camera viewport dimensions (logical pixels).
Sourcepub fn set_camera_target(&mut self, target: GeoCoord)
pub fn set_camera_target(&mut self, target: GeoCoord)
Set the camera target geographic coordinate.
Longitude is normalized to [-180, 180) to prevent the camera
from drifting into a different world copy, which would cause
tile selection to diverge and tiles to stop rendering.
Sourcepub fn set_camera_distance(&mut self, distance: f64)
pub fn set_camera_distance(&mut self, distance: f64)
Set the camera distance from the target in meters.
Sourcepub fn set_camera_pitch(&mut self, pitch: f64)
pub fn set_camera_pitch(&mut self, pitch: f64)
Set the camera pitch in radians.
Sourcepub fn set_camera_yaw(&mut self, yaw: f64)
pub fn set_camera_yaw(&mut self, yaw: f64)
Set the camera yaw / bearing in radians.
Sourcepub fn set_camera_mode(&mut self, mode: CameraMode)
pub fn set_camera_mode(&mut self, mode: CameraMode)
Set the camera projection mode (perspective / orthographic).
Sourcepub fn set_camera_projection(&mut self, projection: CameraProjection)
pub fn set_camera_projection(&mut self, projection: CameraProjection)
Set the camera geographic projection used by camera/world helpers.
Sourcepub fn set_camera_fov_y(&mut self, fov_y: f64)
pub fn set_camera_fov_y(&mut self, fov_y: f64)
Set the vertical field-of-view in radians (perspective mode).
Sourcepub fn constraints(&self) -> &CameraConstraints
pub fn constraints(&self) -> &CameraConstraints
Immutable reference to the camera constraints.
Sourcepub fn set_max_pitch(&mut self, max_pitch: f64)
pub fn set_max_pitch(&mut self, max_pitch: f64)
Set the maximum camera pitch in radians.
Sourcepub fn set_min_distance(&mut self, min_distance: f64)
pub fn set_min_distance(&mut self, min_distance: f64)
Set the minimum camera distance in meters.
Sourcepub fn set_max_distance(&mut self, max_distance: f64)
pub fn set_max_distance(&mut self, max_distance: f64)
Set the maximum camera distance in meters.
Sourcepub fn layers(&self) -> &LayerStack
pub fn layers(&self) -> &LayerStack
Immutable reference to the layer stack.
Sourcepub fn push_layer(&mut self, layer: Box<dyn Layer>)
pub fn push_layer(&mut self, layer: Box<dyn Layer>)
Add a layer to the top of the stack.
Sourcepub fn set_grid_scalar(
&mut self,
name: impl Into<String>,
grid: GeoGrid,
field: ScalarField2D,
ramp: ColorRamp,
)
pub fn set_grid_scalar( &mut self, name: impl Into<String>, grid: GeoGrid, field: ScalarField2D, ramp: ColorRamp, )
Insert or replace a named grid-scalar visualization layer.
Sourcepub fn set_grid_extrusion(
&mut self,
name: impl Into<String>,
grid: GeoGrid,
field: ScalarField2D,
ramp: ColorRamp,
params: ExtrusionParams,
)
pub fn set_grid_extrusion( &mut self, name: impl Into<String>, grid: GeoGrid, field: ScalarField2D, ramp: ColorRamp, params: ExtrusionParams, )
Insert or replace a named grid-extrusion visualization layer.
Sourcepub fn set_instanced_columns(
&mut self,
name: impl Into<String>,
columns: ColumnInstanceSet,
ramp: ColorRamp,
)
pub fn set_instanced_columns( &mut self, name: impl Into<String>, columns: ColumnInstanceSet, ramp: ColorRamp, )
Insert or replace a named instanced-column visualization layer.
Sourcepub fn set_point_cloud(
&mut self,
name: impl Into<String>,
points: PointInstanceSet,
ramp: ColorRamp,
)
pub fn set_point_cloud( &mut self, name: impl Into<String>, points: PointInstanceSet, ramp: ColorRamp, )
Insert or replace a named point-cloud visualization layer.
Sourcepub fn style_document(&self) -> Option<&StyleDocument>
pub fn style_document(&self) -> Option<&StyleDocument>
Return the currently attached style document, if any.
Sourcepub fn set_style(&mut self, style: MapStyle) -> Result<(), StyleError>
pub fn set_style(&mut self, style: MapStyle) -> Result<(), StyleError>
Replace the current style runtime and re-evaluate terrain + layer state.
Sourcepub fn set_style_document(
&mut self,
document: StyleDocument,
) -> Result<(), StyleError>
pub fn set_style_document( &mut self, document: StyleDocument, ) -> Result<(), StyleError>
Replace the current style document and re-evaluate terrain + layer state.
Sourcepub fn with_style_mut<R>(
&mut self,
mutate: impl FnOnce(&mut StyleDocument) -> R,
) -> Result<Option<R>, StyleError>
pub fn with_style_mut<R>( &mut self, mutate: impl FnOnce(&mut StyleDocument) -> R, ) -> Result<Option<R>, StyleError>
Mutate the current style document in place and then re-apply it.
Sourcepub fn reapply_style(&mut self) -> Result<bool, StyleError>
pub fn reapply_style(&mut self) -> Result<bool, StyleError>
Re-evaluate the currently attached style document, if any.
Sourcepub fn terrain(&self) -> &TerrainManager
pub fn terrain(&self) -> &TerrainManager
Immutable reference to the terrain manager.
Sourcepub fn set_terrain(&mut self, terrain: TerrainManager)
pub fn set_terrain(&mut self, terrain: TerrainManager)
Replace the terrain manager with a new configuration.
Sourcepub fn animator(&self) -> &CameraAnimator
pub fn animator(&self) -> &CameraAnimator
Immutable reference to the camera animator.
Sourcepub fn is_animating(&self) -> bool
pub fn is_animating(&self) -> bool
Whether any camera animation is currently active.
Sourcepub fn set_data_update_interval(&mut self, interval: f64)
pub fn set_data_update_interval(&mut self, interval: f64)
Set the minimum interval (seconds) between full terrain + layer updates while a coordinated camera animation is active.
Sourcepub fn data_update_interval(&self) -> f64
pub fn data_update_interval(&self) -> f64
Current data-update throttle interval in seconds.
Sourcepub fn set_task_pool(&mut self, pool: Arc<dyn DataTaskPool>)
pub fn set_task_pool(&mut self, pool: Arc<dyn DataTaskPool>)
Inject an async task pool for offloading heavy data pipeline work.
Sourcepub fn clear_task_pool(&mut self)
pub fn clear_task_pool(&mut self)
Remove the async task pool, reverting to synchronous execution.
Sourcepub fn has_async_pipeline(&self) -> bool
pub fn has_async_pipeline(&self) -> bool
Whether an async task pool is currently active.
Sourcepub fn vector_meshes(&self) -> &[VectorMeshData]
pub fn vector_meshes(&self) -> &[VectorMeshData]
Tessellated vector meshes from the last update.
Sourcepub fn model_instances(&self) -> &[ModelInstance]
pub fn model_instances(&self) -> &[ModelInstance]
3D model instances from the last update.
Sourcepub fn placed_symbols(&self) -> &[PlacedSymbol]
pub fn placed_symbols(&self) -> &[PlacedSymbol]
Placed symbols from the last update.
Sourcepub fn symbol_assets(&self) -> &SymbolAssetRegistry
pub fn symbol_assets(&self) -> &SymbolAssetRegistry
Symbol asset dependency state for the last update.
Sourcepub fn feature_state(
&self,
source_id: &str,
feature_id: &str,
) -> Option<&FeatureState>
pub fn feature_state( &self, source_id: &str, feature_id: &str, ) -> Option<&FeatureState>
Look up feature state for a source-local feature id.
Sourcepub fn set_feature_state(
&mut self,
source_id: impl Into<String>,
feature_id: impl Into<String>,
state: FeatureState,
)
pub fn set_feature_state( &mut self, source_id: impl Into<String>, feature_id: impl Into<String>, state: FeatureState, )
Replace feature state for a source-local feature id.
Sourcepub fn set_feature_state_property(
&mut self,
source_id: impl Into<String>,
feature_id: impl Into<String>,
key: impl Into<String>,
value: PropertyValue,
)
pub fn set_feature_state_property( &mut self, source_id: impl Into<String>, feature_id: impl Into<String>, key: impl Into<String>, value: PropertyValue, )
Set a single feature-state property.
Sourcepub fn remove_feature_state(
&mut self,
source_id: &str,
feature_id: &str,
) -> Option<FeatureState>
pub fn remove_feature_state( &mut self, source_id: &str, feature_id: &str, ) -> Option<FeatureState>
Remove feature state for a source-local feature id.
Sourcepub fn clear_feature_state(&mut self)
pub fn clear_feature_state(&mut self)
Clear all stored feature state.
Sourcepub fn resolve_feature_style(
&self,
style_layer_id: &str,
source_id: &str,
feature_id: &str,
) -> Option<VectorStyle>
pub fn resolve_feature_style( &self, style_layer_id: &str, source_id: &str, feature_id: &str, ) -> Option<VectorStyle>
Resolve a style layer’s paint properties for a specific feature’s current state.
This is the primary convenience method for hover/selection restyling:
it looks up the named style layer, retrieves the feature’s current
state from the internal store, and evaluates all paint properties
through the [StyleEvalContextFull] path.
Returns None when:
- no style document is attached
- the layer id does not exist in the style document
- the layer type does not produce a
VectorStyle(background, hillshade, raster, model)
§Example
map.set_feature_state_property("source", "feat-42", "hover", PropertyValue::Bool(true));
if let Some(style) = map.resolve_feature_style("buildings", "source", "feat-42") {
// `style` has paint values resolved with hover=true.
}Sourcepub fn set_interaction_manager(&mut self, manager: InteractionManager)
pub fn set_interaction_manager(&mut self, manager: InteractionManager)
Attach an interaction manager for automatic hover/leave/click lifecycle.
Once set, the host feeds raw pointer events into the manager (via
interaction_manager_mut) and drains
high-level InteractionEvents each frame.
Sourcepub fn take_interaction_manager(&mut self) -> Option<InteractionManager>
pub fn take_interaction_manager(&mut self) -> Option<InteractionManager>
Remove the attached interaction manager, returning it if present.
Sourcepub fn interaction_manager(&self) -> Option<&InteractionManager>
pub fn interaction_manager(&self) -> Option<&InteractionManager>
Read-only access to the attached interaction manager.
Sourcepub fn interaction_manager_mut(&mut self) -> Option<&mut InteractionManager>
pub fn interaction_manager_mut(&mut self) -> Option<&mut InteractionManager>
Mutable access to the attached interaction manager.
Use this to feed pointer events and drain emitted interaction events.
Sourcepub fn on<F>(&mut self, kind: InteractionEventKind, callback: F) -> ListenerId
pub fn on<F>(&mut self, kind: InteractionEventKind, callback: F) -> ListenerId
Subscribe to interaction events of a given kind.
Returns a ListenerId for
later removal via off.
Sourcepub fn once<F>(&mut self, kind: InteractionEventKind, callback: F) -> ListenerId
pub fn once<F>(&mut self, kind: InteractionEventKind, callback: F) -> ListenerId
Subscribe to a single occurrence of an interaction event kind.
The listener is automatically removed after the first dispatch.
Sourcepub fn off(&mut self, id: ListenerId) -> bool
pub fn off(&mut self, id: ListenerId) -> bool
Unsubscribe a previously registered event listener.
Sourcepub fn dispatch_events(&mut self, events: &[InteractionEvent])
pub fn dispatch_events(&mut self, events: &[InteractionEvent])
Dispatch interaction events to registered listeners.
Call this after draining events from the interaction manager.
Events are forwarded to all matching on / once callbacks.
Sourcepub fn event_emitter_mut(&mut self) -> &mut EventEmitter
pub fn event_emitter_mut(&mut self) -> &mut EventEmitter
Mutable access to the event emitter for advanced use cases.
Sourcepub fn invalidate_symbol_image_dependency(&mut self, image_id: &str) -> usize
pub fn invalidate_symbol_image_dependency(&mut self, image_id: &str) -> usize
Invalidate placed-symbol tiles that depend on the given image id.
Sourcepub fn invalidate_symbol_glyph_dependency(
&mut self,
font_stack: &str,
codepoint: char,
) -> usize
pub fn invalidate_symbol_glyph_dependency( &mut self, font_stack: &str, codepoint: char, ) -> usize
Invalidate placed-symbol tiles that depend on the given glyph.
Sourcepub fn set_vector_meshes(&mut self, meshes: Vec<VectorMeshData>)
pub fn set_vector_meshes(&mut self, meshes: Vec<VectorMeshData>)
Override the vector meshes for this frame (useful for testing).
Sourcepub fn set_model_instances(&mut self, instances: Vec<ModelInstance>)
pub fn set_model_instances(&mut self, instances: Vec<ModelInstance>)
Override the model instances for this frame (useful for testing).
Sourcepub fn set_placed_symbols(&mut self, symbols: Vec<PlacedSymbol>)
pub fn set_placed_symbols(&mut self, symbols: Vec<PlacedSymbol>)
Override the placed symbols for this frame (useful for testing).
Sourcepub fn update_with_dt(&mut self, dt: f64)
pub fn update_with_dt(&mut self, dt: f64)
Recompute all derived state with an explicit delta-time (seconds).
Sourcepub fn handle_input(&mut self, event: InputEvent)
pub fn handle_input(&mut self, event: InputEvent)
Forward an input event to the camera controller.
Touch events are routed through the
built-in GestureRecognizer,
which converts multi-touch sequences into pan / zoom / rotate
events before forwarding them to the camera controller.
Sourcepub fn gesture_recognizer(&self) -> &GestureRecognizer
pub fn gesture_recognizer(&self) -> &GestureRecognizer
Access the gesture recognizer (e.g. to call reset).
Sourcepub fn fly_to(&mut self, options: FlyToOptions)
pub fn fly_to(&mut self, options: FlyToOptions)
Begin a fly-to animation.
Sourcepub fn ease_to(&mut self, options: EaseToOptions)
pub fn ease_to(&mut self, options: EaseToOptions)
Begin an ease-to animation.
Sourcepub fn jump_to(
&mut self,
target: GeoCoord,
distance: f64,
pitch: Option<f64>,
yaw: Option<f64>,
)
pub fn jump_to( &mut self, target: GeoCoord, distance: f64, pitch: Option<f64>, yaw: Option<f64>, )
Immediately jump the camera to the given state.
Sourcepub fn update_camera(&mut self, dt: f64)
pub fn update_camera(&mut self, dt: f64)
Tick the camera animator and recompute zoom / viewport / frustum.
Sourcepub fn frame_output(&self) -> FrameOutput
pub fn frame_output(&self) -> FrameOutput
Build a detached per-frame snapshot for renderers.
Sourcepub fn elevation_at(&self, coord: &GeoCoord) -> Option<f64>
pub fn elevation_at(&self, coord: &GeoCoord) -> Option<f64>
Query the terrain elevation at a geographic coordinate.
Sourcepub fn screen_to_geo(&self, px: f64, py: f64) -> Option<GeoCoord>
pub fn screen_to_geo(&self, px: f64, py: f64) -> Option<GeoCoord>
Unproject a screen pixel to a geographic coordinate (flat ground).
Sourcepub fn geo_to_screen(&self, geo: &GeoCoord) -> Option<(f64, f64)>
pub fn geo_to_screen(&self, geo: &GeoCoord) -> Option<(f64, f64)>
Project a geographic coordinate to a screen-space pixel position.
Returns (px, py) in logical pixels with (0, 0) at the
top-left corner of the viewport, or None if the point is
behind the camera.
Sourcepub fn fit_bounds(&mut self, bounds: &GeoBounds, options: &FitBoundsOptions)
pub fn fit_bounds(&mut self, bounds: &GeoBounds, options: &FitBoundsOptions)
Fit the camera to a geographic bounding box.
Computes the center and zoom level that make the entire bounding
box visible, accounting for optional padding. Depending on
options.animate, the transition may be animated (fly_to) or
instant (jump_to).
Sourcepub fn ray_to_geo(&self, origin: DVec3, direction: DVec3) -> Option<GeoCoord>
pub fn ray_to_geo(&self, origin: DVec3, direction: DVec3) -> Option<GeoCoord>
Cast a ray and intersect with the flat ground plane (z = 0).
Sourcepub fn ray_to_geo_on_terrain(
&self,
origin: DVec3,
direction: DVec3,
) -> Option<GeoCoord>
pub fn ray_to_geo_on_terrain( &self, origin: DVec3, direction: DVec3, ) -> Option<GeoCoord>
Cast a ray and intersect with the terrain surface.
Falls back to flat ground intersection if terrain is disabled or no intersection is found.