Table of Contents

Class MapHandle

Namespace
Maplibre.NativeFfi
Assembly
Maplibre.NativeFfi.dll

A map, with its style and camera.

public sealed class MapHandle : IDisposable, IAsyncDisposable
Inheritance
MapHandle
Implements
Inherited Members

Remarks

See mln_map in the C API reference.

Properties

Discarding

Submits each command without a completion. Native logs a failure as a warning, and the caller sees none.

public MapHandle.DiscardingCommands Discarding { get; }

Property Value

MapHandle.DiscardingCommands

Id

The native handle value, which runtime events report as their source. It stays readable after release, so events drained later still match this handle.

public ulong Id { get; }

Property Value

ulong

IsClosed

Whether a release, dispose, or discard has ended the handle.

public bool IsClosed { get; }

Property Value

bool

Ready

Completes once the handle is ready, and faults with a MaplibreException when it fails to become ready.

public Task Ready { get; }

Property Value

Task

Methods

AddCustomGeometrySourceAsync(string, CustomGeometrySourceOptions)

Adds a source whose GeoJSON tiles come from callbacks.

public Task<CommandCompletion> AddCustomGeometrySourceAsync(string sourceId, CustomGeometrySourceOptions options)

Parameters

sourceId string
options CustomGeometrySourceOptions

Returns

Task<CommandCompletion>

Remarks

See mln_map_add_custom_geometry_source in the C API reference.

Errors:

  • Status.AlreadyExists when the style already has a source named sourceId.
  • Status.InvalidState while the style isn't loaded, as MapHandle.SetStyleUrlAsync() describes.

AddCustomVectorSourceAsync(string, CustomVectorSourceOptions)

Adds a source whose vector tiles come from callbacks.

public Task<CommandCompletion> AddCustomVectorSourceAsync(string sourceId, CustomVectorSourceOptions options)

Parameters

sourceId string
options CustomVectorSourceOptions

Returns

Task<CommandCompletion>

Remarks

See mln_map_add_custom_vector_source in the C API reference.

Errors:

  • Status.AlreadyExists when the style already has a source named sourceId.
  • Status.InvalidState while the style isn't loaded, as MapHandle.SetStyleUrlAsync() describes.

AddGeoJsonSourceAsync(string, GeoJsonSourceOptions?, string?)

Adds a GeoJSON source with no data.

public Task<CommandCompletion> AddGeoJsonSourceAsync(string sourceId, GeoJsonSourceOptions? options = null, string? attribution = null)

Parameters

sourceId string
options GeoJsonSourceOptions
attribution string

Returns

Task<CommandCompletion>

Remarks

Give it data with MapHandle.SetGeoJsonSourceDataAsync() or MapHandle.SetGeoJsonSourceUrlAsync(). Its options stay fixed for as long as the style holds it.

attribution is the source's [attribution](https://maplibre.org/maplibre-style-spec/sources/#attribution), or empty for none.

See mln_map_add_geo_json_source in the C API reference.

Errors:

  • Status.InvalidArgument when an option in options is out of range.
  • Status.AlreadyExists when the style already has a source named sourceId.
  • Status.InvalidState while the style isn't loaded, as MapHandle.SetStyleUrlAsync() describes.

AddImageSourceImageAsync(string, LatLng[], PremultipliedRgba8Image)

Adds an image source that shows image.

public Task<CommandCompletion> AddImageSourceImageAsync(string sourceId, LatLng[] coordinates, PremultipliedRgba8Image image)

Parameters

sourceId string
coordinates LatLng[]
image PremultipliedRgba8Image

Returns

Task<CommandCompletion>

Remarks

coordinates are the image's four corners, clockwise from the top left.

See mln_map_add_image_source_image in the C API reference.

Errors:

  • Status.AlreadyExists when the style already has a source named sourceId.
  • Status.InvalidState while the style isn't loaded, as MapHandle.SetStyleUrlAsync() describes.

AddStyleLayerJsonAsync(string, string?)

Adds a layer to the map's style.

public Task<CommandCompletion> AddStyleLayerJsonAsync(string layerJson, string? beforeLayerId = null)

Parameters

layerJson string
beforeLayerId string

Returns

Task<CommandCompletion>

Remarks

layerJson is a [layer](https://maplibre.org/maplibre-style-spec/layers/) object. The layer goes below the layer named beforeLayerId, or above every layer when beforeLayerId is empty.

See mln_map_add_style_layer_json in the C API reference.

Errors:

  • Status.NotFound when the style has no layer named beforeLayerId, or no source with the ID that the layer uses.
  • Status.AlreadyExists when the style already has a layer with the new layer's ID.
  • Status.InvalidState while the style isn't loaded, as MapHandle.SetStyleUrlAsync() describes.

AddStyleSourceJsonAsync(string, string)

Adds a source to the map's style.

public Task<CommandCompletion> AddStyleSourceJsonAsync(string sourceId, string sourceJson)

Parameters

sourceId string
sourceJson string

Returns

Task<CommandCompletion>

Remarks

sourceJson is a [source](https://maplibre.org/maplibre-style-spec/sources/) object.

See mln_map_add_style_source_json in the C API reference.

Errors:

  • Status.AlreadyExists when the style already has a source named sourceId.
  • Status.InvalidState while the style isn't loaded, as MapHandle.SetStyleUrlAsync() describes.

ApplyCameraDeltaAsync(CameraDelta)

Moves the camera relative to where it is, as a gesture does.

public Task<CommandCompletion> ApplyCameraDeltaAsync(CameraDelta delta)

Parameters

delta CameraDelta

Returns

Task<CommandCompletion>

Remarks

delta can pan the map's content by an offset on the screen, scale the zoom, and add to the bearing and pitch. An anchor keeps one screen point in place while the scale, bearing, or pitch changes. An anchor needs one of those changes, and combines with an offset only when the delta has no animation. The function finishes when the map applies the delta, before an animation ends.

A delta that replaces an animated one starts from where that animation left the camera, so the rest of the replaced change never happens. To reach an exact camera, use MapHandle.UpdateCameraAsync().

A delta in the end phase can carry momentum, which keeps the camera moving from the gesture's release velocities and slows it on each rendered frame. The gesture lasts until the momentum ends: the snapshot keeps gesture_in_progress set, and camera events report CameraChangeSource.Momentum. With momentum, animation sets only transition_id and the end handler, which runs when the gesture ends.

A delta in the begin phase, MapHandle.CancelCameraTransitionsAsync(), or a cancellation by that ID stops the momentum. A later command that sets a field stops only the parts of the momentum that move that field. On a tilted map, the pan moves the map's content the same distance on the screen in every direction.

See mln_map_apply_camera_delta in the C API reference.

AttachAndroidHardwareBufferRing(AndroidHardwareBufferRingDescriptor, VulkanDeviceHandle?, RenderSessionAttachOptions)

Creates a session that renders the map into a ring of Android hardware buffers that the library allocates.

public RenderSessionHandle AttachAndroidHardwareBufferRing(AndroidHardwareBufferRingDescriptor descriptor, VulkanDeviceHandle? device, RenderSessionAttachOptions options)

Parameters

descriptor AndroidHardwareBufferRingDescriptor
device VulkanDeviceHandle
options RenderSessionAttachOptions

Returns

RenderSessionHandle

Remarks

Acquire each frame with RenderSessionHandle.AcquireFrame(), and get its buffer with AcquiredFrameHandle.WithAndroidHardwareBuffer(). RenderSessionHandle.ResizeAsync() gives the ring new buffers of the new size.

A Vulkan build renders with device, or, when device is null, with a device that the library creates. An OpenGL build uses an EGL context on the default display, and device must be null. Attach with RenderDriverKind.CoreWorker.

To show the buffers through Android's UI, such as with Bitmap.wrapHardwareBuffer, attach without GpuSyncKindFlag.SyncFd in RenderSessionAttachOptions.ProducerSyncKinds, so that each frame finishes before you acquire it. Keep each frame acquired until the next one replaces it on screen, then release it with GpuSyncKind.CpuComplete. Give the ring 3 buffers, so the session can render while you hold two frames.

See mln_map_attach_android_hardware_buffer_ring in the C API reference.

Errors:

  • Status.Unsupported when Android is older than 8.0, API level 26, or when the graphics context can't render into hardware buffers: the Vulkan device lacks VK_ANDROID_external_memory_android_hardware_buffer, or the EGL display lacks EGL_ANDROID_get_native_client_buffer or EGL_ANDROID_image_native_buffer.
  • Status.NativeError when the library can't create its Vulkan device or initialize the default EGL display.

AttachAndroidSurface(AndroidSurfaceDescriptor, VulkanDeviceHandle?, RenderSessionAttachOptions)

Creates a session that presents the map to an Android window, with a graphics context that the library creates.

public RenderSessionHandle AttachAndroidSurface(AndroidSurfaceDescriptor descriptor, VulkanDeviceHandle? device, RenderSessionAttachOptions options)

Parameters

descriptor AndroidSurfaceDescriptor
device VulkanDeviceHandle
options RenderSessionAttachOptions

Returns

RenderSessionHandle

Remarks

A Vulkan build presents with device, or, when device is null, with a device that the library creates. An OpenGL build uses an EGL context on the default display, and device must be null. Attach with RenderDriverKind.CoreWorker.

When the platform destroys the window, such as in SurfaceHolder.Callback.surfaceDestroyed, release the target with RenderSessionHandle.ReleaseTargetAsync(), or give the session a new window with RenderSessionHandle.SetAndroidSurfaceTargetAsync(), without waiting for that to complete. The session keeps its own reference to the window and stays usable for the next window. A frame to the destroyed window finishes with RenderResult.TargetNotReady, or with RenderResult.Rendered if the window went away while the frame was presenting.

See mln_map_attach_android_surface in the C API reference.

Errors:

  • Status.InvalidArgument when surface has no window, such as after the platform destroyed it.
  • Status.Unsupported when you created device without VulkanDeviceOptions.Presentation.
  • Status.Unsupported when the GPU or the Vulkan loader can't present.
  • Status.NativeError when the library can't create the graphics context or the window's surface.

AttachDmaBufRing(DmaBufRingDescriptor, VulkanDeviceHandle?, RenderSessionAttachOptions)

Creates a session that renders the map into a ring of dmabufs that the library allocates.

public RenderSessionHandle AttachDmaBufRing(DmaBufRingDescriptor descriptor, VulkanDeviceHandle? device, RenderSessionAttachOptions options)

Parameters

descriptor DmaBufRingDescriptor
device VulkanDeviceHandle
options RenderSessionAttachOptions

Returns

RenderSessionHandle

Remarks

Acquire each frame with RenderSessionHandle.AcquireFrame(), and get its buffer with AcquiredFrameHandle.WithDmaBuf(). RenderSessionHandle.ResizeAsync() gives the ring new buffers of the new size.

A Vulkan build renders with device, or, when device is null, with a device that the library creates. An OpenGL build uses an EGL context of its own, and device must be null. Attach with RenderDriverKind.CoreWorker.

For a reader that waits on no sync file, such as a Wayland compositor without explicit synchronization, attach without GpuSyncKindFlag.SyncFd in RenderSessionAttachOptions.ProducerSyncKinds, so that each frame finishes before you acquire it. Keep each frame acquired until its reader is done with the buffer. Give the ring 3 buffers, so the session can render while you hold two frames.

See mln_map_attach_dma_buf_ring in the C API reference.

Errors:

  • Status.Unsupported when the graphics context can't render into a dmabuf of any of formats.
  • Status.NativeError when the library can't create its Vulkan device or initialize an EGL display.

AttachDxgiSharedTextureRing(DxgiSharedTextureRingDescriptor, VulkanDeviceHandle?, RenderSessionAttachOptions)

Creates a session that renders the map into a ring of DXGI shared textures that the library allocates.

public RenderSessionHandle AttachDxgiSharedTextureRing(DxgiSharedTextureRingDescriptor descriptor, VulkanDeviceHandle? device, RenderSessionAttachOptions options)

Parameters

descriptor DxgiSharedTextureRingDescriptor
device VulkanDeviceHandle
options RenderSessionAttachOptions

Returns

RenderSessionHandle

Remarks

Acquire each frame with RenderSessionHandle.AcquireFrame(), and get its texture with AcquiredFrameHandle.WithDxgiSharedTexture(). RenderSessionHandle.ResizeAsync() gives the ring new textures of the new size.

The session renders with the Vulkan device device, or, when device is null, with one that the library creates. The textures belong to the device's GPU, so open them on a D3D11 or D3D12 device of the same adapter. To pick the GPU, create device with VulkanDeviceOptions.DeviceLuid set to your adapter's LUID. Attach with RenderDriverKind.CoreWorker.

For a reader that waits on no fence, such as Flutter's texture registrar, attach without GpuSyncKindFlag.D3d12Fence in RenderSessionAttachOptions.ProducerSyncKinds, so that each frame finishes before you acquire it. Release a frame with GpuSyncKind.CpuComplete only once the reader has finished with its texture.

See mln_map_attach_dxgi_shared_texture_ring in the C API reference.

Errors:

  • Status.Unsupported in an OpenGL build, or when the GPU can't share the textures: D3D11 has no adapter with the Vulkan device's LUID or can't share textures through NT handles, or the device lacks VK_KHR_external_memory_win32 or can't import D3D11 textures.
  • Status.NativeError when the library can't create its Vulkan device or a D3D11 device on the adapter.

AttachIoSurfaceRing(IoSurfaceRingDescriptor, RenderSessionAttachOptions)

Creates a session that renders the map into a ring of IOSurfaces that the library allocates.

public RenderSessionHandle AttachIoSurfaceRing(IoSurfaceRingDescriptor descriptor, RenderSessionAttachOptions options)

Parameters

descriptor IoSurfaceRingDescriptor
options RenderSessionAttachOptions

Returns

RenderSessionHandle

Remarks

Acquire each frame with RenderSessionHandle.AcquireFrame(), and get its surface with AcquiredFrameHandle.WithIoSurface(). RenderSessionHandle.ResizeAsync() gives the ring new surfaces of the new size. Attach with RenderDriverKind.CoreWorker.

To hand frames to a reader that can't wait on an event, such as Flutter's copyPixelBuffer, attach without GpuSyncKindFlag.MetalSharedEvent in RenderSessionAttachOptions.ProducerSyncKinds, so that each frame finishes before you acquire it. Release a frame with GpuSyncKind.CpuComplete only once the reader has finished with its surface.

See mln_map_attach_io_surface_ring in the C API reference.

Errors:

  • Status.Unsupported when MaplibreNative.SupportedRenderBackendMask() lacks RenderBackendFlag.Metal.
  • Status.NativeError when context names no device and the system has no Metal device.

AttachMetalBorrowedTexture(MetalBorrowedTextureDescriptor, RenderSessionAttachOptions)

Creates a session that renders the map into a ring of your Metal textures.

public RenderSessionHandle AttachMetalBorrowedTexture(MetalBorrowedTextureDescriptor descriptor, RenderSessionAttachOptions options)

Parameters

descriptor MetalBorrowedTextureDescriptor
options RenderSessionAttachOptions

Returns

RenderSessionHandle

Remarks

See mln_map_attach_metal_borrowed_texture in the C API reference.

Errors:

  • Status.Unsupported when MaplibreNative.SupportedRenderBackendMask() lacks RenderBackendFlag.Metal, or when the target supports none of the producer_sync_kinds in options.

AttachMetalSurface(MetalSurfaceDescriptor, RenderSessionAttachOptions)

Creates a session that renders the map to a Metal layer.

public RenderSessionHandle AttachMetalSurface(MetalSurfaceDescriptor descriptor, RenderSessionAttachOptions options)

Parameters

descriptor MetalSurfaceDescriptor
options RenderSessionAttachOptions

Returns

RenderSessionHandle

Remarks

See mln_map_attach_metal_surface in the C API reference.

Errors:

  • Status.Unsupported when MaplibreNative.SupportedRenderBackendMask() lacks RenderBackendFlag.Metal.

AttachOffscreen(OffscreenDescriptor, RenderSessionAttachOptions, OffscreenDeviceHandle?)

Attaches a render session that renders the map offscreen.

public RenderSessionHandle AttachOffscreen(OffscreenDescriptor descriptor, RenderSessionAttachOptions options, OffscreenDeviceHandle? device = null)

Parameters

descriptor OffscreenDescriptor
options RenderSessionAttachOptions
device OffscreenDeviceHandle

Returns

RenderSessionHandle

Remarks

Read each image's pixels with RenderSessionHandle.ReadTextureAsync().

The session renders on device. When device is null, the session creates a device with the default options, and releases it when the session ends.

See mln_map_attach_offscreen in the C API reference.

Errors:

  • Status.InvalidState when the map already has a render session.
  • Status.NativeError when device is null and the platform can't create a device.

AttachOpenGlBorrowedTexture(OpenGlBorrowedTextureDescriptor, RenderSessionAttachOptions)

Creates a session that renders the map into a ring of your OpenGL textures.

public RenderSessionHandle AttachOpenGlBorrowedTexture(OpenGlBorrowedTextureDescriptor descriptor, RenderSessionAttachOptions options)

Parameters

descriptor OpenGlBorrowedTextureDescriptor
options RenderSessionAttachOptions

Returns

RenderSessionHandle

Remarks

See mln_map_attach_open_gl_borrowed_texture in the C API reference.

Errors:

  • Status.Unsupported when MaplibreNative.OpenGlSupportedContextProviderMask() lacks the context's platform, or when the target supports none of the producer_sync_kinds in options.

AttachOpenGlSurface(OpenGlSurfaceDescriptor, RenderSessionAttachOptions)

Creates a session that renders the map to an OpenGL surface.

public RenderSessionHandle AttachOpenGlSurface(OpenGlSurfaceDescriptor descriptor, RenderSessionAttachOptions options)

Parameters

descriptor OpenGlSurfaceDescriptor
options RenderSessionAttachOptions

Returns

RenderSessionHandle

Remarks

See mln_map_attach_open_gl_surface in the C API reference.

Errors:

  • Status.Unsupported when MaplibreNative.OpenGlSupportedContextProviderMask() lacks the context's platform.

AttachVulkanBorrowedTexture(VulkanBorrowedTextureDescriptor, RenderSessionAttachOptions)

Creates a session that renders the map into a ring of your Vulkan images.

public RenderSessionHandle AttachVulkanBorrowedTexture(VulkanBorrowedTextureDescriptor descriptor, RenderSessionAttachOptions options)

Parameters

descriptor VulkanBorrowedTextureDescriptor
options RenderSessionAttachOptions

Returns

RenderSessionHandle

Remarks

See mln_map_attach_vulkan_borrowed_texture in the C API reference.

Errors:

  • Status.Unsupported when MaplibreNative.SupportedRenderBackendMask() lacks RenderBackendFlag.Vulkan, or when the target supports none of the producer_sync_kinds in options.

AttachVulkanSurface(VulkanSurfaceDescriptor, RenderSessionAttachOptions)

Creates a session that renders the map to a Vulkan surface.

public RenderSessionHandle AttachVulkanSurface(VulkanSurfaceDescriptor descriptor, RenderSessionAttachOptions options)

Parameters

descriptor VulkanSurfaceDescriptor
options RenderSessionAttachOptions

Returns

RenderSessionHandle

Remarks

See mln_map_attach_vulkan_surface in the C API reference.

Errors:

  • Status.Unsupported when MaplibreNative.SupportedRenderBackendMask() lacks RenderBackendFlag.Vulkan.

AttachWaylandSurface(WaylandSurfaceDescriptor, VulkanDeviceHandle?, RenderSessionAttachOptions)

Creates a session that presents the map to a Wayland surface, with a graphics context that the library creates.

public RenderSessionHandle AttachWaylandSurface(WaylandSurfaceDescriptor descriptor, VulkanDeviceHandle? device, RenderSessionAttachOptions options)

Parameters

descriptor WaylandSurfaceDescriptor
device VulkanDeviceHandle
options RenderSessionAttachOptions

Returns

RenderSessionHandle

Remarks

A Vulkan build presents with device, or, when device is null, with a device that the library creates. An OpenGL build uses an EGL context on the display, and device must be null. Attach with RenderDriverKind.CoreWorker.

The session presents without waiting for the compositor, so demand at most one frame per display refresh.

Keep the surface until a release or replacement of the target, or a detach of the session, completes. Keep the display connected until the session's detach completes. In an OpenGL build, if you also use EGL on the display, initialize it before you attach.

See mln_map_attach_wayland_surface in the C API reference.

Errors:

  • Status.Unsupported when you created device without VulkanDeviceOptions.Presentation.
  • Status.Unsupported when the GPU or the Vulkan loader can't present to Wayland.
  • Status.NativeError when the library can't create the graphics context or present to the surface.

AttachWin32Window(Win32WindowDescriptor, VulkanDeviceHandle?, RenderSessionAttachOptions)

Creates a session that presents the map to a Win32 window, with a graphics context that the library creates.

public RenderSessionHandle AttachWin32Window(Win32WindowDescriptor descriptor, VulkanDeviceHandle? device, RenderSessionAttachOptions options)

Parameters

descriptor Win32WindowDescriptor
device VulkanDeviceHandle
options RenderSessionAttachOptions

Returns

RenderSessionHandle

Remarks

A Vulkan build presents with device, or, when device is null, with a device that the library creates. An OpenGL build uses a WGL context, and device must be null. Attach with RenderDriverKind.CoreWorker.

An OpenGL build sets the window's pixel format, so don't set one yourself.

The session presents without waiting for the display, so demand at most one frame per display refresh. While the window is minimized, frame demands finish with RenderResult.TargetNotReady.

Keep the window until a release or replacement of the target, or a detach of the session, completes.

See mln_map_attach_win32_window in the C API reference.

Errors:

  • Status.InvalidArgument when window isn't a window, or, in an OpenGL build, already has another pixel format.
  • Status.InvalidState when window is minimized or has no client area.
  • Status.Unsupported when you created device without VulkanDeviceOptions.Presentation.
  • Status.InvalidState when window was minimized before the attach ran.
  • Status.Unsupported when the GPU or the Vulkan loader can't present.
  • Status.NativeError when the library can't create the graphics context or present to the window.

BeginCommandGroupAsync()

Holds back the map's changes from rendering until MapHandle.EndCommandGroupAsync(), so they show in the same frame.

public Task<CommandCompletion> BeginCommandGroupAsync()

Returns

Task<CommandCompletion>

Remarks

Groups nest, and the changes render when the outermost group ends.

See mln_map_begin_command_group in the C API reference.

CameraForGeometryAsync(string, CameraFitOptions?)

Computes a camera that fits a GeoJSON geometry in the map's view.

public Task<CameraOptions> CameraForGeometryAsync(string geometry, CameraFitOptions? fitOptions = null)

Parameters

geometry string
fitOptions CameraFitOptions

Returns

Task<CameraOptions>

Remarks

geometry is a GeoJSON geometry object with at least one coordinate, not a feature. The camera keeps the map's bearing and pitch unless fitOptions sets them, and its zoom stays within the map's zoom limits.

See mln_map_camera_for_geometry in the C API reference.

Errors:

  • Status.InvalidArgument when the padding in fitOptions leaves no room for the area.

CameraForLatLngBoundsAsync(LatLngBounds, CameraFitOptions?)

Computes a camera that fits bounds in the map's view.

public Task<CameraOptions> CameraForLatLngBoundsAsync(LatLngBounds bounds, CameraFitOptions? fitOptions = null)

Parameters

bounds LatLngBounds
fitOptions CameraFitOptions

Returns

Task<CameraOptions>

Remarks

The camera keeps the map's bearing and pitch unless fitOptions sets them, and its zoom stays within the map's zoom limits.

See mln_map_camera_for_lat_lng_bounds in the C API reference.

Errors:

  • Status.InvalidArgument when the padding in fitOptions leaves no room for the area.

CameraForLatLngsAsync(LatLng[], CameraFitOptions?)

Computes a camera that fits coordinates in the map's view.

public Task<CameraOptions> CameraForLatLngsAsync(LatLng[] coordinates, CameraFitOptions? fitOptions = null)

Parameters

coordinates LatLng[]
fitOptions CameraFitOptions

Returns

Task<CameraOptions>

Remarks

coordinates must not be empty. The camera keeps the map's bearing and pitch unless fitOptions sets them, and its zoom stays within the map's zoom limits.

See mln_map_camera_for_lat_lngs in the C API reference.

Errors:

  • Status.InvalidArgument when the padding in fitOptions leaves no room for the area.

CancelCameraTransitionsAsync()

Stops every running camera animation where it is.

public Task<CommandCompletion> CancelCameraTransitionsAsync()

Returns

Task<CommandCompletion>

Remarks

The end handler of each stopped animation reports CameraTransitionOutcome.Cancelled.

See mln_map_cancel_camera_transitions in the C API reference.

CancelCameraTransitionsWithIdAsync(ulong)

Stops the running camera animations whose animation options set transitionId.

public Task<CommandCompletion> CancelCameraTransitionsWithIdAsync(ulong transitionId)

Parameters

transitionId ulong

Returns

Task<CommandCompletion>

Remarks

Other animations keep running. The end handler of each stopped animation reports CameraTransitionOutcome.Cancelled.

See mln_map_cancel_camera_transitions_with_id in the C API reference.

Dispose()

Releases the map in any state, and finishes in the background.

public void Dispose()

Remarks

Use it from destructors and finalizers. Otherwise, use MapHandle.ReleaseAsync().

See mln_map_dispose in the C API reference.

DumpDebugLogsAsync()

Logs debugging information about the map's style and sources.

public Task<CommandCompletion> DumpDebugLogsAsync()

Returns

Task<CommandCompletion>

Remarks

See mln_map_dump_debug_logs in the C API reference.

EndCommandGroupAsync()

Ends the group that MapHandle.BeginCommandGroupAsync() began.

public Task<CommandCompletion> EndCommandGroupAsync()

Returns

Task<CommandCompletion>

Remarks

See mln_map_end_command_group in the C API reference.

FitCameraToGeometryAsync(string, CameraFitUpdate)

Moves the camera to fit a GeoJSON geometry in the map's view, at once or with an animation.

public Task<CommandCompletion> FitCameraToGeometryAsync(string geometry, CameraFitUpdate update)

Parameters

geometry string
update CameraFitUpdate

Returns

Task<CommandCompletion>

Remarks

geometry is a GeoJSON geometry object with at least one coordinate, not a feature. The camera is the one that MapHandle.CameraForGeometryAsync() computes after the commands sent before this one apply. The function finishes when the map applies the change, before an animation ends.

See mln_map_fit_camera_to_geometry in the C API reference.

Errors:

  • Status.InvalidArgument when the padding in update leaves no room for the area. The camera doesn't move.

FitCameraToLatLngBoundsAsync(LatLngBounds, CameraFitUpdate)

Moves the camera to fit bounds in the map's view, at once or with an animation.

public Task<CommandCompletion> FitCameraToLatLngBoundsAsync(LatLngBounds bounds, CameraFitUpdate update)

Parameters

bounds LatLngBounds
update CameraFitUpdate

Returns

Task<CommandCompletion>

Remarks

The camera is the one that MapHandle.CameraForLatLngBoundsAsync() computes after the commands sent before this one apply. The function finishes when the map applies the change, before an animation ends.

See mln_map_fit_camera_to_lat_lng_bounds in the C API reference.

Errors:

  • Status.InvalidArgument when the padding in update leaves no room for the area. The camera doesn't move.

FitCameraToLatLngsAsync(LatLng[], CameraFitUpdate)

Moves the camera to fit coordinates in the map's view, at once or with an animation.

public Task<CommandCompletion> FitCameraToLatLngsAsync(LatLng[] coordinates, CameraFitUpdate update)

Parameters

coordinates LatLng[]
update CameraFitUpdate

Returns

Task<CommandCompletion>

Remarks

coordinates must not be empty. The camera is the one that MapHandle.CameraForLatLngsAsync() computes after the commands sent before this one apply. The function finishes when the map applies the change, before an animation ends.

See mln_map_fit_camera_to_lat_lngs in the C API reference.

Errors:

  • Status.InvalidArgument when the padding in update leaves no room for the area. The camera doesn't move.

GetCameraAsync()

Reads the map's camera.

public Task<CameraQueryResult> GetCameraAsync()

Returns

Task<CameraQueryResult>

Remarks

The query reads the camera after the map applies the commands sent before it.

See mln_map_get_camera in the C API reference.

GetFeatureStateAsync(FeatureStateSelector)

Reads the state of a feature, as a JSON object.

public Task<string> GetFeatureStateAsync(FeatureStateSelector selector)

Parameters

selector FeatureStateSelector

Returns

Task<string>

Remarks

The object is empty when the feature has no state.

See mln_map_get_feature_state in the C API reference.

GetGlobalStateAsync()

Reads the global state of the map's style as a JSON object.

public Task<string> GetGlobalStateAsync()

Returns

Task<string>

Remarks

See mln_map_get_global_state in the C API reference.

GetImageSourceCoordinatesAsync(string)

Reads the corners of an image source's image, clockwise from the top left.

public Task<LatLng[]> GetImageSourceCoordinatesAsync(string sourceId)

Parameters

sourceId string

Returns

Task<LatLng[]>

Remarks

See mln_map_get_image_source_coordinates in the C API reference.

Errors:

  • Status.NotFound when the style has no source named sourceId.
  • Status.InvalidArgument when the source named sourceId isn't an image source.

GetLoadedStyleJsonAsync()

Reads the JSON of the style that the map loaded.

public Task<string> GetLoadedStyleJsonAsync()

Returns

Task<string>

Remarks

The JSON doesn't include the changes made to the style since it loaded.

See mln_map_get_loaded_style_json in the C API reference.

GetSnapshot()

Copies the map's state.

public MapSnapshot GetSnapshot()

Returns

MapSnapshot

Remarks

The copy doesn't wait for pending commands. To read the camera after they apply, use MapHandle.GetCameraAsync().

See mln_map_get_snapshot in the C API reference.

Errors:

  • Status.InvalidState until RuntimeHandle.CreateMap() completes with Status.Ok.

GetStyleImageAsync(string)

Reads an image of the map's style.

public Task<StyleImageInfo?> GetStyleImageAsync(string imageId)

Parameters

imageId string

Returns

Task<StyleImageInfo>

Remarks

Completes with no value when the style has no image named imageId.

See mln_map_get_style_image in the C API reference.

GetStyleLayerAsync(string)

Reads a layer of the map's style.

public Task<StyleLayerInfo?> GetStyleLayerAsync(string layerId)

Parameters

layerId string

Returns

Task<StyleLayerInfo?>

Remarks

Completes with no value when the style has no layer named layerId.

See mln_map_get_style_layer in the C API reference.

GetStyleLayerJsonAsync(string)

Reads a layer of the map's style as a layer object.

public Task<string?> GetStyleLayerJsonAsync(string layerId)

Parameters

layerId string

Returns

Task<string>

Remarks

Completes with no value when the style has no layer named layerId.

See mln_map_get_style_layer_json in the C API reference.

GetStyleLayerPropertyAsync(string, string)

Reads a property of a layer in the map's style.

public Task<string?> GetStyleLayerPropertyAsync(string layerId, string propertyName)

Parameters

layerId string
propertyName string

Returns

Task<string>

Remarks

The value can differ in form from the value that was set: a color set as "#ff0000" reads back as ["rgba", 255, 0, 0, 1].

Completes with no value when the layer doesn't set the property.

See mln_map_get_style_layer_property in the C API reference.

Errors:

  • Status.NotFound when the style has no layer named layerId.

GetStyleLightPropertyAsync(string)

Reads a property of the light of the map's style.

public Task<string?> GetStyleLightPropertyAsync(string propertyName)

Parameters

propertyName string

Returns

Task<string>

Remarks

The value can differ in form from the value that was set: a color set as "#ff0000" reads back as ["rgba", 255, 0, 0, 1].

Completes with no value when the light doesn't set the property.

See mln_map_get_style_light_property in the C API reference.

GetStyleSourceAsync(string)

Reads a source of the map's style.

public Task<StyleSourceInfo?> GetStyleSourceAsync(string sourceId)

Parameters

sourceId string

Returns

Task<StyleSourceInfo>

Remarks

A tile source with a url has an empty attribution until its TileJSON loads, which raises RuntimeEventType.MapSourceChanged.

Completes with no value when the style has no source named sourceId.

See mln_map_get_style_source in the C API reference.

GetStyleTransitionOptionsAsync()

Reads the default transition of the map's style.

public Task<StyleTransitionOptions> GetStyleTransitionOptionsAsync()

Returns

Task<StyleTransitionOptions>

Remarks

See mln_map_get_style_transition_options in the C API reference.

GetStyleUrlAsync()

Reads the URL of the map's style.

public Task<string> GetStyleUrlAsync()

Returns

Task<string>

Remarks

The URL is empty when the style came from MapHandle.SetStyleJsonAsync().

See mln_map_get_style_url in the C API reference.

InvalidateCustomGeometrySourceRegionAsync(string, LatLngBounds)

Makes a custom geometry source ask again for the tiles in bounds that the map still needs.

public Task<CommandCompletion> InvalidateCustomGeometrySourceRegionAsync(string sourceId, LatLngBounds bounds)

Parameters

sourceId string
bounds LatLngBounds

Returns

Task<CommandCompletion>

Remarks

See mln_map_invalidate_custom_geometry_source_region in the C API reference.

Errors:

  • Status.NotFound when the style has no source named sourceId.
  • Status.InvalidArgument when the source named sourceId isn't a custom geometry source.

InvalidateCustomGeometrySourceTileAsync(string, CanonicalTileId)

Makes a custom geometry source ask for a tile again when the map needs it.

public Task<CommandCompletion> InvalidateCustomGeometrySourceTileAsync(string sourceId, CanonicalTileId tileId)

Parameters

sourceId string
tileId CanonicalTileId

Returns

Task<CommandCompletion>

Remarks

See mln_map_invalidate_custom_geometry_source_tile in the C API reference.

Errors:

  • Status.NotFound when the style has no source named sourceId.
  • Status.InvalidArgument when the source named sourceId isn't a custom geometry source.

InvalidateCustomVectorSourceRegionAsync(string, LatLngBounds)

Makes a custom vector source ask again for the tiles in bounds that the map still needs.

public Task<CommandCompletion> InvalidateCustomVectorSourceRegionAsync(string sourceId, LatLngBounds bounds)

Parameters

sourceId string
bounds LatLngBounds

Returns

Task<CommandCompletion>

Remarks

See mln_map_invalidate_custom_vector_source_region in the C API reference.

Errors:

  • Status.NotFound when the style has no source named sourceId.
  • Status.InvalidArgument when the source named sourceId isn't a custom vector source.

InvalidateCustomVectorSourceTileAsync(string, CanonicalTileId)

Makes a custom vector source ask for a tile again when the map needs it.

public Task<CommandCompletion> InvalidateCustomVectorSourceTileAsync(string sourceId, CanonicalTileId tileId)

Parameters

sourceId string
tileId CanonicalTileId

Returns

Task<CommandCompletion>

Remarks

See mln_map_invalidate_custom_vector_source_tile in the C API reference.

Errors:

  • Status.NotFound when the style has no source named sourceId.
  • Status.InvalidArgument when the source named sourceId isn't a custom vector source.

LatLngBoundsForCameraAsync(CameraOptions)

Computes the area that the map would show with camera.

public Task<LatLngBounds> LatLngBoundsForCameraAsync(CameraOptions camera)

Parameters

camera CameraOptions

Returns

Task<LatLngBounds>

Remarks

Camera fields that camera doesn't set come from the map's camera. The longitudes can fall outside -180 to 180, so a view across the antimeridian gives one continuous range.

See mln_map_lat_lng_bounds_for_camera in the C API reference.

ListStyleLayersAsync()

Lists the layers of the map's style, from bottom to top.

public Task<StyleLayerInfo[]> ListStyleLayersAsync()

Returns

Task<StyleLayerInfo[]>

Remarks

See mln_map_list_style_layers in the C API reference.

ListStyleSourcesAsync()

Lists the sources of the map's style.

public Task<StyleSourceInfo[]> ListStyleSourcesAsync()

Returns

Task<StyleSourceInfo[]>

Remarks

See mln_map_list_style_sources in the C API reference.

MoveStyleLayerAsync(string, string?)

Moves a layer of the map's style below the layer named beforeLayerId, or above every layer when beforeLayerId is empty.

public Task<CommandCompletion> MoveStyleLayerAsync(string layerId, string? beforeLayerId = null)

Parameters

layerId string
beforeLayerId string

Returns

Task<CommandCompletion>

Remarks

See mln_map_move_style_layer in the C API reference.

Errors:

  • Status.NotFound when the style has no layer named layerId or beforeLayerId.
  • Status.InvalidState while the style isn't loaded, as MapHandle.SetStyleUrlAsync() describes.

ReleaseAsync()

Releases the map.

public Task ReleaseAsync()

Returns

Task

Remarks

Detach the map's render session first.

See mln_map_release in the C API reference.

RemoveFeatureStateAsync(FeatureStateSelector)

Removes the feature state that selector selects.

public Task<CommandCompletion> RemoveFeatureStateAsync(FeatureStateSelector selector)

Parameters

selector FeatureStateSelector

Returns

Task<CommandCompletion>

Remarks

See mln_map_remove_feature_state in the C API reference.

RemoveStyleImageAsync(string)

Removes an image from the map's style.

public Task<CommandCompletion> RemoveStyleImageAsync(string imageId)

Parameters

imageId string

Returns

Task<CommandCompletion>

Remarks

See mln_map_remove_style_image in the C API reference.

Errors:

  • Status.NotFound when the style has no image named imageId.
  • Status.InvalidState while the style isn't loaded, as MapHandle.SetStyleUrlAsync() describes.

RemoveStyleLayerAsync(string)

Removes a layer from the map's style.

public Task<CommandCompletion> RemoveStyleLayerAsync(string layerId)

Parameters

layerId string

Returns

Task<CommandCompletion>

Remarks

See mln_map_remove_style_layer in the C API reference.

Errors:

  • Status.NotFound when the style has no layer named layerId.
  • Status.InvalidState while the style isn't loaded, as MapHandle.SetStyleUrlAsync() describes.

RemoveStyleSourceAsync(string)

Removes a source from the map's style.

public Task<CommandCompletion> RemoveStyleSourceAsync(string sourceId)

Parameters

sourceId string

Returns

Task<CommandCompletion>

Remarks

See mln_map_remove_style_source in the C API reference.

Errors:

  • Status.NotFound when the style has no source named sourceId.
  • Status.InvalidState when a layer still uses the source, or while the style isn't loaded, as MapHandle.SetStyleUrlAsync() describes.

RequestRepaintAsync()

Renders a new frame of a continuous map, even when nothing changed.

public Task<CommandCompletion> RequestRepaintAsync()

Returns

Task<CommandCompletion>

Remarks

See mln_map_request_repaint in the C API reference.

RequestStillImageAsync()

Renders a still image of a static or tile map.

public Task RequestStillImageAsync()

Returns

Task

Remarks

The map's render session draws the image once every resource that the image needs has loaded.

See mln_map_request_still_image in the C API reference.

Errors:

  • Status.Cancelled when the map is released before the image is done.
  • Status.NativeError when the style or a resource that the image needs fails to load.

ResizeAsync(LogicalSize)

Sets the map's size.

public Task<CommandCompletion> ResizeAsync(LogicalSize logicalSize)

Parameters

logicalSize LogicalSize

Returns

Task<CommandCompletion>

Remarks

A map with a render session takes its size from the session, so resize the session with RenderSessionHandle.ResizeAsync() instead.

See mln_map_resize in the C API reference.

Errors:

  • Status.InvalidState when the map has a render session.
  • Status.InvalidState when a render session attached to the map before the resize applied.

SetBoundsAsync(BoundOptions)

Limits the camera's center to an area, and its zoom and pitch to ranges.

public Task<CommandCompletion> SetBoundsAsync(BoundOptions options)

Parameters

options BoundOptions

Returns

Task<CommandCompletion>

Remarks

Limits that options doesn't set keep their current values. When the camera is outside the new limits, it moves inside them.

See mln_map_set_bounds in the C API reference.

SetCustomGeometrySourceTileDataAsync(string, CanonicalTileId, string)

Sets the data of a tile in a custom geometry source.

public Task<CommandCompletion> SetCustomGeometrySourceTileDataAsync(string sourceId, CanonicalTileId tileId, string data)

Parameters

sourceId string
tileId CanonicalTileId
data string

Returns

Task<CommandCompletion>

Remarks

data is a GeoJSON feature collection, feature, or geometry. The source ignores data for a tile that it hasn't asked for, or has since cancelled.

See mln_map_set_custom_geometry_source_tile_data in the C API reference.

Errors:

  • Status.NotFound when the style has no source named sourceId.
  • Status.InvalidArgument when the source named sourceId isn't a custom geometry source.

SetCustomGeometrySourceTileErrorAsync(string, CanonicalTileId, string)

Reports that a tile of a custom geometry source failed to load.

public Task<CommandCompletion> SetCustomGeometrySourceTileErrorAsync(string sourceId, CanonicalTileId tileId, string message)

Parameters

sourceId string
tileId CanonicalTileId
message string

Returns

Task<CommandCompletion>

Remarks

See mln_map_set_custom_geometry_source_tile_error in the C API reference.

Errors:

  • Status.NotFound when the style has no source named sourceId.
  • Status.InvalidArgument when the source named sourceId isn't a custom geometry source.

SetCustomVectorSourceTileDataAsync(string, CanonicalTileId, StyleVectorTileEncoding, ReadOnlySpan<byte>)

Sets the data of a tile in a custom vector source.

public Task<CommandCompletion> SetCustomVectorSourceTileDataAsync(string sourceId, CanonicalTileId tileId, StyleVectorTileEncoding encoding, ReadOnlySpan<byte> data)

Parameters

sourceId string
tileId CanonicalTileId
encoding StyleVectorTileEncoding
data ReadOnlySpan<byte>

Returns

Task<CommandCompletion>

Remarks

data is the tile, encoded as encoding. The source ignores data for a tile that it hasn't asked for, or has since cancelled.

See mln_map_set_custom_vector_source_tile_data in the C API reference.

Errors:

  • Status.NotFound when the style has no source named sourceId.
  • Status.InvalidArgument when the source named sourceId isn't a custom vector source.

SetCustomVectorSourceTileErrorAsync(string, CanonicalTileId, string)

Reports that a tile of a custom vector source failed to load.

public Task<CommandCompletion> SetCustomVectorSourceTileErrorAsync(string sourceId, CanonicalTileId tileId, string message)

Parameters

sourceId string
tileId CanonicalTileId
message string

Returns

Task<CommandCompletion>

Remarks

See mln_map_set_custom_vector_source_tile_error in the C API reference.

Errors:

  • Status.NotFound when the style has no source named sourceId.
  • Status.InvalidArgument when the source named sourceId isn't a custom vector source.

SetDebugFlagsAsync(MapDebugFlag)

Draws debugging overlays, such as tile borders, on the map.

public Task<CommandCompletion> SetDebugFlagsAsync(MapDebugFlag flags)

Parameters

flags MapDebugFlag

Returns

Task<CommandCompletion>

Remarks

flags replaces the overlays set before.

See mln_map_set_debug_flags in the C API reference.

SetEventMaskAsync(RuntimeEventFlag)

Selects the events that the map reports.

public Task<CommandCompletion> SetEventMaskAsync(RuntimeEventFlag mask)

Parameters

mask RuntimeEventFlag

Returns

Task<CommandCompletion>

Remarks

See mln_map_set_event_mask in the C API reference.

SetFeatureStateAsync(FeatureStateSelector, string)

Merges state into the state of a feature.

public Task<CommandCompletion> SetFeatureStateAsync(FeatureStateSelector selector, string state)

Parameters

selector FeatureStateSelector
state string

Returns

Task<CommandCompletion>

Remarks

state is a JSON object. Its keys replace the same keys in the feature's state, and the other keys stay.

See mln_map_set_feature_state in the C API reference.

SetFreeCameraOptionsAsync(FreeCameraOptions)

Places the camera at a position and orientation in space.

public Task<CommandCompletion> SetFreeCameraOptionsAsync(FreeCameraOptions options)

Parameters

options FreeCameraOptions

Returns

Task<CommandCompletion>

Remarks

The map adjusts them to a camera that it can show. It stops running camera animations first, and their end handlers report CameraTransitionOutcome.Cancelled.

See mln_map_set_free_camera_options in the C API reference.

SetGeoJsonSourceDataAsync(string, string)

Replaces the data of a GeoJSON source.

public Task<CommandCompletion> SetGeoJsonSourceDataAsync(string sourceId, string data)

Parameters

sourceId string
data string

Returns

Task<CommandCompletion>

Remarks

data is a GeoJSON feature collection, feature, or geometry. The library prepares it for the source with the source's options, off the threads that the caller and the runtime use, and 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, as MapHandle.SetGeoJsonSourceSynchronousTilingAsync() describes, the command prepares data before later commands run, so the data shows in the next frame.

See mln_map_set_geo_json_source_data in the C API reference.

Errors:

  • Status.NotFound when the style has no source named sourceId.
  • Status.InvalidArgument when the source named sourceId isn't a GeoJSON source, when data isn't valid GeoJSON, or when the source clusters and data isn't a feature collection of points. The source keeps its data.
  • Status.Cancelled when newer data for the source replaces data 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 data is ready.
  • Status.InvalidState while the style isn't loaded, as MapHandle.SetStyleUrlAsync() describes.

SetGeoJsonSourceSynchronousTilingAsync(string, bool)

Sets whether a GeoJSON source builds its tiles while the map renders.

public Task<CommandCompletion> SetGeoJsonSourceSynchronousTilingAsync(string sourceId, bool enabled)

Parameters

sourceId string
enabled bool

Returns

Task<CommandCompletion>

Remarks

Building tiles while the map renders, instead of in the background, makes new data show in the next frame. The setting replaces the synchronousUpdate member of the source's JSON, which defaults to false.

See mln_map_set_geo_json_source_synchronous_tiling in the C API reference.

Errors:

  • Status.NotFound when the style has no source named sourceId.
  • Status.InvalidArgument when the source named sourceId isn't a GeoJSON source.
  • Status.InvalidState while the style isn't loaded, as MapHandle.SetStyleUrlAsync() describes.

SetGeoJsonSourceUrlAsync(string, string)

Makes a GeoJSON source load its data from url.

public Task<CommandCompletion> SetGeoJsonSourceUrlAsync(string sourceId, string url)

Parameters

sourceId string
url string

Returns

Task<CommandCompletion>

Remarks

See mln_map_set_geo_json_source_url in the C API reference.

Errors:

  • Status.NotFound when the style has no source named sourceId.
  • Status.InvalidArgument when the source named sourceId isn't a GeoJSON source.
  • Status.InvalidState while the style isn't loaded, as MapHandle.SetStyleUrlAsync() describes.

SetGlobalStatePropertyAsync(string, string)

Sets a value that the style's global-state expressions read.

public Task<CommandCompletion> SetGlobalStatePropertyAsync(string propertyName, string value)

Parameters

propertyName string
value string

Returns

Task<CommandCompletion>

Remarks

See mln_map_set_global_state_property in the C API reference.

Errors:

  • Status.InvalidState while the style isn't loaded, as MapHandle.SetStyleUrlAsync() describes.

SetImageSourceCoordinatesAsync(string, LatLng[])

Moves the image of an image source.

public Task<CommandCompletion> SetImageSourceCoordinatesAsync(string sourceId, LatLng[] coordinates)

Parameters

sourceId string
coordinates LatLng[]

Returns

Task<CommandCompletion>

Remarks

coordinates are the image's four corners, clockwise from the top left.

See mln_map_set_image_source_coordinates in the C API reference.

Errors:

  • Status.NotFound when the style has no source named sourceId.
  • Status.InvalidArgument when the source named sourceId isn't an image source.
  • Status.InvalidState while the style isn't loaded, as MapHandle.SetStyleUrlAsync() describes.

SetImageSourceImageAsync(string, PremultipliedRgba8Image)

Replaces the image of an image source.

public Task<CommandCompletion> SetImageSourceImageAsync(string sourceId, PremultipliedRgba8Image image)

Parameters

sourceId string
image PremultipliedRgba8Image

Returns

Task<CommandCompletion>

Remarks

See mln_map_set_image_source_image in the C API reference.

Errors:

  • Status.NotFound when the style has no source named sourceId.
  • Status.InvalidArgument when the source named sourceId isn't an image source.
  • Status.InvalidState while the style isn't loaded, as MapHandle.SetStyleUrlAsync() describes.

SetImageSourceUrlAsync(string, string)

Makes an image source load its image from url.

public Task<CommandCompletion> SetImageSourceUrlAsync(string sourceId, string url)

Parameters

sourceId string
url string

Returns

Task<CommandCompletion>

Remarks

See mln_map_set_image_source_url in the C API reference.

Errors:

  • Status.NotFound when the style has no source named sourceId.
  • Status.InvalidArgument when the source named sourceId isn't an image source.
  • Status.InvalidState while the style isn't loaded, as MapHandle.SetStyleUrlAsync() describes.

SetProjectionModeAsync(ProjectionModeOptions)

Sets whether the map draws in perspective or axonometric projection, and how much it skews the view.

public Task<CommandCompletion> SetProjectionModeAsync(ProjectionModeOptions options)

Parameters

options ProjectionModeOptions

Returns

Task<CommandCompletion>

Remarks

Settings that options doesn't set keep their current values.

See mln_map_set_projection_mode in the C API reference.

SetRenderingStatsViewEnabledAsync(bool)

Shows or hides an overlay of rendering statistics on the map.

public Task<CommandCompletion> SetRenderingStatsViewEnabledAsync(bool enabled)

Parameters

enabled bool

Returns

Task<CommandCompletion>

Remarks

See mln_map_set_rendering_stats_view_enabled in the C API reference.

SetStyleImageAsync(string, PremultipliedRgba8Image, StyleImageOptions?)

Adds an image to the map's style, or replaces the image named imageId.

public Task<CommandCompletion> SetStyleImageAsync(string imageId, PremultipliedRgba8Image image, StyleImageOptions? options = null)

Parameters

imageId string
image PremultipliedRgba8Image
options StyleImageOptions

Returns

Task<CommandCompletion>

Remarks

See mln_map_set_style_image in the C API reference.

Errors:

  • Status.InvalidState while the style isn't loaded, as MapHandle.SetStyleUrlAsync() describes.

SetStyleJsonAsync(string)

Loads the map's style from json.

public Task<CommandCompletion> SetStyleJsonAsync(string json)

Parameters

json string

Returns

Task<CommandCompletion>

Remarks

The command completes once the style has parsed, and the map's style is then loaded, as MapHandle.SetStyleUrlAsync() describes. The style's sources, sprites, and glyphs load in the background.

See mln_map_set_style_json in the C API reference.

Errors:

  • Status.NativeError when json isn't a valid style. The map keeps its current style.

SetStyleLayerPropertyAsync(string, string, string)

Sets a property of a layer in the map's style.

public Task<CommandCompletion> SetStyleLayerPropertyAsync(string layerId, string propertyName, string value)

Parameters

layerId string
propertyName string
value string

Returns

Task<CommandCompletion>

Remarks

propertyName is one of the layer's layout or paint [properties](https://maplibre.org/maplibre-style-spec/layers/), or filter, minzoom, maxzoom, source, or source-layer. A null value resets any of these but source and source-layer to its default.

See mln_map_set_style_layer_property in the C API reference.

Errors:

  • Status.NotFound when the style has no layer named layerId.
  • Status.InvalidState while the style isn't loaded, as MapHandle.SetStyleUrlAsync() describes.

SetStyleLightJsonAsync(string)

Replaces the light of the map's style.

public Task<CommandCompletion> SetStyleLightJsonAsync(string lightJson)

Parameters

lightJson string

Returns

Task<CommandCompletion>

Remarks

See mln_map_set_style_light_json in the C API reference.

Errors:

  • Status.InvalidState while the style isn't loaded, as MapHandle.SetStyleUrlAsync() describes.

SetStyleLightPropertyAsync(string, string)

Sets a property of the light of the map's style.

public Task<CommandCompletion> SetStyleLightPropertyAsync(string propertyName, string value)

Parameters

propertyName string
value string

Returns

Task<CommandCompletion>

Remarks

See mln_map_set_style_light_property in the C API reference.

Errors:

  • Status.InvalidState while the style isn't loaded, as MapHandle.SetStyleUrlAsync() describes.

SetStyleSourceVolatileAsync(string, bool)

Sets whether a source is volatile.

public Task<CommandCompletion> SetStyleSourceVolatileAsync(string sourceId, bool isVolatile)

Parameters

sourceId string
isVolatile bool

Returns

Task<CommandCompletion>

Remarks

The map doesn't store the tiles of a volatile source in the persistent cache.

See mln_map_set_style_source_volatile in the C API reference.

Errors:

  • Status.NotFound when the style has no source named sourceId.
  • Status.InvalidState while the style isn't loaded, as MapHandle.SetStyleUrlAsync() describes.

SetStyleTransitionOptionsAsync(StyleTransitionOptions)

Sets the default transition of the map's style.

public Task<CommandCompletion> SetStyleTransitionOptionsAsync(StyleTransitionOptions options)

Parameters

options StyleTransitionOptions

Returns

Task<CommandCompletion>

Remarks

See mln_map_set_style_transition_options in the C API reference.

Errors:

  • Status.InvalidState while the style isn't loaded, as MapHandle.SetStyleUrlAsync() describes.

SetStyleUrlAsync(string)

Loads the map's style from url.

public Task<CommandCompletion> SetStyleUrlAsync(string url)

Parameters

url string

Returns

Task<CommandCompletion>

Remarks

The command completes once the style document has loaded and parsed. The style's sources, sprites, and glyphs then load in the background.

The map's style is loaded from the time a style document parses until the next call to this function. While the style isn't loaded, the commands that change it complete with Status.InvalidState. To change a new map's style without a style document, first load an empty style, such as {"version":8,"sources":{},"layers":[]}.

See mln_map_set_style_url in the C API reference.

Errors:

  • Status.NativeError when the style document fails to load or isn't a valid style.
  • Status.Cancelled when the map is released, or this function or MapHandle.SetStyleJsonAsync() loads another style, before the style document parses.

SetTileOptionsAsync(MapTileOptions)

Sets how the map chooses which tiles to load, and at what detail.

public Task<CommandCompletion> SetTileOptionsAsync(MapTileOptions options)

Parameters

options MapTileOptions

Returns

Task<CommandCompletion>

Remarks

Settings that options doesn't set keep their current values.

See mln_map_set_tile_options in the C API reference.

SetViewportOptionsAsync(MapViewportOptions)

Sets how the map orients and constrains its view.

public Task<CommandCompletion> SetViewportOptionsAsync(MapViewportOptions options)

Parameters

options MapViewportOptions

Returns

Task<CommandCompletion>

Remarks

Settings that options doesn't set keep their current values.

See mln_map_set_viewport_options in the C API reference.

ToString()

Names the handle's type, its Id, and whether it is closed.

public override string ToString()

Returns

string

UpdateCameraAsync(CameraUpdate)

Moves the camera, at once or with an animation.

public Task<CommandCompletion> UpdateCameraAsync(CameraUpdate update)

Parameters

update CameraUpdate

Returns

Task<CommandCompletion>

Remarks

Camera fields that update doesn't set keep their values, and the update stops any running animation of the fields it sets. The function finishes when the map applies the update, before an animation ends. To learn when an animation ends, set an CameraTransitionHandler in its animation options.

See mln_map_update_camera in the C API reference.