Skip to main content

Sources

#Data sources (sources)

Data sources are the basis for map visualization. By defining different layers, the same data can be displayed in different ways.

The types of data sources include vector, raster, raster-dem, geojson, image, video, and the value of the type attribute must be one of them.

Note: Simply adding the source will not allow the data to be displayed on the map. You also need to define a layer style based on this data.

GeoJSON

GeoJSON source. Data must be provided via the "data" attribute, whose value can be a URL or inline GeoJSON.

"geojson-marker": {
"type": "geojson",
"data": {
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [120.74603465203592, 31.30605899929158]
},
"properties": {
"title": "Mapmost DC",
"marker-symbol": "monument"
}
}
}

This GeoJSON source example references an external GeoJSON document via a URL. GeoJSON documents must be in the same domain or accessible using CORS.

"geojson-lines": {
"type": "geojson",
"data": "./lines.geojson"
}

attribution

Optional attribute. string

Contains the properties that need to be displayed when displaying the mapping to the user.

buffer

Optional attribute. number. The value range is 0 ~ 512 (inclusive), and the default value is 128. The size around the tile. A value of 0 does not generate a buffer. A value of 512 creates a buffer as wide as the texture itself. At higher values, tile edges can reduce rendering artifacts and slow performance.

cluster

Optional attribute. boolean. Default value false.

If the data is a collection of point features, set this to true and cluster the points into groups by radius size. Point cluster groups become new Point features in the source code, with additional properties:

  • True if the point is a cluster.

  • cluster_ids is a unique ID used in conjunction with the cluster inspection method.

  • point_count, the number of original points in the cluster.

  • point_count_abbreviated, simplified point calculation.

clusterMaxZoom

Optional attribute. number

The maximum map level of cluster points after enabling the cluster function. The default is a zoom less than maxzoom (so the final zoom features are not clustered together). Clusters will be re-evaluated at integer zoom levels, so setting clusterMaxZoom to 14 means the cluster will appear all the way to z15.

clusterMinpoints

Optional attribute. number

After enabling the cluster function, the minimum number of points required to form a cluster. Default value 2.

clusterProperties

Optional attribute.

When the clustering feature is enabled, an object with custom properties is generated on the cluster, aggregating values ​​from the cluster points. It has the form {"property_name": [operator, map_expression]}. Operator can accept any expression function with at least two operands (for example: "+" or "max"), which accumulates the attribute values ​​contained in the cluster/point cluster; Map_expression can generate the value of a single point.

For example: {"sum": ["+", ["get", "scalerank"]]}.

For more advanced cases, you can use a custom reduce expression instead of the operator that references a special ["cumulative"] value, for example: {"sum": [["+", ["cumulative"], ["get", "sum"]], ["get", "scalerank"]]}

clusterRadius

Optional attribute. A number greater than or equal to 0. Default value is 50.

After the cluster function is enabled, it represents the radius of each cluster. 512 means that the cluster radius is equal to the width of the tile.

data

Optional attribute.

A URL pointing to a GeoJSON file, or inline GeoJSON.

filter

Optional attribute.

An expression used to filter features before rendering them for rendering.

fillMetrics

Optional attribute. boolean. Default value false.

Whether to calculate polygon extent metrics. This property is required for polygon layers that have a fill-gradient value defined.

generateId

Optional attribute. boolean. Default value false.

Whether to generate id for geojson. When enabled, the feature.id property will be automatically assigned a value based on its index in the features array and overwrite the previous value.

lineMetrics

Optional attribute. boolean. Default value false.

Whether to calculate line distance metrics. This is required for line layers that specify a line-gradient value.

maxzoom

Optional attribute. number. Default value is 18.

The maximum zoom level at which vector tiles are created (higher means more detail at higher zoom levels).

promoteId

Optional attribute. promoteId

Attribute used as feature id (used for feature status). It can be a property name or an object in the form of {sourceLayer:propertyName}. If specified as a string for a vector tile source, the same properties are used in all its source layers.

tolerance

Optional attribute. number. Default value is 0.375. The threshold for polygon feature simplification. When the shape of the polygon itself is particularly small, you can adjust this threshold to make the feature simplification less severe and retain the original points of the polygon as much as possible.

Douglas-Peucker simplified tolerances (higher means simpler geometry and faster performance). ##Image Image data source.

"image": {
"type": "image",
"url": "./radar.gif",
"coordinates": [
[-80.425, 46.437],
[-71.516, 46.437],
[-71.516, 37.936],
[-80.425, 37.936]
]
}

coordinates

Required attribute. array

The coordinates array contains the longitude and latitude of the image corner points listed in clockwise order, corresponding to: upper left, upper right, lower right, lower left.

url

Required attribute. string

The URL of the image.

Raster tiles (Raster)

The format for defining a raster tile data source is as follows:

"mapmost-satellite": {
"type": "raster",
"url": "<raster url>",
"tileSize": 256
}

attribution

Optional attribute. string

Contains the properties that need to be displayed when displaying the mapping to the user.

bounds

Optional attribute. array.

Array containing the longitude and latitude of the southwest and northeast corners of the source bounding box, in the following order: [sw.lng, sw.lat, ne.lng, ne.lat]. When this attribute is included in a source, Mapmost SDK for WebGL will not send requests to any tiles outside the bounds.

maxzoom

Optional attribute. number. Default value is 22.

