|
MapLibre Native C API
Public C ABI for the MapLibre Native wrapper.
|
Go to the source code of this file.
Data Structures | |
| struct | mln_style_source_info |
| struct | mln_style_tile_source_options |
| struct | mln_canonical_tile_id |
| struct | mln_custom_geometry_source_options |
| struct | mln_premultiplied_rgba8_image |
| struct | mln_style_image_options |
| struct | mln_style_image_info |
Typedefs | |
| typedef void(* | mln_custom_geometry_source_tile_callback) (void *user_data, mln_canonical_tile_id tile_id) |
Enumerations | |
| enum | mln_style_source_type : uint32_t |
| enum | mln_style_tile_source_option_field : uint32_t |
| enum | mln_style_tile_scheme : uint32_t |
| enum | mln_style_vector_tile_encoding : uint32_t |
| enum | mln_style_raster_dem_encoding : uint32_t |
| enum | mln_custom_geometry_source_option_field : uint32_t |
| enum | mln_style_image_option_field : uint32_t |
| enum | mln_location_indicator_image_kind : uint32_t |
Public C API declarations for style sources, layers, and images.
| typedef void(* mln_custom_geometry_source_tile_callback) (void *user_data, mln_canonical_tile_id tile_id) |
Callback invoked for custom geometry source tile requests and cancels.
| enum mln_custom_geometry_source_option_field : uint32_t |
Field mask values for mln_custom_geometry_source_options.
| enum mln_location_indicator_image_kind : uint32_t |
Location indicator image-name properties.
| enum mln_style_image_option_field : uint32_t |
Field mask values for mln_style_image_options.
| enum mln_style_raster_dem_encoding : uint32_t |
DEM raster encoding values used by mln_style_tile_source_options.
| enum mln_style_source_type : uint32_t |
Style source type values returned by mln_map_get_style_source_type().
| enum mln_style_tile_scheme : uint32_t |
Tile URL coordinate scheme values used by mln_style_tile_source_options.
| enum mln_style_tile_source_option_field : uint32_t |
Field mask values for mln_style_tile_source_options.
| enum mln_style_vector_tile_encoding : uint32_t |
Vector tile encoding values used by mln_style_tile_source_options.
| mln_custom_geometry_source_options mln_custom_geometry_source_options_default | ( | void | ) |
Returns default custom geometry source options.
| mln_status mln_map_add_color_relief_layer | ( | mln_map * | map, |
| mln_string_view | layer_id, | ||
| mln_string_view | source_id, | ||
| mln_string_view | before_layer_id ) |
Adds a color-relief layer for a raster DEM source.
layer_id, source_id, and before_layer_id are borrowed for the call. Passing an empty before_layer_id appends the layer; otherwise the layer is inserted before that existing layer. Use mln_map_set_layer_property() with color-relief-color to set the color ramp expression.
Returns:
| mln_status mln_map_add_custom_geometry_source | ( | mln_map * | map, |
| mln_string_view | source_id, | ||
| const mln_custom_geometry_source_options * | options ) |
Adds a custom geometry source.
source_id is borrowed for the call. options is borrowed for the call, but the callback function pointers and user_data pointer are retained by value. The callback functions and user_data must remain valid until the source is removed, the style is replaced, or the map is destroyed, and until any in-flight callback invocation has returned. For URL loads, style replacement occurs when the new style loads, not when the load request is accepted. For inline JSON loads, style replacement completes before mln_map_set_style_json() returns successfully.
fetch_tile and cancel_tile may run on arbitrary native worker threads, may be concurrent with owner-thread map calls, and must not call thread-affine map APIs directly. Queue work back to the map owner thread before calling mln_map_set_custom_geometry_source_tile_data() or invalidation functions. Callbacks must not throw, panic, longjmp, or otherwise unwind through the C ABI. cancel_tile is best-effort and may be repeated or race with fetch_tile.
Custom geometry sources belong to the current style. Replacing the style drops sources that were added to the previous style.
Returns:
| mln_status mln_map_add_geojson_source_data | ( | mln_map * | map, |
| mln_string_view | source_id, | ||
| const mln_geojson * | data ) |
Adds a GeoJSON source with inline data.
source_id and data are borrowed for the call. The accepted GeoJSON descriptor is copied into MapLibre Native before return.
Returns:
| mln_status mln_map_add_geojson_source_url | ( | mln_map * | map, |
| mln_string_view | source_id, | ||
| mln_string_view | url ) |
Adds a GeoJSON source with URL data.
source_id and url are borrowed for the call. The source loads GeoJSON from url through MapLibre Native's resource system.
Returns:
| mln_status mln_map_add_hillshade_layer | ( | mln_map * | map, |
| mln_string_view | layer_id, | ||
| mln_string_view | source_id, | ||
| mln_string_view | before_layer_id ) |
Adds a hillshade layer for a raster DEM source.
layer_id, source_id, and before_layer_id are borrowed for the call. Passing an empty before_layer_id appends the layer; otherwise the layer is inserted before that existing layer.
Returns:
| mln_status mln_map_add_image_source_image | ( | mln_map * | map, |
| mln_string_view | source_id, | ||
| const mln_lat_lng * | coordinates, | ||
| size_t | coordinate_count, | ||
| const mln_premultiplied_rgba8_image * | image ) |
Adds an image source with inline image pixels.
source_id, coordinates, image, and image pixels are borrowed for the call. coordinates must contain exactly four coordinates in top-left, top-right, bottom-right, bottom-left order. The function copies accepted coordinates and pixels into the current style before return.
Image sources belong to the current style. Loading another style URL or JSON document drops sources that were added to the previous style.
Returns:
| mln_status mln_map_add_image_source_url | ( | mln_map * | map, |
| mln_string_view | source_id, | ||
| const mln_lat_lng * | coordinates, | ||
| size_t | coordinate_count, | ||
| mln_string_view | url ) |
Adds an image source that loads its image from a URL.
source_id, coordinates, and url are borrowed for the call. coordinates must contain exactly four coordinates in top-left, top-right, bottom-right, bottom-left order. The function copies accepted strings and coordinates into the current style before return. Later URL load or decode failures are reported through runtime events.
Image sources belong to the current style. Loading another style URL or JSON document drops sources that were added to the previous style.
Returns:
| mln_status mln_map_add_location_indicator_layer | ( | mln_map * | map, |
| mln_string_view | layer_id, | ||
| mln_string_view | before_layer_id ) |
Adds a source-free location indicator layer.
layer_id and before_layer_id are borrowed for the call. Passing an empty before_layer_id appends the layer; otherwise the layer is inserted before that existing layer.
Returns:
| mln_status mln_map_add_raster_dem_source_tiles | ( | mln_map * | map, |
| mln_string_view | source_id, | ||
| const mln_string_view * | tiles, | ||
| size_t | tile_count, | ||
| const mln_style_tile_source_options * | options ) |
Adds a raster DEM source with inline tile URLs.
source_id and tile URL views are borrowed for the call. The function copies accepted strings into MapLibre Native before return. options may be null for defaults.
Returns:
| mln_status mln_map_add_raster_dem_source_url | ( | mln_map * | map, |
| mln_string_view | source_id, | ||
| mln_string_view | url, | ||
| const mln_style_tile_source_options * | options ) |
Adds a raster DEM source with a TileJSON URL.
source_id and url are borrowed for the call. options may be null for defaults. For URL sources, tile_size and raster_encoding are used when their field bits are set.
Returns:
| mln_status mln_map_add_raster_source_tiles | ( | mln_map * | map, |
| mln_string_view | source_id, | ||
| const mln_string_view * | tiles, | ||
| size_t | tile_count, | ||
| const mln_style_tile_source_options * | options ) |
Adds a raster source with inline tile URLs.
source_id and tile URL views are borrowed for the call. The function copies accepted strings into MapLibre Native before return. options may be null for defaults.
Returns:
| mln_status mln_map_add_raster_source_url | ( | mln_map * | map, |
| mln_string_view | source_id, | ||
| mln_string_view | url, | ||
| const mln_style_tile_source_options * | options ) |
Adds a raster source with a TileJSON URL.
source_id and url are borrowed for the call. options may be null for defaults. For URL sources, only tile_size is used when its field bit is set.
Returns:
| mln_status mln_map_add_style_layer_json | ( | mln_map * | map, |
| const mln_json_value * | layer_json, | ||
| mln_string_view | before_layer_id ) |
Adds one style layer from a full style-spec layer JSON object.
layer_json and before_layer_id are borrowed for the call. layer_json must contain id and type members. Passing an empty before_layer_id appends the layer; otherwise the layer is inserted before that existing layer.
Returns:
| mln_status mln_map_add_style_source_json | ( | mln_map * | map, |
| mln_string_view | source_id, | ||
| const mln_json_value * | source_json ) |
Adds one style source from a style-spec source JSON object.
source_id and source_json are borrowed for the call. source_json is the object that appears under sources[source_id] in a style document. The function parses and copies the accepted source into MapLibre Native before return.
Returns:
| mln_status mln_map_add_vector_source_tiles | ( | mln_map * | map, |
| mln_string_view | source_id, | ||
| const mln_string_view * | tiles, | ||
| size_t | tile_count, | ||
| const mln_style_tile_source_options * | options ) |
Adds a vector source with inline tile URLs.
source_id and tile URL views are borrowed for the call. The function copies accepted strings into MapLibre Native before return. options may be null for defaults.
Returns:
| mln_status mln_map_add_vector_source_url | ( | mln_map * | map, |
| mln_string_view | source_id, | ||
| mln_string_view | url, | ||
| const mln_style_tile_source_options * | options ) |
Adds a vector source with a TileJSON URL.
source_id and url are borrowed for the call. options may be null for defaults. For URL sources, min_zoom, max_zoom, and vector_encoding override values from the loaded TileJSON when their field bits are set.
Returns:
| mln_status mln_map_copy_style_image_premultiplied_rgba8 | ( | mln_map * | map, |
| mln_string_view | image_id, | ||
| uint8_t * | out_pixels, | ||
| size_t | pixel_capacity, | ||
| size_t * | out_byte_length, | ||
| bool * | out_found ) |
Copies one runtime style image as tightly packed premultiplied RGBA8 pixels.
image_id is borrowed for the call. out_pixels may be null only when pixel_capacity is 0. On success, out_byte_length receives the required byte length. When out_found is false, out_byte_length receives 0. If pixel_capacity is too small for a present image, out_byte_length still receives the required byte length and the function returns MLN_STATUS_INVALID_ARGUMENT.
Returns:
| mln_status mln_map_copy_style_source_attribution | ( | mln_map * | map, |
| mln_string_view | source_id, | ||
| char * | out_attribution, | ||
| size_t | attribution_capacity, | ||
| size_t * | out_attribution_size, | ||
| bool * | out_found ) |
Copies one style source attribution string into caller-owned memory.
source_id is borrowed for the call. out_attribution may be null only when attribution_capacity is 0. On success, out_attribution_size receives the byte length of the attribution, excluding any null terminator. When out_found is false or the source has no attribution, out_attribution_size receives 0.
Returns:
| mln_status mln_map_get_image_source_coordinates | ( | mln_map * | map, |
| mln_string_view | source_id, | ||
| mln_lat_lng * | out_coordinates, | ||
| size_t | coordinate_capacity, | ||
| size_t * | out_coordinate_count, | ||
| bool * | out_found ) |
Copies image source coordinates.
On success, out_found reports whether source_id exists. When found, out_coordinate_count receives 4. If coordinate_capacity is less than 4, out_coordinate_count still receives 4 and the function returns MLN_STATUS_INVALID_ARGUMENT.
Returns:
| mln_status mln_map_get_layer_filter | ( | mln_map * | map, |
| mln_string_view | layer_id, | ||
| mln_json_snapshot ** | out_filter ) |
Copies one layer filter as a style-spec JSON value snapshot.
On success, *out_filter receives an owned snapshot handle. Use mln_json_snapshot_get() to borrow its root JSON value. Destroy the snapshot with mln_json_snapshot_destroy(). Missing filters return null snapshots.
Returns:
| mln_status mln_map_get_layer_property | ( | mln_map * | map, |
| mln_string_view | layer_id, | ||
| mln_string_view | property_name, | ||
| mln_json_snapshot ** | out_value ) |
Copies one layer property as a style-spec JSON value snapshot.
On success, *out_value receives an owned snapshot handle. Use mln_json_snapshot_get() to borrow its root JSON value. Destroy the snapshot with mln_json_snapshot_destroy(). Undefined native style properties return null snapshots.
Returns:
| mln_status mln_map_get_style_image_info | ( | mln_map * | map, |
| mln_string_view | image_id, | ||
| mln_style_image_info * | out_info, | ||
| bool * | out_found ) |
Copies fixed metadata for one runtime style image.
On success, out_found reports whether image_id exists. When not found, out_info receives default image metadata.
Returns:
| mln_status mln_map_get_style_layer_json | ( | mln_map * | map, |
| mln_string_view | layer_id, | ||
| mln_json_snapshot ** | out_layer, | ||
| bool * | out_found ) |
Copies one style layer as a full style-spec layer JSON snapshot.
On success, out_found reports whether layer_id exists. When found, *out_layer receives an owned snapshot handle.
Returns:
| mln_status mln_map_get_style_layer_type | ( | mln_map * | map, |
| mln_string_view | layer_id, | ||
| mln_string_view * | out_layer_type, | ||
| bool * | out_found ) |
Borrows one style layer type string.
On success, out_found reports whether layer_id exists. When found, out_layer_type receives a view of a static style-spec layer type string.
Returns:
| mln_status mln_map_get_style_light_property | ( | mln_map * | map, |
| mln_string_view | property_name, | ||
| mln_json_snapshot ** | out_value ) |
Copies one style light property as a style-spec JSON value snapshot.
On success, *out_value receives an owned snapshot handle. Use mln_json_snapshot_get() to borrow its root JSON value. Destroy the snapshot with mln_json_snapshot_destroy(). Undefined native style light properties return null snapshots.
Returns:
| mln_status mln_map_get_style_source_info | ( | mln_map * | map, |
| mln_string_view | source_id, | ||
| mln_style_source_info * | out_info, | ||
| bool * | out_found ) |
Copies fixed metadata for one style source.
The returned struct contains string lengths, not string contents. Use mln_map_copy_style_source_attribution() to copy attribution bytes when has_attribution is true. The source ID is the lookup key and is also available through style source ID lists.
Returns:
| mln_status mln_map_get_style_source_type | ( | mln_map * | map, |
| mln_string_view | source_id, | ||
| uint32_t * | out_source_type, | ||
| bool * | out_found ) |
Gets one style source type.
On success, out_found reports whether source_id exists. When found, out_source_type receives one of mln_style_source_type.
Returns:
| mln_status mln_map_invalidate_custom_geometry_source_region | ( | mln_map * | map, |
| mln_string_view | source_id, | ||
| mln_lat_lng_bounds | bounds ) |
Invalidates custom geometry source data inside one geographic region.
Returns:
| mln_status mln_map_invalidate_custom_geometry_source_tile | ( | mln_map * | map, |
| mln_string_view | source_id, | ||
| mln_canonical_tile_id | tile_id ) |
Invalidates custom geometry source data for one canonical tile.
Returns:
| mln_status mln_map_list_style_layer_ids | ( | mln_map * | map, |
| mln_style_id_list ** | out_layer_ids ) |
Copies style layer IDs in style order.
On success, *out_layer_ids receives an owned list handle. Destroy it with mln_style_id_list_destroy().
Returns:
| mln_status mln_map_list_style_source_ids | ( | mln_map * | map, |
| mln_style_id_list ** | out_source_ids ) |
Copies style source IDs in style order.
On success, *out_source_ids receives an owned list handle. Destroy it with mln_style_id_list_destroy().
Returns:
| mln_status mln_map_move_style_layer | ( | mln_map * | map, |
| mln_string_view | layer_id, | ||
| mln_string_view | before_layer_id ) |
Moves one style layer before another layer or to the top.
layer_id and before_layer_id are borrowed for the call. Passing an empty before_layer_id moves the layer to the top of the style order.
Returns:
| mln_status mln_map_remove_style_image | ( | mln_map * | map, |
| mln_string_view | image_id, | ||
| bool * | out_removed ) |
Removes one runtime style image by ID.
image_id is borrowed for the call. On success, out_removed reports whether an image existed and was removed.
Returns:
| mln_status mln_map_remove_style_layer | ( | mln_map * | map, |
| mln_string_view | layer_id, | ||
| bool * | out_removed ) |
Removes one style layer by ID.
layer_id is borrowed for the call. On success, out_removed reports whether a layer existed and was removed.
Returns:
| mln_status mln_map_remove_style_source | ( | mln_map * | map, |
| mln_string_view | source_id, | ||
| bool * | out_removed ) |
Removes one style source by ID.
source_id is borrowed for the call. On success, out_removed reports whether a source existed and was removed.
Returns:
| mln_status mln_map_set_custom_geometry_source_tile_data | ( | mln_map * | map, |
| mln_string_view | source_id, | ||
| mln_canonical_tile_id | tile_id, | ||
| const mln_geojson * | data ) |
Sets custom geometry source data for one canonical tile.
source_id and data are borrowed for the call. The accepted GeoJSON descriptor is copied into MapLibre Native before return.
Returns:
| mln_status mln_map_set_geojson_source_data | ( | mln_map * | map, |
| mln_string_view | source_id, | ||
| const mln_geojson * | data ) |
Updates one GeoJSON source with inline data.
source_id and data are borrowed for the call. The accepted GeoJSON descriptor is copied into MapLibre Native before return.
Returns:
| mln_status mln_map_set_geojson_source_url | ( | mln_map * | map, |
| mln_string_view | source_id, | ||
| mln_string_view | url ) |
Updates one GeoJSON source to load data from a URL.
source_id and url are borrowed for the call.
Returns:
| mln_status mln_map_set_image_source_coordinates | ( | mln_map * | map, |
| mln_string_view | source_id, | ||
| const mln_lat_lng * | coordinates, | ||
| size_t | coordinate_count ) |
Updates image source coordinates.
coordinates is borrowed for the call and must contain exactly four coordinates in top-left, top-right, bottom-right, bottom-left order. The function copies accepted coordinates into MapLibre Native before return.
Returns:
| mln_status mln_map_set_image_source_image | ( | mln_map * | map, |
| mln_string_view | source_id, | ||
| const mln_premultiplied_rgba8_image * | image ) |
Updates an image source with inline image pixels.
source_id, image, and image pixels are borrowed for the call. The function copies accepted pixels into MapLibre Native before return.
Returns:
| mln_status mln_map_set_image_source_url | ( | mln_map * | map, |
| mln_string_view | source_id, | ||
| mln_string_view | url ) |
Updates an image source to load its image from a URL.
source_id and url are borrowed for the call. Later URL load or decode failures are reported through runtime events.
Returns:
| mln_status mln_map_set_layer_filter | ( | mln_map * | map, |
| mln_string_view | layer_id, | ||
| const mln_json_value * | filter ) |
Sets or clears one layer filter.
layer_id and filter are borrowed for the call. Passing null for filter clears the layer filter. Non-null filters use the MapLibre style-spec filter JSON representation. The function parses and copies the accepted filter into MapLibre Native's typed filter expression storage before return.
Returns:
| mln_status mln_map_set_layer_property | ( | mln_map * | map, |
| mln_string_view | layer_id, | ||
| mln_string_view | property_name, | ||
| const mln_json_value * | value ) |
Sets one layer property using its MapLibre style-spec property name.
layer_id, property_name, and value are borrowed for the call. value is a style-spec JSON value descriptor. Expressions use style-spec expression JSON arrays. The function parses and copies the accepted value into MapLibre Native's typed style property storage before return.
Returns:
| mln_status mln_map_set_location_indicator_accuracy_radius | ( | mln_map * | map, |
| mln_string_view | layer_id, | ||
| double | radius ) |
Sets a location indicator layer accuracy radius in logical pixels.
Returns:
| mln_status mln_map_set_location_indicator_bearing | ( | mln_map * | map, |
| mln_string_view | layer_id, | ||
| double | bearing ) |
Sets a location indicator layer bearing in degrees.
Returns:
| mln_status mln_map_set_location_indicator_image_name | ( | mln_map * | map, |
| mln_string_view | layer_id, | ||
| uint32_t | image_kind, | ||
| mln_string_view | image_id ) |
Sets one location indicator image-name property.
image_id is borrowed for the call and copied into native style storage. The named style image does not need to exist when this function is called.
Returns:
| mln_status mln_map_set_location_indicator_location | ( | mln_map * | map, |
| mln_string_view | layer_id, | ||
| mln_lat_lng | coordinate, | ||
| double | altitude ) |
Sets a location indicator layer location.
coordinate uses normal C API latitude/longitude order. The underlying style property is written as [longitude, latitude, altitude].
Returns:
| mln_status mln_map_set_style_image | ( | mln_map * | map, |
| mln_string_view | image_id, | ||
| const mln_premultiplied_rgba8_image * | image, | ||
| const mln_style_image_options * | options ) |
Sets one runtime style image.
image_id, image, and image pixels are borrowed for the call. The function copies accepted pixel bytes into the current style before return. If image_id already exists, the native image is replaced.
Runtime style images belong to the current style. Loading another style URL or JSON document drops images that were added to the previous style.
Returns:
| mln_status mln_map_set_style_light_json | ( | mln_map * | map, |
| const mln_json_value * | light_json ) |
Sets the style light from a style-spec light JSON object.
light_json is borrowed for the call. The function parses and copies the accepted light into MapLibre Native before return.
Returns:
| mln_status mln_map_set_style_light_property | ( | mln_map * | map, |
| mln_string_view | property_name, | ||
| const mln_json_value * | value ) |
Sets one style light property using its MapLibre style-spec property name.
property_name and value are borrowed for the call. value is a style-spec JSON value descriptor. The function parses and copies the accepted value into MapLibre Native's typed light property storage before return.
Returns:
| mln_status mln_map_style_image_exists | ( | mln_map * | map, |
| mln_string_view | image_id, | ||
| bool * | out_exists ) |
Reports whether a runtime style image ID exists.
Returns:
| mln_status mln_map_style_layer_exists | ( | mln_map * | map, |
| mln_string_view | layer_id, | ||
| bool * | out_exists ) |
Reports whether a style layer ID exists.
Returns:
| mln_status mln_map_style_source_exists | ( | mln_map * | map, |
| mln_string_view | source_id, | ||
| bool * | out_exists ) |
Reports whether a style source ID exists.
Returns:
| mln_premultiplied_rgba8_image mln_premultiplied_rgba8_image_default | ( | void | ) |
Returns a default premultiplied RGBA8 image descriptor.
| mln_status mln_style_id_list_count | ( | const mln_style_id_list * | list, |
| size_t * | out_count ) |
Gets the number of IDs in a style ID list handle.
Returns:
| void mln_style_id_list_destroy | ( | mln_style_id_list * | list | ) |
Destroys a style ID list handle. Null is accepted as a no-op.
| mln_status mln_style_id_list_get | ( | const mln_style_id_list * | list, |
| size_t | index, | ||
| mln_string_view * | out_id ) |
Borrows one ID from a style ID list handle.
On success, out_id receives a view into list-owned storage. The view remains valid until the list is destroyed.
Returns:
| mln_style_image_info mln_style_image_info_default | ( | void | ) |
Returns default runtime style image metadata.
| mln_style_image_options mln_style_image_options_default | ( | void | ) |
Returns default runtime style image options.
| mln_style_tile_source_options mln_style_tile_source_options_default | ( | void | ) |
Returns default tile source options.