|
MapLibre Native C API
Public C ABI for the MapLibre Native wrapper.
|
Go to the source code of this file.
Data Structures | |
| struct | mln_image_stretch |
| struct | mln_image_content |
| struct | mln_style_source_tile_info |
| struct | mln_geo_json_source_options |
| struct | mln_style_source_info |
| struct | mln_style_layer_info |
| struct | mln_canonical_tile_id |
| struct | mln_custom_geometry_source_options |
| struct | mln_custom_vector_source_options |
| struct | mln_premultiplied_rgba8_image |
| struct | mln_style_image_options |
| struct | mln_style_image_info |
| struct | mln_style_transition_options |
Read and change the sources, layers, and images of a map's style.
| typedef struct mln_canonical_tile_id mln_canonical_tile_id |
A tile's zoom level z, column x, and row y, with row 0 at the north.
The fields that mln_custom_geometry_source_options sets.
| typedef uint32_t mln_custom_geometry_source_option_fields |
A set of mln_custom_geometry_source_option_field bits.
| typedef struct mln_custom_geometry_source_options mln_custom_geometry_source_options |
The callbacks and options of a custom geometry source.
Zoom levels are whole numbers from 0 to 32.
| typedef void(*) mln_custom_source_cancel_tile_callback(void *user_data, mln_map map, mln_buffer_view source_id, mln_canonical_tile_id tile_id) |
Reports that a custom source no longer needs a tile.
map and source_id name the source.
Lifetimes: source_id stays valid until the callback returns. The callback borrows map, so it must not release it.
| typedef void(*) mln_custom_source_fetch_tile_callback(void *user_data, mln_map map, mln_buffer_view source_id, mln_canonical_tile_id tile_id) |
Asks for the data of a tile in a custom source.
map and source_id name the source that asks. Return quickly. Once the data is ready, pass it to mln_map_set_custom_geometry_source_tile_data() or mln_map_set_custom_vector_source_tile_data(). If it fails to load, report that with mln_map_set_custom_geometry_source_tile_error() or mln_map_set_custom_vector_source_tile_error().
Lifetimes: source_id stays valid until the callback returns. The callback borrows map, so it must not release it.
The fields that mln_custom_vector_source_options sets.
| typedef uint32_t mln_custom_vector_source_option_fields |
A set of mln_custom_vector_source_option_field bits.
| typedef struct mln_custom_vector_source_options mln_custom_vector_source_options |
The callbacks and options of a custom vector source.
Zoom levels are whole numbers from 0 to 32.
The fields that mln_geo_json_source_options sets.
| typedef uint32_t mln_geo_json_source_option_fields |
A set of mln_geo_json_source_option_field bits.
| typedef struct mln_geo_json_source_options mln_geo_json_source_options |
Options for a GeoJSON source.
Zoom levels are whole numbers.
| typedef struct mln_image_content mln_image_content |
The area of an image, in image pixels, that text fits inside.
| typedef struct mln_image_stretch mln_image_stretch |
A range of image pixels, from from to to, that stretches to fit text.
| typedef struct mln_premultiplied_rgba8_image mln_premultiplied_rgba8_image |
An image of 8-bit RGBA pixels whose colors are multiplied by their alpha.
| typedef struct mln_style_image_info mln_style_image_info |
An image in the map's style.
| typedef enum mln_style_image_info_field mln_style_image_info_field |
The fields that mln_style_image_info sets.
| typedef uint32_t mln_style_image_info_fields |
A set of mln_style_image_info_field bits.
| typedef enum mln_style_image_option_field mln_style_image_option_field |
The fields that mln_style_image_options sets.
| typedef uint32_t mln_style_image_option_fields |
A set of mln_style_image_option_field bits.
| typedef struct mln_style_image_options mln_style_image_options |
Options for a style image, as the sprite spec describes them.
| typedef enum mln_style_image_text_fit mln_style_image_text_fit |
How an image stretches to fit text along one axis.
| typedef struct mln_style_layer_info mln_style_layer_info |
A layer in the map's style.
| typedef enum mln_style_layer_visibility mln_style_layer_visibility |
Whether a layer shows.
How a raster DEM tile encodes elevation in its colors.
| typedef struct mln_style_source_info mln_style_source_info |
A source in the map's style.
| typedef enum mln_style_source_info_field mln_style_source_info_field |
The fields that mln_style_source_info sets.
| typedef uint32_t mln_style_source_info_fields |
A set of mln_style_source_info_field bits.
| typedef struct mln_style_source_tile_info mln_style_source_tile_info |
The tiles of a source, as the style lists them.
| typedef enum mln_style_source_type mln_style_source_type |
The type of a style source.
| typedef enum mln_style_tile_scheme mln_style_tile_scheme |
Whether a tileset counts tile rows from the north (XYZ) or the south (TMS).
The fields that mln_style_transition_options sets.
| typedef uint32_t mln_style_transition_option_fields |
A set of mln_style_transition_option_field bits.
| typedef struct mln_style_transition_options mln_style_transition_options |
The default transition for changes to a style's paint properties.
The format of vector tiles.
| enum mln_custom_geometry_source_option_field : uint32_t |
The fields that mln_custom_geometry_source_options sets.
| enum mln_custom_vector_source_option_field : uint32_t |
The fields that mln_custom_vector_source_options sets.
| Enumerator | |
|---|---|
| MLN_CUSTOM_VECTOR_SOURCE_OPTION_MIN_ZOOM | |
| MLN_CUSTOM_VECTOR_SOURCE_OPTION_MAX_ZOOM | |
| enum mln_geo_json_source_option_field : uint32_t |
The fields that mln_geo_json_source_options sets.
| enum mln_style_image_info_field : uint32_t |
The fields that mln_style_image_info sets.
| Enumerator | |
|---|---|
| MLN_STYLE_IMAGE_INFO_CONTENT | |
| MLN_STYLE_IMAGE_INFO_TEXT_FIT_WIDTH | |
| MLN_STYLE_IMAGE_INFO_TEXT_FIT_HEIGHT | |
| enum mln_style_image_option_field : uint32_t |
The fields that mln_style_image_options sets.
| enum mln_style_image_text_fit : uint32_t |
| enum mln_style_layer_visibility : uint32_t |
| enum mln_style_raster_dem_encoding : uint32_t |
| enum mln_style_source_info_field : uint32_t |
The fields that mln_style_source_info sets.
| enum mln_style_source_type : uint32_t |
The type of a style source.
| enum mln_style_tile_scheme : uint32_t |
| enum mln_style_transition_option_field : uint32_t |
The fields that mln_style_transition_options sets.
| Enumerator | |
|---|---|
| MLN_STYLE_TRANSITION_OPTION_DURATION | |
| MLN_STYLE_TRANSITION_OPTION_DELAY | |
| MLN_STYLE_TRANSITION_OPTION_ENABLE_PLACEMENT_TRANSITIONS | |
| enum mln_style_vector_tile_encoding : uint32_t |
| mln_status mln_map_add_custom_geometry_source | ( | mln_map | map, |
| mln_buffer_view | source_id, | ||
| const mln_custom_geometry_source_options * | options, | ||
| const mln_completion * | completion, | ||
| mln_diagnostic * | out_diagnostic ) |
Adds a source whose GeoJSON tiles come from callbacks.
Completes with:
Lifetimes: When this function returns an error, the caller keeps user_data and the library doesn't call release_user_data.
| mln_status mln_map_add_custom_vector_source | ( | mln_map | map, |
| mln_buffer_view | source_id, | ||
| const mln_custom_vector_source_options * | options, | ||
| const mln_completion * | completion, | ||
| mln_diagnostic * | out_diagnostic ) |
Adds a source whose vector tiles come from callbacks.
Completes with:
Lifetimes: When this function returns an error, the caller keeps user_data and the library doesn't call release_user_data.
| mln_status mln_map_add_geo_json_source | ( | mln_map | map, |
| mln_buffer_view | source_id, | ||
| const mln_geo_json_source_options * | options, | ||
| mln_buffer_view | attribution, | ||
| const mln_completion * | completion, | ||
| mln_diagnostic * | out_diagnostic ) |
Adds a GeoJSON source with no data.
Give it data with mln_map_set_geo_json_source_data() or mln_map_set_geo_json_source_url(). Its options stay fixed for as long as the style holds it.
attribution is the source's attribution, or empty for none.
Returns:
Completes with:
| mln_status mln_map_add_image_source_image | ( | mln_map | map, |
| mln_buffer_view | source_id, | ||
| const mln_lat_lng * | coordinates, | ||
| size_t | coordinate_count, | ||
| const mln_premultiplied_rgba8_image * | image, | ||
| const mln_completion * | completion, | ||
| mln_diagnostic * | out_diagnostic ) |
Adds an image source that shows image.
coordinates are the image's four corners, clockwise from the top left.
Completes with:
| mln_status mln_map_add_style_layer_json | ( | mln_map | map, |
| mln_buffer_view | layer_json, | ||
| mln_buffer_view | before_layer_id, | ||
| const mln_completion * | completion, | ||
| mln_diagnostic * | out_diagnostic ) |
Adds a layer to the map's style.
layer_json is a layer object. The layer goes below the layer named before_layer_id, or above every layer when before_layer_id is empty.
Completes with:
| mln_status mln_map_add_style_source_json | ( | mln_map | map, |
| mln_buffer_view | source_id, | ||
| mln_buffer_view | source_json, | ||
| const mln_completion * | completion, | ||
| mln_diagnostic * | out_diagnostic ) |
Adds a source to the map's style.
source_json is a source object.
Completes with:
| mln_status mln_map_get_global_state | ( | mln_map | map, |
| const mln_completion * | completion, | ||
| mln_diagnostic * | out_diagnostic ) |
Reads the global state of the map's style as a JSON object.
| mln_status mln_map_get_image_source_coordinates | ( | mln_map | map, |
| mln_buffer_view | source_id, | ||
| const mln_completion * | completion, | ||
| mln_diagnostic * | out_diagnostic ) |
Reads the corners of an image source's image, clockwise from the top left.
Completes with:
| mln_status mln_map_get_style_image | ( | mln_map | map, |
| mln_buffer_view | image_id, | ||
| const mln_completion * | completion, | ||
| mln_diagnostic * | out_diagnostic ) |
Reads an image of the map's style.
Completes with no value when the style has no image named image_id.
| mln_status mln_map_get_style_layer | ( | mln_map | map, |
| mln_buffer_view | layer_id, | ||
| const mln_completion * | completion, | ||
| mln_diagnostic * | out_diagnostic ) |
Reads a layer of the map's style.
Completes with no value when the style has no layer named layer_id.
| mln_status mln_map_get_style_layer_json | ( | mln_map | map, |
| mln_buffer_view | layer_id, | ||
| const mln_completion * | completion, | ||
| mln_diagnostic * | out_diagnostic ) |
Reads a layer of the map's style as a layer object.
Completes with no value when the style has no layer named layer_id.
| mln_status mln_map_get_style_layer_property | ( | mln_map | map, |
| mln_buffer_view | layer_id, | ||
| mln_buffer_view | property_name, | ||
| const mln_completion * | completion, | ||
| mln_diagnostic * | out_diagnostic ) |
Reads a property of a layer in the map's style.
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.
Completes with:
| mln_status mln_map_get_style_light_property | ( | mln_map | map, |
| mln_buffer_view | property_name, | ||
| const mln_completion * | completion, | ||
| mln_diagnostic * | out_diagnostic ) |
Reads a property of the light of the map's style.
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.
| mln_status mln_map_get_style_source | ( | mln_map | map, |
| mln_buffer_view | source_id, | ||
| const mln_completion * | completion, | ||
| mln_diagnostic * | out_diagnostic ) |
Reads a source of the map's style.
A tile source with a url has an empty attribution until its TileJSON loads, which raises MLN_RUNTIME_EVENT_MAP_SOURCE_CHANGED.
Completes with no value when the style has no source named source_id.
| mln_status mln_map_get_style_transition_options | ( | mln_map | map, |
| const mln_completion * | completion, | ||
| mln_diagnostic * | out_diagnostic ) |
Reads the default transition of the map's style.
| mln_status mln_map_invalidate_custom_geometry_source_region | ( | mln_map | map, |
| mln_buffer_view | source_id, | ||
| mln_lat_lng_bounds | bounds, | ||
| const mln_completion * | completion, | ||
| mln_diagnostic * | out_diagnostic ) |
Makes a custom geometry source ask again for the tiles in bounds that the map still needs.
Completes with:
| mln_status mln_map_invalidate_custom_geometry_source_tile | ( | mln_map | map, |
| mln_buffer_view | source_id, | ||
| mln_canonical_tile_id | tile_id, | ||
| const mln_completion * | completion, | ||
| mln_diagnostic * | out_diagnostic ) |
Makes a custom geometry source ask for a tile again when the map needs it.
Completes with:
| mln_status mln_map_invalidate_custom_vector_source_region | ( | mln_map | map, |
| mln_buffer_view | source_id, | ||
| mln_lat_lng_bounds | bounds, | ||
| const mln_completion * | completion, | ||
| mln_diagnostic * | out_diagnostic ) |
Makes a custom vector source ask again for the tiles in bounds that the map still needs.
Completes with:
| mln_status mln_map_invalidate_custom_vector_source_tile | ( | mln_map | map, |
| mln_buffer_view | source_id, | ||
| mln_canonical_tile_id | tile_id, | ||
| const mln_completion * | completion, | ||
| mln_diagnostic * | out_diagnostic ) |
Makes a custom vector source ask for a tile again when the map needs it.
Completes with:
| mln_status mln_map_list_style_layers | ( | mln_map | map, |
| const mln_completion * | completion, | ||
| mln_diagnostic * | out_diagnostic ) |
Lists the layers of the map's style, from bottom to top.
| mln_status mln_map_list_style_sources | ( | mln_map | map, |
| const mln_completion * | completion, | ||
| mln_diagnostic * | out_diagnostic ) |
Lists the sources of the map's style.
| mln_status mln_map_move_style_layer | ( | mln_map | map, |
| mln_buffer_view | layer_id, | ||
| mln_buffer_view | before_layer_id, | ||
| const mln_completion * | completion, | ||
| mln_diagnostic * | out_diagnostic ) |
Moves a layer of the map's style below the layer named before_layer_id, or above every layer when before_layer_id is empty.
Completes with:
| mln_status mln_map_remove_style_image | ( | mln_map | map, |
| mln_buffer_view | image_id, | ||
| const mln_completion * | completion, | ||
| mln_diagnostic * | out_diagnostic ) |
Removes an image from the map's style.
Completes with:
| mln_status mln_map_remove_style_layer | ( | mln_map | map, |
| mln_buffer_view | layer_id, | ||
| const mln_completion * | completion, | ||
| mln_diagnostic * | out_diagnostic ) |
Removes a layer from the map's style.
Completes with:
| mln_status mln_map_remove_style_source | ( | mln_map | map, |
| mln_buffer_view | source_id, | ||
| const mln_completion * | completion, | ||
| mln_diagnostic * | out_diagnostic ) |
Removes a source from the map's style.
Completes with:
| mln_status mln_map_set_custom_geometry_source_tile_data | ( | mln_map | map, |
| mln_buffer_view | source_id, | ||
| mln_canonical_tile_id | tile_id, | ||
| mln_buffer_view | data, | ||
| const mln_completion * | completion, | ||
| mln_diagnostic * | out_diagnostic ) |
Sets the data of a tile in a custom geometry source.
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.
Completes with:
| mln_status mln_map_set_custom_geometry_source_tile_error | ( | mln_map | map, |
| mln_buffer_view | source_id, | ||
| mln_canonical_tile_id | tile_id, | ||
| mln_buffer_view | message, | ||
| const mln_completion * | completion, | ||
| mln_diagnostic * | out_diagnostic ) |
Reports that a tile of a custom geometry source failed to load.
Completes with:
| mln_status mln_map_set_custom_vector_source_tile_data | ( | mln_map | map, |
| mln_buffer_view | source_id, | ||
| mln_canonical_tile_id | tile_id, | ||
| mln_style_vector_tile_encoding | encoding, | ||
| mln_buffer_view | data, | ||
| const mln_completion * | completion, | ||
| mln_diagnostic * | out_diagnostic ) |
Sets the data of a tile in a custom vector source.
data is the tile, encoded as encoding. The source ignores data for a tile that it hasn't asked for, or has since cancelled.
Completes with:
| mln_status mln_map_set_custom_vector_source_tile_error | ( | mln_map | map, |
| mln_buffer_view | source_id, | ||
| mln_canonical_tile_id | tile_id, | ||
| mln_buffer_view | message, | ||
| const mln_completion * | completion, | ||
| mln_diagnostic * | out_diagnostic ) |
Reports that a tile of a custom vector source failed to load.
Completes with:
| mln_status mln_map_set_geo_json_source_data | ( | mln_map | map, |
| mln_buffer_view | source_id, | ||
| mln_buffer_view | data, | ||
| const mln_completion * | completion, | ||
| mln_diagnostic * | out_diagnostic ) |
Replaces the data of a GeoJSON source.
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 mln_map_set_geo_json_source_synchronous_tiling() describes, the command prepares data before later commands run, so the data shows in the next frame.
Completes with:
| mln_status mln_map_set_geo_json_source_synchronous_tiling | ( | mln_map | map, |
| mln_buffer_view | source_id, | ||
| bool | enabled, | ||
| const mln_completion * | completion, | ||
| mln_diagnostic * | out_diagnostic ) |
Sets whether a GeoJSON source builds its tiles while the map renders.
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.
Completes with:
| mln_status mln_map_set_geo_json_source_url | ( | mln_map | map, |
| mln_buffer_view | source_id, | ||
| mln_buffer_view | url, | ||
| const mln_completion * | completion, | ||
| mln_diagnostic * | out_diagnostic ) |
Makes a GeoJSON source load its data from url.
Completes with:
| mln_status mln_map_set_global_state_property | ( | mln_map | map, |
| mln_buffer_view | property_name, | ||
| mln_buffer_view | value, | ||
| const mln_completion * | completion, | ||
| mln_diagnostic * | out_diagnostic ) |
Sets a value that the style's global-state expressions read.
Completes with:
| mln_status mln_map_set_image_source_coordinates | ( | mln_map | map, |
| mln_buffer_view | source_id, | ||
| const mln_lat_lng * | coordinates, | ||
| size_t | coordinate_count, | ||
| const mln_completion * | completion, | ||
| mln_diagnostic * | out_diagnostic ) |
Moves the image of an image source.
coordinates are the image's four corners, clockwise from the top left.
Completes with:
| mln_status mln_map_set_image_source_image | ( | mln_map | map, |
| mln_buffer_view | source_id, | ||
| const mln_premultiplied_rgba8_image * | image, | ||
| const mln_completion * | completion, | ||
| mln_diagnostic * | out_diagnostic ) |
Replaces the image of an image source.
Completes with:
| mln_status mln_map_set_image_source_url | ( | mln_map | map, |
| mln_buffer_view | source_id, | ||
| mln_buffer_view | url, | ||
| const mln_completion * | completion, | ||
| mln_diagnostic * | out_diagnostic ) |
Makes an image source load its image from url.
Completes with:
| mln_status mln_map_set_style_image | ( | mln_map | map, |
| mln_buffer_view | image_id, | ||
| const mln_premultiplied_rgba8_image * | image, | ||
| const mln_style_image_options * | options, | ||
| const mln_completion * | completion, | ||
| mln_diagnostic * | out_diagnostic ) |
Adds an image to the map's style, or replaces the image named image_id.
Completes with:
| mln_status mln_map_set_style_layer_property | ( | mln_map | map, |
| mln_buffer_view | layer_id, | ||
| mln_buffer_view | property_name, | ||
| mln_buffer_view | value, | ||
| const mln_completion * | completion, | ||
| mln_diagnostic * | out_diagnostic ) |
Sets a property of a layer in the map's style.
property_name is one of the layer's layout or paint properties, or filter, minzoom, maxzoom, source, or source-layer. A null value resets any of these but source and source-layer to its default.
Completes with:
| mln_status mln_map_set_style_light_json | ( | mln_map | map, |
| mln_buffer_view | light_json, | ||
| const mln_completion * | completion, | ||
| mln_diagnostic * | out_diagnostic ) |
Replaces the light of the map's style.
Completes with:
| mln_status mln_map_set_style_light_property | ( | mln_map | map, |
| mln_buffer_view | property_name, | ||
| mln_buffer_view | value, | ||
| const mln_completion * | completion, | ||
| mln_diagnostic * | out_diagnostic ) |
Sets a property of the light of the map's style.
Completes with:
| mln_status mln_map_set_style_source_volatile | ( | mln_map | map, |
| mln_buffer_view | source_id, | ||
| bool | is_volatile, | ||
| const mln_completion * | completion, | ||
| mln_diagnostic * | out_diagnostic ) |
Sets whether a source is volatile.
The map doesn't store the tiles of a volatile source in the persistent cache.
Completes with:
| mln_status mln_map_set_style_transition_options | ( | mln_map | map, |
| const mln_style_transition_options * | options, | ||
| const mln_completion * | completion, | ||
| mln_diagnostic * | out_diagnostic ) |
Sets the default transition of the map's style.
Completes with: