Map data sources
Note
The 3.1 version of this API has been deprecated. For continued support and feature development, upgrade to the latest 3.2 version.
As stated in the Scene structure overview, the sources section is mandatory. This section always contains one source that describes data format provided by a provider. Currently, the available data formats include: GeoJSON and OMV - a format that follows Vector Tile Specification.
A source section contains the following parameters:
type- Specifies the format provided by the provider. It can be eitherOMVorGeoJSONTileSource.extra_data(optional) - Contains any additional data that to pass to thetransformfunction.transform(optional) - Enables processing tile data right in the style through either of the following methods:-
A single function, for example:
sources: omv: type: OMV transform: | function(data, extraData, tileInfo) { if (data.water) { for (let i = 0; i < data.water.features.length; i++) { data.water.features[i].properties.myProperty1 = 'myValue1'; } } return data; } -
Multiple functions, sorted by their names and called in the corresponding sequence, for example:
sources: omv: type: OMV transform: f1: | function(data, extraData, tileInfo) { if (data.water) { for (let i = 0; i < data.water.features.length; i++) { data.water.features[i].properties.myProperty1 = 'myValue1'; } } return data; } f2: | function(data, extraData, tileInfo) { if (data.water) { for (let i = 0; i < data.water.features.length; i++) { data.water.features[i].properties.myProperty2 = 'myValue2'; } } return data; }
-
As demonstrated in the preceding examples, each transform function accepts the following arguments:
data- object that contains data from the current tile. This object contains a list of layers (pois,roads, etc.), where each layer is a GeoJSONFeatureCollection. Some providers (for example,H.service.traffic.flow.Provider) provide only one GeoJSONFeatureCollectionper tile, in such cases this GeoJSONFeatureCollectionpasses asdatainstead list of layers.extraData- content of theextra_dataoptional parameter defined in the source section.tileInfo- object that contains information about the current tile, for example tile coordinates. Eachtransformfunction must return the modified version of thedataparameter.
Next steps
For more information, see Vector map types
Updated yesterday