Table of Contents

Class MapProjectionHandle

Namespace
Maplibre.NativeFfi
Assembly
Maplibre.NativeFfi.dll

A camera view for converting between screen points and coordinates.

public sealed class MapProjectionHandle : IDisposable
Inheritance
MapProjectionHandle
Implements
Inherited Members

Remarks

See mln_map_projection in the C API reference.

Properties

Id

The native handle value. It stays readable after release.

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

Methods

Create(MapView)

Creates a projection that converts coordinates for one view of a map.

public static MapProjectionHandle Create(MapView view)

Parameters

view MapView

Returns

MapProjectionHandle

Remarks

Create it from the view of an MapSnapshot or an RenderFrameResult. The projection doesn't follow the map, so create a new one after the map's camera or size changes.

See mln_map_projection_create in the C API reference.

GetCamera()

Reads the projection's camera.

public MapProjectionCameraResult GetCamera()

Returns

MapProjectionCameraResult

Remarks

See mln_map_projection_get_camera in the C API reference.

LatLngForPixel(ScreenPoint)

Finds the coordinate at a screen point.

public LatLng LatLngForPixel(ScreenPoint point)

Parameters

point ScreenPoint

Returns

LatLng

Remarks

The longitude stays between -180 and 180.

See mln_map_projection_lat_lng_for_pixel in the C API reference.

LatLngForPixelUnwrapped(ScreenPoint)

Finds the coordinate at a screen point, without wrapping its longitude.

public LatLng LatLngForPixelUnwrapped(ScreenPoint point)

Parameters

point ScreenPoint

Returns

LatLng

Remarks

The longitude can fall outside -180 to 180, to show which copy of the world the point is in.

See mln_map_projection_lat_lng_for_pixel_unwrapped in the C API reference.

LatLngsForPixels(ScreenPoint[])

Finds the coordinates at several screen points, as MapProjectionHandle.LatLngForPixel() does.

public LatLng[] LatLngsForPixels(ScreenPoint[] points)

Parameters

points ScreenPoint[]

Returns

LatLng[]

Remarks

See mln_map_projection_lat_lngs_for_pixels in the C API reference.

LatLngsForPixelsUnwrapped(ScreenPoint[])

Finds the coordinates at several screen points, as MapProjectionHandle.LatLngForPixelUnwrapped() does.

public LatLng[] LatLngsForPixelsUnwrapped(ScreenPoint[] points)

Parameters

points ScreenPoint[]

Returns

LatLng[]

Remarks

See mln_map_projection_lat_lngs_for_pixels_unwrapped in the C API reference.

MetersPerPixelAtLatitude(double)

Computes how many meters one screen pixel covers at latitude, at the projection's zoom.

public double MetersPerPixelAtLatitude(double latitude)

Parameters

latitude double

Returns

double

Remarks

The result ignores the camera's pitch.

See mln_map_projection_meters_per_pixel_at_latitude in the C API reference.

PixelForLatLng(LatLng)

Finds the screen point of a coordinate.

public ScreenPoint PixelForLatLng(LatLng coordinate)

Parameters

coordinate LatLng

Returns

ScreenPoint

Remarks

The point is in the copy of the world nearest the camera's center.

See mln_map_projection_pixel_for_lat_lng in the C API reference.

PixelsForLatLngs(LatLng[])

Finds the screen points of several coordinates, as MapProjectionHandle.PixelForLatLng() does.

public ScreenPoint[] PixelsForLatLngs(LatLng[] coordinates)

Parameters

coordinates LatLng[]

Returns

ScreenPoint[]

Remarks

See mln_map_projection_pixels_for_lat_lngs in the C API reference.

Release()

Releases a projection.

public void Release()

Remarks

See mln_map_projection_release in the C API reference.

SetCamera(CameraOptions)

Moves the projection's camera, without changing the map.

public void SetCamera(CameraOptions camera)

Parameters

camera CameraOptions

Remarks

Camera fields that camera doesn't set keep their values.

See mln_map_projection_set_camera in the C API reference.

ToString()

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

public override string ToString()

Returns

string