The maximum zoom level available for raster tiles, as specified in the TileJSON specification. When displaying the map at higher zoom levels, the tile data on maxzoom will be used.

minzoom

Optional attribute. number. Default value is 0.

The minimum zoom level available for tiles, as specified in the TileJSON specification.

scheme

Optional attribute. enum. One of "xyz" and "tms", the default value is "xyz".

Affects the y direction of the tile coordinates. Assume a Global Mercator (aka Spherical Mercator) profile.

"xyz": Slippy map tile name scheme.

"tms": OSGeo specification scheme.

tiles

Optional attribute. string

An array of one or more tile source URLs, as shown in the TileJSON specification.

tileSize

Optional attribute. number. Unit pixel, default value 512.

The minimum visible size of displayed tiles in the layer. Configurable only in raster layer.

url

Optional attribute. string

The URL of the TileJSON resource. Supported protocols are: http:, https:.

Raster DEM tiles (Raster-dem)

Raster DEM source.

"mapmost-terrain-dem-v1": {
"type": "raster-dem",
"tiles": [
"<tiles url>"// Such as "http://***/dem/{z}/{x}/{y}.png"
],
}

attribution

Optional attribute. string

Contains the properties that need to be displayed when displaying the mapping to the user.

maxzoom

Optional attribute. number. Default value is 22.

The maximum zoom level available for tiles, as specified in the TileJSON specification. When the map is displayed at a higher zoom level, data from the largest zoomed tile is used.

minzoom

Optional attribute. number. Default value is 0.

The minimum zoom level available for tiles, as specified in the TileJSON specification.

tiles

Optional attribute. string

An array of one or more tile source URLs, as shown in the TileJSON specification.

tileSize

Optional attribute. number. Unit pixel. Default value is 512.

The minimum visible size of displayed tiles in the layer. Configurable only in raster layer.

Tiled sources

Tile map services (vector and raster) must specify their details according to the TileJSON specification. The specific form of defining the data source is as follows:

  • By providing TileJSON properties such as "tiles", "minzoom" and "maxzoom" directly in the source code:
"mapmost-dark": {
"type": "vector",
"tiles": [
"http://a.example.com/tiles/{z}/{x}/{y}.pbf",
"http://b.example.com/tiles/{z}/{x}/{y}.pbf"
],
"maxzoom": 14
}
  • Add a "url" for the TileJSON resource:
"mapmost-dark": {
"type": "vector",
"url": "http://api.example.com/tilejson.json"
}
  • By providing a WMS service URL as the data source. To support EPSG:3857 (or EPSG:900913) map service, the bbox parameter in the service URL needs to be changed to "{bbox-epsg-3857}".
"wms-imagery": {
"type": "raster",
"tiles": [
"http://a.example.com/wms?bbox={bbox-epsg-3857}&format=image/png&service=WMS&version=1.1.1&request=GetMap&srs=EPSG:3857&width=256&height=256&layers=example"
],
"tileSize": 256
}

[CGCS 2000 Special Edition] supports EPSG:4490 map service, the bbox parameter in the service URL needs to be changed to "{bbox-epsg-4490}".

Vector tiles (Vector)

Vector tile map service. The format for defining a data source is as follows:

"mapmost-dark": {
"type": "vector",
"url": "http://***/mms-style/darkMap.json"
}

All layers using vector tile maps must specify a "source-layer".

attribution

Optional attribute. string

Contains the properties to be displayed when presented to the user.

bounds

Optional attribute. array.

Array containing the longitude and latitude of the southwest and northeast corners of the source bounding box, in the following order: [sw.lng, sw.lat, ne.lng, ne.lat]. When this property is included in a source, Mapmost SDK for WebGL will not request any tiles outside the given bounds.

maxzoom

Optional attribute. number. Default value is 22.

The maximum zoom level available for tiles, as specified in the TileJSON specification. When displaying the map at higher zoom levels, the tile data on maxzoom will be used.

minzoom

Optional attribute. number. Default value is 0.

The minimum zoom level available for tiles, as specified in the TileJSON specification.

promoteId

Optional attribute. promoteId

Attribute used as feature id (used for feature status). It can be a property name or an object in the form of {sourceLayer:propertyName}. If specified as a string for a vector tile source, the same properties are used in all its data source layers.

scheme

Optional attribute. enum. One of "xyz" and "tms". Default value "xyz".

Affects the y direction of the tile coordinates. Assume Global Mercator (aka Spherical Mercator).

"xyz": Slippy map tile name scheme.

"tms": OSGeo specification scheme.

tiles

Optional attribute. array

One or more arrays containing tile source URLs, as shown in the TileJSON specification.

url

Optional attribute. string

The URL of the TileJSON resource. Supported protocols are: http:, https:.

volatile

Optional attribute. boolean. Default value false.

A setting that determines whether the source file’s tiles are cached locally.

Video (Video)

Video data source.

"video": {
"type": "video",
"urls": [
"./drone.mp4",
"./drone.webm"
],
"coordinates": [
[-122.51596391201019, 37.56238816766053],
[-122.51467645168304, 37.56410183312965],
[-122.51309394836426, 37.563391708549425],
[-122.51423120498657, 37.56161849366671]
]
}

coordinates

Required attribute. array

The array contains the latitude and longitude of the video corner points listed in clockwise order, corresponding to: upper left, upper right, lower right, lower left.

urls

Required attribute. string

urls is an array of video URLs, providing URLs in multiple formats to support cross-browser videos, arranged by preferred format.