Skip to main content

datasource(sources)

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

Data source types includevectorrasterraster-demgeojsonimagevideotypeThe value of the attribute must be one of these.

Description: Complete onlysourceAdding does not allow the data to be displayed on the map. You also need to define a layer style based on this data.

tile map (Tiled sources)

Tile map services (vector and raster) must be based onTileJSONThe specification specifies their details. The specific form of defining the data source is as follows:

  • By providing it directly in the source codeTileJSONattributes, such as"tiles""minzoom"and"maxzoom":
"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
}
  • forTileJSONAdd a resource"url":
"mapmost-dark": {
"type": "vector",
"url": "http://api.example.com/tilejson.json"
}
  • by providing aWMSservingURLas a data source. supportEPSG:3857(orEPSG:900913)map service, serviceURLmiddlebboxThe parameters need 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 2000special edition】supportEPSG:4490map service, serviceURLmiddlebboxThe parameters need 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

An 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 LiteNo tiles outside the given bounds will be requested.

maxzoom

Optional attribute.number。 default value22。

The maximum zoom level available for the tile, e.g.TileJSONas shown in the specification. When displaying the map at a higher zoom level, themaxzoomtile data on.

minzoom

Optional attribute.number。 default value0。

The minimum zoom level available for the tile, e.g.TileJSONas shown in the specification.

promoteId

Optional attribute.promoteId

used as propertiesidAttributes (for property status). It can be an attribute name or{sourceLayer:propertyName}form object. 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"xyz"and"tms"one of the. default value"xyz"

Affects tile coordinatesydirection. Assume Global Mercator (aka Spherical Mercator).

"xyz": Slippy Map tile name scheme.

"tms": OSGeo Standardize the plan.

tiles

Optional attribute.array

one or more containstilesourceurlarray, such asTileJSONas shown in the specification.

url

Optional attribute.string

TileJSONresourceURL。 Supported protocols are: http:https:

volatile

Optional attribute.boolean。default valuefalse

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

grid 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

An 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 LiteNo request will be sent to any tile outside the boundary.

maxzoom

Optional attribute.number。default value22。

The maximum zoom level available for raster tiles, e.g.TileJSONas shown in the specification. When displaying the map at a higher zoom level, themaxzoomtile data on.

minzoom

Optional attribute.number。default value0。

The minimum zoom level available for the tile, e.g.TileJSONas shown in the specification.

scheme

Optional attribute.enum"xyz"and"tms"One of the default values"xyz"

Affects tile coordinatesydirection. Assume a Global Mercator (aka Spherical Mercator) profile.

"xyz": Slippy Map tile name scheme.

"tms": OSGeo Standardize the plan.

tiles

Optional attribute.string

one or moretilesourceurlarray, such asTileJSONas shown in the specification.

tileSize

Optional attribute.number。Unit pixel, default value512。

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

url

Optional attribute.string

TileJSONresourceURL。 Supported protocols are:http:https:

gridDEMtile(Raster-dem)

gridDEMsource. Only supportsMapbox Terrain-DEM (Mapbox:// Mapbox . Mapbox - Terrain-DEM -v1):

"mapbox-terrain-dem-v1": {
"type": "raster-dem",
"url": "mapbox://mapbox.mapbox-terrain-dem-v1"
}

attribution

Optional attribute.string

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

bounds

Optional attribute.array

An 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 LiteRequests will not be sent to any detile outside the boundary.

minzoom

Optional attribute.number。default value0。

The minimum zoom level available for the tile, e.g.TileJSONas shown in the specification.

tiles

Optional attribute.string

one or moretilesourceurlarray, such asTileJSONas shown in the specification.

tileSize

Optional attribute.number。Unit pixel. default value512。

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

url

Optional attribute.string

TileJSONresourceURL。 Supported protocols are:http:https:

GeoJSON

GeoJSONsource. data must pass"data"Attributes are provided whose values ​​can beURLor inlineGeoJSON。

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

thisGeoJSONSource examples viaURLreferences an externalGeoJSONdocument. GeoJSONDocuments must be in the same domain, or you can useCORSaccess.

"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。Value range0 ~ 512(Contains512), default value128。

The size around the tile. The value is0No buffer is generated. The value is512will create 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 valuefalse

If the data is a collection of point features, set this totrue,And cluster the points into groups according to the radius. Point cluster group becomes new in source codePointFeatures, with additional properties:

  • True if the point is a cluster.

  • cluster_ids,It is the only one used in conjunction with the cluster inspection method.id。

  • 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 less thanmaxzoomof one scale (so the final scaled features don’t cluster together). The cluster will be re-evaluated at an integer scale level, so theclusterMaxZoomset to14means that the cluster will be displayed untilz15。

clusterMinpoints

Optional attribute.number

After enabling the cluster function, the minimum number of points required to form a cluster. default value2。

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{"property_name": [operator, map_expression]}form. OperatorAny expression function that can accept at least two operands (e.g.: "+"or"max"),it goes through the cluster/The attribute values ​​contained in the point cluster are accumulated; Map_expressionValues ​​for individual points can be generated.

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

For more advanced cases you can use a customreduceexpression instead of an operator, it refers to a special[" cumulative "]value, for example:{"sum": [["+", [" cumulative "], ["get", "sum"]], ["get", "scalerank"]]}

clusterRadius

Optional attribute. Greater than or equal to0ofnumber。default value50。

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

data

Optional attribute.

a pointGeoJSONDocumentaryURL,or inlineGeoJSON。

filter

Optional attribute.

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

generateId

Optional attribute.boolean。default valuefalse

Is itgeojsongenerateid。 When enabled, thefeature.idThe property will be based on thefeaturesIndexes in the array are automatically assigned and overwrite previous values.

lineMetrics

Optional attribute.boolean。default valuefalse

Whether to calculate line distance metrics. This is useful for specifyingline-gradientThe value line layer is required.

maxzoom

Optional attribute.number。default value18。

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

promoteId

Optional attribute.promoteId

used as propertiesidAttributes (for property status). It can be an attribute name or{sourceLayer:propertyName}`form object. 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 value0.375。

Douglas-PeuckerSimplified tolerances (higher means simpler geometry and faster performance).

image(Image)

Image data source.

"image": {
"type": "image",
"url": "https://docs.mapbox.com/mapbox-gl-js/assets/radar.gif",
"coordinates": [
[-80.425, 46.437],
[-71.516, 46.437],
[-71.516, 37.936],
[-80.425, 37.936]
]
}

coordinates

Required attribute.array

coordinatesThe 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

graphicURL。

video(Video)

Video data source.

"video": {
"type": "video",
"urls": [
"https://static-assets.mapbox.com/mapbox-gl-js/drone.mp4",
"https://static-assets.mapbox.com/mapbox-gl-js/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

urlsfor videourlArray, providing multiple formatsurlTo support cross-browser videos, arranged by preferred format.