pub struct Map { /* private fields */ }Expand description
A handle to a map, which lives on its runtime’s thread.
Each command takes the next sequence number when it is sent and runs on
the runtime’s thread after every command sent before it, to this map,
another map or the runtime. It returns a Completion of its result, or
an error when it can’t be sent, and then never completes. A command sent
before the map is built waits for it. Clone is another handle to the
same map, and any thread may use one.
The map lives until release or until its last handle
drops. A command on a released map fails with
ErrorKind::InvalidState.
Implementations§
Source§impl Map
impl Map
Sourcepub fn discarding_results(&self, on_failure: fn(Error)) -> Map
pub fn discarding_results(&self, on_failure: fn(Error)) -> Map
A handle to the same map whose commands discard their results, for a
caller that doesn’t need them: each command’s completion acts as one
whose result was taken, and costs no allocation, and a failure,
cancellations included, goes to on_failure on the runtime’s thread.
pub fn id(&self) -> MapId
Sourcepub fn sent_sequence(&self) -> u64
pub fn sent_sequence(&self) -> u64
The sequence number of the last command sent to the map.
Sourcepub fn applied_sequence(&self) -> u64
pub fn applied_sequence(&self) -> u64
The sequence number of the last command that ran. While the runtime’s thread runs several queued commands as one burst, they count once the frame that shows them all can.
Sourcepub fn snapshot(&self) -> Result<MapSnapshot, Error>
pub fn snapshot(&self) -> Result<MapSnapshot, Error>
The map’s state after the last command that ran, without waiting for
the commands still on their way. To read the state after them, send a
command and read the snapshot once it completes, or use a query such
as camera. Its update_generation counts the
renderer’s updates as they are when it is read, which can be later
than the rest of the state.
Fails with ErrorKind::InvalidState until the
map is built, and after it is released.
Sourcepub fn projection(&self, view: Option<&MapView>) -> Result<MapProjection, Error>
pub fn projection(&self, view: Option<&MapView>) -> Result<MapProjection, Error>
A projection of view, or of the map’s view as of
snapshot for None, on the ground the map drew
then (mln_engine::map::Map::ground): it converts as the map does, in
the view’s projection, over terrain on the ground the renderer drew,
else on the flat map. It is the caller’s, and doesn’t follow the map.
Fails as snapshot does, and for view as
MapView::to_state.
Sourcepub fn event_mask(&self) -> EventMask
pub fn event_mask(&self) -> EventMask
The events that the map reports, as of the last command that ran.
Sourcepub fn with_core<R: Send + 'static>(
&self,
f: impl FnOnce(&mut Map) -> R + Send + 'static,
) -> Result<Completion<R>, Error>
pub fn with_core<R: Send + 'static>( &self, f: impl FnOnce(&mut Map) -> R + Send + 'static, ) -> Result<Completion<R>, Error>
Runs f on the map itself, on the runtime’s thread, in its place
among the map’s commands. It sees the effects of the commands sent
before it. The map handles what f changed, and reports its events,
before the completion.
Sourcepub fn release(&self) -> Result<Completion<()>, Error>
pub fn release(&self) -> Result<Completion<()>, Error>
Releases the map. The completion reports when the runtime has let go
of it. A render session that was released, but hasn’t let go of the
map yet, is abandoned, as
RenderSession::abandon does: a
caller-driven one that the host stopped servicing would otherwise
hold the map for good.
Fails with ErrorKind::InvalidState when the
map was released already, or while a render session that wasn’t
released is attached to it.
Sourcepub fn dispose(&self) -> Result<Completion<()>, Error>
pub fn dispose(&self) -> Result<Completion<()>, Error>
Releases the map whatever its state, as dropping its last handle
does, and lets the runtime finish in the background: the completion
reports when the runtime has let go of it, and may be dropped. Every
command fails with ErrorKind::InvalidState
from now on. A render session that is attached and wasn’t released
keeps drawing the map’s last update, and the runtime lets go of the
map once the session detaches or is abandoned. A released one is
abandoned, as release does.
Fails with ErrorKind::InvalidState when the
map was released already.
Sourcepub fn resize(
&self,
extent: LogicalExtent,
) -> Result<Completion<Applied>, Error>
pub fn resize( &self, extent: LogicalExtent, ) -> Result<Completion<Applied>, Error>
Sets the map’s size and scale factor. The map keeps its tiles, and a
resize to the extent the map has changes nothing, so it renders
nothing. Fails with ErrorKind::InvalidState
while a render session is attached, since the session sizes the map
to its target: resize the session instead. Fails with
ErrorKind::InvalidArgument for an empty size,
or a scale factor that isn’t finite and positive.
Sourcepub fn request_repaint(&self) -> Result<Completion<Applied>, Error>
pub fn request_repaint(&self) -> Result<Completion<Applied>, Error>
Renders a new frame of a continuous map, even when nothing changed.
Fails with ErrorKind::InvalidState for a
static or tile map, which renders only still images.
Sourcepub fn begin_command_group(&self) -> Result<Completion<Applied>, Error>
pub fn begin_command_group(&self) -> Result<Completion<Applied>, Error>
Holds the map’s changes back from rendering until the matching
end_command_group, so that they show in
the same frame. Groups nest, and the changes show when the outermost
group ends.
Sourcepub fn end_command_group(&self) -> Result<Completion<Applied>, Error>
pub fn end_command_group(&self) -> Result<Completion<Applied>, Error>
Ends the group that begin_command_group
began. Completes with ErrorKind::InvalidState
when no group is open.
Sourcepub fn command_group(&self) -> Result<CommandGroup, Error>
pub fn command_group(&self) -> Result<CommandGroup, Error>
Begins a command group that ends when the guard drops, or with
CommandGroup::end.
Sourcepub fn set_event_mask(
&self,
mask: EventMask,
) -> Result<Completion<Applied>, Error>
pub fn set_event_mask( &self, mask: EventMask, ) -> Result<Completion<Applied>, Error>
Selects the events that the map reports.
Sourcepub fn attach(
&self,
target: RenderTarget,
options: AttachOptions,
) -> Result<(RenderSession, Completion<()>), Error>
pub fn attach( &self, target: RenderTarget, options: AttachOptions, ) -> Result<(RenderSession, Completion<()>), Error>
Attaches a render session, which renders the map into target, and
sizes the map to the target. A map has one session at a time. The
session takes frame demands and other work at once, and runs them
once the completion reports it ready.
The session renders on a thread of its own, or, with
Driver::CallerThread, on the thread
that takes its DriverWork: the attach completes
in that thread’s first service.
Fails with ErrorKind::InvalidState when the
map already has a session or was released, or a window is minimized
or has no client area, and with
ErrorKind::InvalidArgument for an empty
target, a Surface::wgpu without the
host’s device, or a Win32 window with a pixel format of its own that
OpenGL would present to. The completion fails as
Device::new does when the
session has to create its device and can’t, with
ErrorKind::InvalidState when the window or
surface had no area to present to by then, with
ErrorKind::Unsupported when no GPU can present
to a window, and with ErrorKind::Failed when
the window has no surface to give.
Sourcepub fn attach_then<R>(
&self,
target: RenderTarget,
options: AttachOptions,
then: impl FnOnce(&RenderSession, Completion<()>) -> R,
) -> Result<R, Error>
pub fn attach_then<R>( &self, target: RenderTarget, options: AttachOptions, then: impl FnOnce(&RenderSession, Completion<()>) -> R, ) -> Result<R, Error>
Attaches a render session as attach does, and calls
then with it and the attach’s completion before the session’s
thread may deliver the attach’s result. A callback that then
attaches with Completion::on_complete runs where the session
delivers it: on the session’s thread, inside its driver call, even
when the session attaches before then runs. One attached after
attach returned would run at once on this thread instead.
then keeps the session with a clone of it: the session is released
once its last handle drops. Fails as attach does, before then
runs.
Sourcepub fn request_still_image(&self) -> Result<Completion<()>, Error>
pub fn request_still_image(&self) -> Result<Completion<()>, Error>
Renders a still image of a static or tile map, once every resource
that it needs has loaded. The map’s render session draws it, and
RenderSession::read_texture reads its pixels once the completion
reports success.
While the image waits, the session has a demand of its own for it,
whose FrameResult has no token. The demand
waits for the map to load what the image needs, and parks while a
borrowed ring has no texture to render into. It finishes with the
image’s frame, which completes the image once its result is queued:
a frame of the host’s demands completes none. The host’s demands
neither replace it nor are replaced by it. When the session ends its
demands, by a barrier, a target’s release or a detach, the demand
ends too, and the image waits for the next one: once the barrier ran,
the target came back, or the next session attached.
Fails with ErrorKind::InvalidState for a
continuous map. Completes with
ErrorKind::InvalidState while another image
is on its way or a command group is open,
ErrorKind::Failed when the
style or a resource that the image needs fails to load, and
ErrorKind::Cancelled when the map is released
first.
Sourcepub fn scale_factor(&self) -> f64
pub fn scale_factor(&self) -> f64
The map’s scale factor: device pixels per logical pixel. It is the
pixel ratio of the map’s options until a render session’s
resize sets another, and the map’s
next session renders at it.
Sourcepub fn registry(&self) -> &Arc<Registry> ⓘ
pub fn registry(&self) -> &Arc<Registry> ⓘ
What the map parses its style against, its renderer draws and its
tile workers lay out: its runtime’s
registry. A filter for a query parses
against its functions.
Sourcepub fn set_feature_state(
&self,
selector: &FeatureStateSelector,
state: FeatureState,
) -> Result<Completion<Applied>, Error>
pub fn set_feature_state( &self, selector: &FeatureStateSelector, state: FeatureState, ) -> Result<Completion<Applied>, Error>
Merges state into the state of the feature that selector names:
its keys replace the same keys of the feature’s state, and the other
keys stay.
The map keeps the state until it is removed, its source leaves the
style, or a style loads: remove_style_source
removes the state of the source’s features, and a style that loads
removes the state of every source. To set state for a new style’s
sources, wait until set_style_url or
set_style_json completes.
The map’s next update for its render session carries the state, so a
frame shows it, and a rendered query reads it, once the frame renders
that update. A command that changes no state publishes no update: an
empty state merges nothing.
Fails with ErrorKind::InvalidArgument for a
selector without a feature.
Sourcepub fn feature_state(
&self,
selector: &FeatureStateSelector,
) -> Result<Completion<FeatureState>, Error>
pub fn feature_state( &self, selector: &FeatureStateSelector, ) -> Result<Completion<FeatureState>, Error>
The state of the feature that selector names, empty when it has
none. Fails with ErrorKind::InvalidArgument
for a selector without a feature.
Sourcepub fn remove_feature_state(
&self,
selector: &FeatureStateSelector,
) -> Result<Completion<Applied>, Error>
pub fn remove_feature_state( &self, selector: &FeatureStateSelector, ) -> Result<Completion<Applied>, Error>
Removes the state that selector selects: one key of a feature, all
of a feature’s state, or that of every feature in a source layer.
The removal reaches the render session as
set_feature_state describes, and a
removal of no state publishes no update. Fails with
ErrorKind::InvalidArgument for a state key
without a feature.
Sourcepub fn set_style_url(
&self,
url: impl Into<String>,
) -> Result<Completion<Applied>, Error>
pub fn set_style_url( &self, url: impl Into<String>, ) -> Result<Completion<Applied>, Error>
Loads the map’s style from url.
Completes once the style document has loaded and parsed, with
ErrorKind::Failed when it fails to, and with
ErrorKind::Cancelled when another style load
starts or the map is released first. The style’s sources, sprites and
glyphs then load in the background. Commands that change the style
fail with ErrorKind::InvalidState until the
document has parsed.
Sourcepub fn set_style_json(
&self,
json: impl Into<String>,
) -> Result<Completion<Applied>, Error>
pub fn set_style_json( &self, json: impl Into<String>, ) -> Result<Completion<Applied>, Error>
Loads the map’s style from JSON text. Completes as
set_style_url does, once the style has
parsed, but with ErrorKind::InvalidArgument
for JSON that isn’t a valid style. A style that fails to parse leaves
the map’s style as it was.
Sourcepub fn loaded_style_json(&self) -> Result<Completion<String>, Error>
pub fn loaded_style_json(&self) -> Result<Completion<String>, Error>
The JSON of the style that the map loaded, without the changes made since.
Sourcepub fn style_url(&self) -> Result<Completion<Option<String>>, Error>
pub fn style_url(&self) -> Result<Completion<Option<String>>, Error>
The URL of the map’s style, or None for a style loaded from JSON.
Sourcepub fn add_style_source_json(
&self,
source_id: impl Into<String>,
json: impl Into<String>,
) -> Result<Completion<Applied>, Error>
pub fn add_style_source_json( &self, source_id: impl Into<String>, json: impl Into<String>, ) -> Result<Completion<Applied>, Error>
Adds a source to the style from its JSON. See
mln_engine::map::Map::add_source_json for the errors.
Sourcepub fn remove_style_source(
&self,
source_id: impl Into<String>,
) -> Result<Completion<Applied>, Error>
pub fn remove_style_source( &self, source_id: impl Into<String>, ) -> Result<Completion<Applied>, Error>
Removes a source from the style. Completes with
ErrorKind::NotFound when the style has no
such source, and ErrorKind::InvalidState
when a layer uses it or the style isn’t loaded. The source’s features
lose their state, and a value held for the source drops before the
completion.
Sourcepub fn add_style_layer_json(
&self,
json: impl Into<String>,
before_layer_id: Option<String>,
) -> Result<Completion<Applied>, Error>
pub fn add_style_layer_json( &self, json: impl Into<String>, before_layer_id: Option<String>, ) -> Result<Completion<Applied>, Error>
Adds a layer to the style from its JSON, below before_layer_id or
above every layer. See Style::add_layer_json for the errors.
Sourcepub fn add_style_layer(
&self,
layer: Layer,
before_layer_id: Option<String>,
) -> Result<Completion<Applied>, Error>
pub fn add_style_layer( &self, layer: Layer, before_layer_id: Option<String>, ) -> Result<Completion<Applied>, Error>
Adds layer to the style, below before_layer_id or above every
layer: one of a type that isn’t made from JSON, or one that holds a
value for as long as the style has it
(Layer::from_style_holding).
See Style::add_layer for the errors.
Sourcepub fn remove_style_layer(
&self,
layer_id: impl Into<String>,
) -> Result<Completion<Applied>, Error>
pub fn remove_style_layer( &self, layer_id: impl Into<String>, ) -> Result<Completion<Applied>, Error>
Removes a layer from the style. Completes with
ErrorKind::NotFound when the style has no
such layer, and ErrorKind::InvalidState
while the style isn’t loaded.
Sourcepub fn style_layer_json(
&self,
layer_id: impl Into<String>,
) -> Result<Completion<Option<String>>, Error>
pub fn style_layer_json( &self, layer_id: impl Into<String>, ) -> Result<Completion<Option<String>>, Error>
A layer of the style as JSON, or None when the style has no such
layer.
Sourcepub fn set_style_layer_property(
&self,
layer_id: impl Into<String>,
name: impl Into<String>,
json: impl Into<String>,
) -> Result<Completion<Applied>, Error>
pub fn set_style_layer_property( &self, layer_id: impl Into<String>, name: impl Into<String>, json: impl Into<String>, ) -> Result<Completion<Applied>, Error>
Sets a property of a layer to a JSON value. See
Style::set_layer_property_json for the errors.
Sourcepub fn style_layer_property(
&self,
layer_id: impl Into<String>,
name: impl Into<String>,
) -> Result<Completion<Option<String>>, Error>
pub fn style_layer_property( &self, layer_id: impl Into<String>, name: impl Into<String>, ) -> Result<Completion<Option<String>>, Error>
A property of a layer as JSON, or None when the layer doesn’t set
it. See Style::layer_property_json for the errors.
Sourcepub fn set_style_root_property(
&self,
name: impl Into<String>,
json: impl Into<String>,
) -> Result<Completion<Applied>, Error>
pub fn set_style_root_property( &self, name: impl Into<String>, json: impl Into<String>, ) -> Result<Completion<Applied>, Error>
Sets a root property of the style to a JSON value, without
reloading the style. See Style::set_root_property_json for the
properties that change and the errors.
Sourcepub fn style_root_property(
&self,
name: impl Into<String>,
) -> Result<Completion<Option<String>>, Error>
pub fn style_root_property( &self, name: impl Into<String>, ) -> Result<Completion<Option<String>>, Error>
A root property of the style as JSON, or None when neither the
style nor the map sets it. See Style::root_property_json.
Sourcepub fn set_style_light_property(
&self,
name: impl Into<String>,
json: impl Into<String>,
) -> Result<Completion<Applied>, Error>
pub fn set_style_light_property( &self, name: impl Into<String>, json: impl Into<String>, ) -> Result<Completion<Applied>, Error>
Sets a property of the style’s light to a JSON value.
Sourcepub fn style_light_property(
&self,
name: impl Into<String>,
) -> Result<Completion<Option<String>>, Error>
pub fn style_light_property( &self, name: impl Into<String>, ) -> Result<Completion<Option<String>>, Error>
A property of the style’s light as JSON, or None when the light
doesn’t set it.
Sourcepub fn update_camera(
&self,
update: CameraUpdate,
) -> Result<Completion<Applied>, Error>
pub fn update_camera( &self, update: CameraUpdate, ) -> Result<Completion<Applied>, Error>
Moves the camera to absolute values, by a jump, an ease or a flight.
Sourcepub fn update_camera_then(
&self,
update: CameraUpdate,
on_end: impl FnOnce(Result<TransitionEnd, Error>) + Send + 'static,
) -> Result<Completion<Applied>, Error>
pub fn update_camera_then( &self, update: CameraUpdate, on_end: impl FnOnce(Result<TransitionEnd, Error>) + Send + 'static, ) -> Result<Completion<Applied>, Error>
Moves the camera as update_camera does, and
calls on_end with how the change ended, on the runtime’s thread:
once the map has published the snapshot that shows where the change
left the camera, whose generation the end reports, and before the
returned completion when the change ends within the command. A
command that fails ends as cancelled, and one that the map’s release
ends as closed, with generation 0. on_end runs on this thread only
with ErrorKind::Cancelled, when the send
fails.
Sourcepub fn apply_camera_delta(
&self,
delta: CameraDelta,
) -> Result<Completion<Applied>, Error>
pub fn apply_camera_delta( &self, delta: CameraDelta, ) -> Result<Completion<Applied>, Error>
Moves the camera relative to where it is, as a gesture does.
Completes with ErrorKind::InvalidArgument for
a delta that the camera can’t apply.
Sourcepub fn apply_camera_delta_then(
&self,
delta: CameraDelta,
on_end: impl FnOnce(Result<TransitionEnd, Error>) + Send + 'static,
) -> Result<Completion<Applied>, Error>
pub fn apply_camera_delta_then( &self, delta: CameraDelta, on_end: impl FnOnce(Result<TransitionEnd, Error>) + Send + 'static, ) -> Result<Completion<Applied>, Error>
Applies delta as apply_camera_delta
does, and calls on_end with how the change ended, as
update_camera_then does.
Sourcepub fn camera_for(
&self,
area: CameraFitArea,
options: CameraFitOptions,
) -> Result<Completion<CameraOptions>, Error>
pub fn camera_for( &self, area: CameraFitArea, options: CameraFitOptions, ) -> Result<Completion<CameraOptions>, Error>
The camera that fits area in the map’s view, after the commands
sent before, as [mln_engine::map::Map::camera_for_lat_lngs] fits
it. Its zoom stays within the map’s zoom limits.
Completes with ErrorKind::InvalidArgument for
an empty area, and for padding and margin that leave no room for it.
Sourcepub fn fit_camera(
&self,
area: CameraFitArea,
update: CameraFitUpdate,
) -> Result<Completion<Applied>, Error>
pub fn fit_camera( &self, area: CameraFitArea, update: CameraFitUpdate, ) -> Result<Completion<Applied>, Error>
Moves the camera to the one that camera_for
finds once the commands sent before have run, as
update_camera moves it.
Completes as camera_for fails, and then leaves the camera where it
is and ends the animation as cancelled.
Sourcepub fn fit_camera_then(
&self,
area: CameraFitArea,
update: CameraFitUpdate,
on_end: impl FnOnce(Result<TransitionEnd, Error>) + Send + 'static,
) -> Result<Completion<Applied>, Error>
pub fn fit_camera_then( &self, area: CameraFitArea, update: CameraFitUpdate, on_end: impl FnOnce(Result<TransitionEnd, Error>) + Send + 'static, ) -> Result<Completion<Applied>, Error>
Fits the camera as fit_camera does, and calls
on_end with how the change ended, as
update_camera_then does.
Sourcepub fn cancel_camera_transitions(&self) -> Result<Completion<Applied>, Error>
pub fn cancel_camera_transitions(&self) -> Result<Completion<Applied>, Error>
Stops every camera animation.
Sourcepub fn cancel_camera_transitions_with_id(
&self,
transition_id: u64,
) -> Result<Completion<Applied>, Error>
pub fn cancel_camera_transitions_with_id( &self, transition_id: u64, ) -> Result<Completion<Applied>, Error>
Stops the camera animations whose transition ID is transition_id.
Sourcepub fn camera(&self) -> Result<Completion<CameraQuery>, Error>
pub fn camera(&self) -> Result<Completion<CameraQuery>, Error>
The camera after the commands sent before.
Sourcepub fn lat_lng_bounds_for_camera(
&self,
camera: CameraOptions,
) -> Result<Completion<LatLngBounds>, Error>
pub fn lat_lng_bounds_for_camera( &self, camera: CameraOptions, ) -> Result<Completion<LatLngBounds>, Error>
The area that camera would show, with the fields that camera
leaves out from the map’s camera. It holds every corner of a rotated
view, and its longitudes can pass ±180, so a view across the
antimeridian gives one continuous range.
Sourcepub fn set_bounds(
&self,
bounds: BoundOptions,
) -> Result<Completion<Applied>, Error>
pub fn set_bounds( &self, bounds: BoundOptions, ) -> Result<Completion<Applied>, Error>
Sets the limits on the camera.
Sourcepub fn set_free_camera_options(
&self,
camera: FreeCameraOptions,
) -> Result<Completion<Applied>, Error>
pub fn set_free_camera_options( &self, camera: FreeCameraOptions, ) -> Result<Completion<Applied>, Error>
Sets the camera’s position and orientation in three dimensions.
Sourcepub fn set_viewport_options(
&self,
options: ViewportOptions,
) -> Result<Completion<Applied>, Error>
pub fn set_viewport_options( &self, options: ViewportOptions, ) -> Result<Completion<Applied>, Error>
Sets how the map orients and constrains its view.
Sourcepub fn set_tile_options(
&self,
options: TileOptions,
) -> Result<Completion<Applied>, Error>
pub fn set_tile_options( &self, options: TileOptions, ) -> Result<Completion<Applied>, Error>
Sets how the map picks the tiles to load.
pub fn set_projection_mode( &self, mode: ProjectionMode, ) -> Result<Completion<Applied>, Error>
Sourcepub fn dump_debug_logs(&self) -> Result<Completion<Applied>, Error>
pub fn dump_debug_logs(&self) -> Result<Completion<Applied>, Error>
Logs the style’s sources and their state.
Source§impl Map
impl Map
Sourcepub fn set_global_state_property(
&self,
name: impl Into<String>,
json: impl Into<String>,
) -> Result<Completion<Applied>, Error>
pub fn set_global_state_property( &self, name: impl Into<String>, json: impl Into<String>, ) -> Result<Completion<Applied>, Error>
Sets the value name that the style’s global-state expressions
read, from JSON. See Style::set_global_state_property_json.
Sourcepub fn global_state(&self) -> Result<Completion<String>, Error>
pub fn global_state(&self) -> Result<Completion<String>, Error>
The style’s global state as a JSON object.
Sourcepub fn style_source(
&self,
source_id: impl Into<String>,
) -> Result<Completion<Option<SourceInfo>>, Error>
pub fn style_source( &self, source_id: impl Into<String>, ) -> Result<Completion<Option<SourceInfo>>, Error>
A source of the style, or None when the style has no such source.
Sourcepub fn style_sources(&self) -> Result<Completion<Vec<SourceInfo>>, Error>
pub fn style_sources(&self) -> Result<Completion<Vec<SourceInfo>>, Error>
The style’s sources, in style order.
Sourcepub fn set_style_source_volatile(
&self,
source_id: impl Into<String>,
is_volatile: bool,
) -> Result<Completion<Applied>, Error>
pub fn set_style_source_volatile( &self, source_id: impl Into<String>, is_volatile: bool, ) -> Result<Completion<Applied>, Error>
Sets whether a source keeps its tiles out of the persistent cache.
Sourcepub fn add_geojson_source(
&self,
source_id: impl Into<String>,
options: GeoJsonSourceOptions,
) -> Result<Completion<Applied>, Error>
pub fn add_geojson_source( &self, source_id: impl Into<String>, options: GeoJsonSourceOptions, ) -> Result<Completion<Applied>, Error>
Adds a GeoJSON source with no data and options, which stay fixed
for as long as the style holds it.
Fails with ErrorKind::InvalidArgument for an
option out of range, and completes with it for cluster properties
that don’t parse.
Sourcepub fn set_geojson_source_url(
&self,
source_id: impl Into<String>,
url: impl Into<String>,
) -> Result<Completion<Applied>, Error>
pub fn set_geojson_source_url( &self, source_id: impl Into<String>, url: impl Into<String>, ) -> Result<Completion<Applied>, Error>
Makes a GeoJSON source load its data from url. Data that a
set_geojson_source_data sent before
and that isn’t ready yet is cancelled.
Sourcepub fn set_geojson_source_data(
&self,
source_id: impl Into<String>,
json: impl Into<String>,
) -> Result<Completion<Applied>, Error>
pub fn set_geojson_source_data( &self, source_id: impl Into<String>, json: impl Into<String>, ) -> Result<Completion<Applied>, Error>
Replaces the data of a GeoJSON source with the GeoJSON text json, a
feature collection, feature or geometry.
The runtime’s thread parses the data, and a background thread prepares it with the source’s options; the command completes once the source holds it. Later commands don’t wait for it. While the source is still preparing earlier data, only the newest data waits to follow it. With synchronous tiling on, the command prepares the data before later commands run.
Completes with ErrorKind::NotFound when the
style has no such source, with InvalidArgument when it isn’t a
GeoJSON source, when json isn’t GeoJSON, or when the source clusters
and the data isn’t a feature collection of points, and with
Cancelled when newer data replaces it while it waits, or when the
source’s URL, its removal, a style load or the map’s release replaces
the source’s data before it is ready.
Sourcepub fn set_geojson_source_synchronous_tiling(
&self,
source_id: impl Into<String>,
enabled: bool,
) -> Result<Completion<Applied>, Error>
pub fn set_geojson_source_synchronous_tiling( &self, source_id: impl Into<String>, enabled: bool, ) -> Result<Completion<Applied>, Error>
Sets whether a GeoJSON source builds its tiles while the map renders,
in place of the synchronousUpdate of the source’s JSON.
Sourcepub fn add_source_holding(
&self,
source: Source,
held: Box<dyn Any + Send>,
) -> Result<Completion<Applied>, Error>
pub fn add_source_holding( &self, source: Source, held: Box<dyn Any + Send>, ) -> Result<Completion<Applied>, Error>
Adds source to the style, with held, a value that the map holds
for that source while it is in the style, which
with_held_source reaches. The map drops
it once the source leaves the style, by its removal, a style load or
the map’s release, before the command that removed it completes. A
command that fails drops it before it completes.
Completes with ErrorKind::AlreadyExists
when the style has a source with the ID, and as
add_style_source_json otherwise.
Sourcepub fn with_held_source<T: Any + Send>(
&self,
source_id: impl Into<String>,
apply: impl FnOnce(Result<&mut T, HeldSourceError>) -> Result<(), Error> + Send + 'static,
) -> Result<Completion<Applied>, Error>
pub fn with_held_source<T: Any + Send>( &self, source_id: impl Into<String>, apply: impl FnOnce(Result<&mut T, HeldSourceError>) -> Result<(), Error> + Send + 'static, ) -> Result<Completion<Applied>, Error>
A command that runs apply on the runtime’s thread with the value of
type T that the map holds for the source source_id, or why it
holds none, and completes with what apply returns.
Sourcepub fn set_style_image(
&self,
image: StyleImage,
) -> Result<Completion<Applied>, Error>
pub fn set_style_image( &self, image: StyleImage, ) -> Result<Completion<Applied>, Error>
Adds image to the style, or replaces the image with its ID.
Sourcepub fn remove_style_image(
&self,
image_id: impl Into<String>,
) -> Result<Completion<Applied>, Error>
pub fn remove_style_image( &self, image_id: impl Into<String>, ) -> Result<Completion<Applied>, Error>
Removes an image from the style. Completes with
ErrorKind::NotFound when the style has no
such image.
Sourcepub fn style_image(
&self,
image_id: impl Into<String>,
) -> Result<Completion<Option<Arc<StyleImage>>>, Error>
pub fn style_image( &self, image_id: impl Into<String>, ) -> Result<Completion<Option<Arc<StyleImage>>>, Error>
An image of the style, or None when the style has no such image.
Sourcepub fn add_image_source(
&self,
source_id: impl Into<String>,
coordinates: [LatLng; 4],
image: PremultipliedImage,
) -> Result<Completion<Applied>, Error>
pub fn add_image_source( &self, source_id: impl Into<String>, coordinates: [LatLng; 4], image: PremultipliedImage, ) -> Result<Completion<Applied>, Error>
Adds an image source that shows image at coordinates, its four
corners clockwise from the top left.
Sourcepub fn set_image_source_url(
&self,
source_id: impl Into<String>,
url: impl Into<String>,
) -> Result<Completion<Applied>, Error>
pub fn set_image_source_url( &self, source_id: impl Into<String>, url: impl Into<String>, ) -> Result<Completion<Applied>, Error>
Makes an image source load its image from url.
Sourcepub fn set_image_source_image(
&self,
source_id: impl Into<String>,
image: PremultipliedImage,
) -> Result<Completion<Applied>, Error>
pub fn set_image_source_image( &self, source_id: impl Into<String>, image: PremultipliedImage, ) -> Result<Completion<Applied>, Error>
Replaces the image of an image source.
Sourcepub fn set_image_source_coordinates(
&self,
source_id: impl Into<String>,
coordinates: [LatLng; 4],
) -> Result<Completion<Applied>, Error>
pub fn set_image_source_coordinates( &self, source_id: impl Into<String>, coordinates: [LatLng; 4], ) -> Result<Completion<Applied>, Error>
Moves the image of an image source to coordinates, its four corners
clockwise from the top left.
Sourcepub fn image_source_coordinates(
&self,
source_id: impl Into<String>,
) -> Result<Completion<[LatLng; 4]>, Error>
pub fn image_source_coordinates( &self, source_id: impl Into<String>, ) -> Result<Completion<[LatLng; 4]>, Error>
The corners of an image source’s image, clockwise from the top left.
Sourcepub fn style_layer(
&self,
layer_id: impl Into<String>,
) -> Result<Completion<Option<LayerInfo>>, Error>
pub fn style_layer( &self, layer_id: impl Into<String>, ) -> Result<Completion<Option<LayerInfo>>, Error>
A layer of the style, or None when the style has no such layer.
Sourcepub fn style_layers(&self) -> Result<Completion<Vec<LayerInfo>>, Error>
pub fn style_layers(&self) -> Result<Completion<Vec<LayerInfo>>, Error>
The style’s layers, from bottom to top.
Sourcepub fn move_style_layer(
&self,
layer_id: impl Into<String>,
before_layer_id: Option<String>,
) -> Result<Completion<Applied>, Error>
pub fn move_style_layer( &self, layer_id: impl Into<String>, before_layer_id: Option<String>, ) -> Result<Completion<Applied>, Error>
Moves a layer below before_layer_id, or above every layer. See
Style::move_layer for the errors.
Sourcepub fn set_style_transition_options(
&self,
options: TransitionOptions,
) -> Result<Completion<Applied>, Error>
pub fn set_style_transition_options( &self, options: TransitionOptions, ) -> Result<Completion<Applied>, Error>
Sets the default transition of the style’s paint properties.
Sourcepub fn style_transition_options(
&self,
) -> Result<Completion<TransitionOptions>, Error>
pub fn style_transition_options( &self, ) -> Result<Completion<TransitionOptions>, Error>
The default transition of the style’s paint properties.
Trait Implementations§
impl Eq for Map
Source§impl GestureCamera for Map
impl GestureCamera for Map
Source§fn lat_lng_for_pixel(&self, pixel: ScreenCoordinate) -> Option<LatLng>
fn lat_lng_for_pixel(&self, pixel: ScreenCoordinate) -> Option<LatLng>
On the ground the map draws, so that a box zoom over terrain centers on the ground it boxed, and in the projection it draws in.
Source§fn viewport(&self) -> ScreenCoordinate
fn viewport(&self) -> ScreenCoordinate
fn camera(&self) -> CameraOptions
Source§fn zoom_range(&self) -> (f64, f64)
fn zoom_range(&self) -> (f64, f64)
zoom_range).Source§fn apply_camera_delta(&mut self, delta: &CameraDelta)
fn apply_camera_delta(&mut self, delta: &CameraDelta)
Map::apply_camera_delta
does. The recognizer only sends valid deltas.Source§fn release(&mut self, delta: &CameraDelta) -> PendingEnd
fn release(&mut self, delta: &CameraDelta) -> PendingEnd
apply_camera_delta does, and
returns how its command ends: the end of the momentum it starts,
whose speed a press that stops it can carry.fn update_camera(&mut self, update: &CameraUpdate)
fn cancel_transitions_with_id(&mut self, transition_id: u64)
Auto Trait Implementations§
impl !RefUnwindSafe for Map
impl !UnwindSafe for Map
impl Forget for Map
impl Freeze for Map
impl Move for Map
impl Send for Map
impl Sync for Map
impl Unpin for Map
impl UnsafeUnpin for Mapwhere
*const ArcInner<MapShared> is !null: UnsafeUnpin,
PhantomData<ArcInner<MapShared>>: UnsafeUnpin,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> FmtForward for T
impl<T> FmtForward for T
Source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.Source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.Source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.Source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.Source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.Source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.Source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.Source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.