new VectorTilesMap()
Vector tile map class. (Currently supports loading multiple MVT services in the same coordinate system) Various standard references in the style of mapbox:“ https://docs.mapbox.com/mapbox-gl-js/style-spec/ ”.
| Name | Type | Description |
|---|---|---|
options.url |
String |
Suitable for generating mvt data through SuperMap desktop software and publishing it as a rest style map service through iServer. (Mapbox only supports grid tile data in the 3857 projection coordinate system, with global partitioning and tile origin fixed at the upper left corner of the 3857 projection) |
options.layerConfig |
String |
Layer configuration file. |
options.provider |
String |
Map service provider. |
options.name |
String |
Map name. |
options.billboardMode |
billboardMode |
optional
Set the display mode of the text to be flat and flat. |
options.localIdeographFontFamily |
Boolean |
optional
Used to set the text annotation font to the default font of the browser, solving the problem of mapbox not recognizing fonts and causing text not to be displayed. The default value is false. |
options.localFontFamily |
String |
optional
Used to set text priority to generate font files locally. If the font file is not available locally, it will be obtained from the font address in style.json, with a default value of null. Can be referred to https://docs.mapbox.com/mapbox-gl-js/api/map/ MVT characters are divided into ideographic characters (Chinese, Japanese, Korean, etc.) and alphabetical characters (English, Arabic, etc.) |
options.subdomains |
Array | String |
Multiple subdomains. When the input parameter is Array, it supports loading multiple subdomains. When the input parameter is String, only a single subdomain loading is supported. |
options.crs |
String |
Currently supports loading third-party coordinate systems EPSG: 4490, EPSG: 3857, default value EPSG: 4490. |
options.transformRequest |
function |
Callback function. Used to modify URLs, set headers, or set credential properties for cross source requests. The default value is null. |
Example
var mvtMap = scene.addVectorTilesMap({
url:URL_CONFIG.MVT,
canvasWidth:512,
name:'testMVT',
viewer:viewer,
transformRequest:function(url,resourceType){
return {
url:url.replace('http','https'),
headers:{'my-custom-header':true}
};
}
});
var layerReadyPromise = mvtMap.readyPromise;
layerReadyPromise.then(function(data){
// All subsequent API operations on MVT should be called inside readyPromise
})
Members
-
deprecated alphanumber
-
Get or set the overall transparency of the layer, with a value between 0 and 1 (0 is completely transparent).
- Default Value: 1.0
- See:
-
- VectorTilesMapSetting.alpha
detailLevelOffsetNumber
Set the fine layer of the MVT layer to use the texture of the coarse layer. Use numbers to specify the number of offset layers. For positive integers, use the texture of the fine layer above the current layer. For negative integers, offset downwards. Number represents the number of offset layers.
isOverlapDisplayedBoolean
Get or set whether the overlapping parts of layers are displayed. When set to true, the overlapping parts are still displayed and do not participate in avoidance. The default value is false (abandoned interface, currently supports text label avoidance effect by default).
- Default Value: false
deprecated lineAntialiasingboolean
Get or set whether the line is anti aliasing
- Default Value: true
- VectorTilesMapSetting.lineAntialiasing
mapboxStyle
Get or set the style object of the mapbox standard used by the layer, which can be used to modify the map style, style, theme map, etc. in the front-end. Various standard references in the style of Mapbox:“ https://docs.mapbox.com/mapbox-gl-js/style-spec/ ”.
maximumLevelNumber
Get the maximum level of the layer.
minimumLevelNumber
Get the minimum level of the layer.
readyPromisePromise
Get a promise that is true when the VectorTilesMap object is ready for use.
rectangleNumber
Obtain the geographical range of data.
- See:
selectedColorBoolean
Set the selected color to highlight, with the default value being SuperMap3D. Color.CYAN.
- Default Value: false
showBoolean
Get or set the visibility of layers.
style3DObject
Get or set display style.
- See:
swipeEnabledBoolean
Set whether to enable the rolling shutter function, default value: false.
- Default Value: false
swipeRegionBoundingRectangle
Set the upper left and lower right corners of the rolling shutter area, type: BoundingRectangle, default value is new ,SuperMap3D.BoundingRectangle(0.0,0.0,1.0,1.0)
tileHeightNumber
Obtain tile height.
tileWidthNumber
Obtain tile width.
tilingScheme
Global segmentation method for obtaining data.
Methods
-
addImage(id, options)
-
Add an image to the vector tile map.
Name Type Description idstring Image ID.
optionsObject Optional objects.
Name Type Description pixelRatioObject The ratio of image pixels to physical pixels on the screen.
sdfboolean Is the image an SDF image.
contentArray.<number> Shaped as [x1, x2, y1, y2]. This parameter only applies to symbol layers that use the 'icon text fit' style and the image itself This parameter specifies which area of the image can be covered by text, in pixels
stretchXArray.<Array.<number>> Shaped as [x1, x2], [x3, x4]. This parameter only applies to symbol layers that use the 'icon text fit' style and the image itself This parameter specifies the horizontal area for image stretching, measured in pixels
stretchYArray.<Array.<number>> Shaped as [y1, y2], [y3, y4]. This parameter only applies to symbol layers that use the 'icon text fit' style and the image itself This parameter specifies the vertical area for image stretching, measured in pixels
-
addLayer(layerObject, before)
-
Add layers.
Name Type Description layerObjectObject A layer parameter object that conforms to the layer specification in the style of Mapbox.
beforeString Specify a target layer based on the ID and place the newly added layer in front of it.
Example
// Add a new layer of type symbol before an existing layer map.addLayer({ id: 'states', // Here, the source needs to reference the id of a source object that already exists in a layer source: 'state-data', type: 'symbol', layout: { // Set the label text content to the value of the 'name' attribute in the feature 'text-field': ['get', 'name'] } // Add this new layer before an existing layer with id 'cities' }, 'cities'); -
addSource(id, source)
-
Add a mapbox style standard data source to the map
Name Type Description idstring The ID of the added data source. Duplicate data sources cannot exist
sourceObject Data source object, compliant with Mapbox style standards
Examples
添加SuperMap REST地图服务作为栅格数据源 map.addSource('myRestMap', { type: 'raster', url : "http://localhost:8090/iserver/services/map-myMap/rest/maps/myMap", });添加SuperMap REST海图出图服务作为栅格数据源,chartSetting为ChartSetting类型海图出图参数类 map.addSource('myRestChartMap', { type: 'raster', url : "http://localhost:8090/iserver/services/map-myRestChartMap/rest/maps/myRestChartMap", chartSetting : chartSetting });添加geojson务作为矢量数据源 map.addSource('my-data', { "type": "geojson", "data": { "type": "Feature", "geometry": { "type": "Point", "coordinates": [-77.0323, 38.9131] } } }); -
flyTo(center, zoom, scale)
-
Locate the camera position, MVT data can be located to a specified level.
The camera's perspective after positioning is vertically downward, with Cener as the center of the field of view, and MVT data is displayed at a specific level.
Applicable when terrain is not loaded.
Name Type Description centerArray The center of the field of view after positioning, the first value is longitude, and the second value is latitude, in degrees.
zoomNumber MVT hierarchy after positioning.
scaleNumber Global scale.
Example
mvtMap.flyTo({ center :[103.6454723, 40.134343], zoom : 11 }); mvtMap.flyTo({ center :[103.6454723, 40.134343], scale : 1.0/36978669.4318207 }) -
getFilter(layerID){Array}
-
Return the layer filter used by the specified ID layer
Name Type Description layerIDstring To obtain the layer ID of the filter object
Returns:
Type Description Array Filters used for layers Example
const filter = map.getFilter('myLayer'); -
getLayer(id){Object}
-
Return a layer parameter object that conforms to the layer specification in the mapbox style with a specified layer ID
Name Type Description idstring Layer object ID
Returns:
Type Description Object Return the layer object with the specified ID, or return undefined when the layer ID does not exist Example
const stateDataLayer = map.getLayer('state-data'); -
getLayoutProperty(layerId, name){*}
-
Return a property value in the layout object of the layer with the specified ID
Name Type Description layerIdstring To obtain the layer ID of the layout object
namestring To obtain the name of the property of the layout object
Returns:
Type Description * Return the property values of a specific layout object Example
const layoutProperty = map.getLayoutProperty('mySymbolLayer', 'icon-anchor'); -
getPaintProperty(layerId, name){*}
-
Return the value of the specified attribute in the canvas style of the specified layer
Name Type Description layerIdstring To obtain the layer ID of the canvas style object
namestring The property name of the canvas style object to be obtained
Returns:
Type Description * Return the value of a property of a canvas style object Example
const paintProperty = map.getPaintProperty('mySymbolLayer', 'icon-color'); -
getSource(id){Object}
-
Return the source object with the specified ID in the map style
Name Type Description idstring The ID of the source to get.
Returns:
Type Description Object Return the source object with the specified ID in the style. If the ID does not exist, return undefined The style source with the specified ID or undefined if the ID Example
const sourceObject = map.getSource('points'); -
getVisibleInViewport(index){Boolean}
-
Obtain layer corresponding viewport visibility, mainly used for split screen and large screen display.
Name Type Description indexNumber Indexes.
Throws:
-
the index is 0~8。
- Type
- DeveloperError
Returns:
Type Description Boolean Visible visibility. -
-
hasImage(id){boolean}
-
Determine whether there is an image with ID in the vector tile map.
Name Type Description idstring Image ID.
Returns:
Type Description boolean True indicates that the service has an image with ID, while false indicates otherwise. -
listImages(){Array.<number>}
-
Obtain all image IDs of the vector tile map.
Returns:
Type Description Array.<number> All image IDs for this service -
loadImage(url, callback)
-
Load an image for the vector tile map.
Name Type Description urlstring Image address.
callbackfunction The function called when the image loads successfully or fails, similar to callback (error, data)
Example
mvtMap.loadImage("./p.png", function(err, data){ if(err){ return; } mvtMap.addImage('imageId', data); }) -
moveLayer(id, beforeId)
-
Move the layer to the specified layer array.
Name Type Description idString The ID of the layer that is expected to be moved in position.
beforeIdString optional This ID specifies an existing layer, and the desired layer to be moved will be inserted before this existing layer. The layer to be moved specified by the ID will be displayed below the foredId layer. If this parameter is omitted, the moved layer will be appended to the end of the layer array and displayed above all other layers on the map.
Example
// Move Polygon1 to the position before Polygon2 in the array VectorTilesMap.moveLayer("ploygon1", "polygon2"); -
queryRenderedFeatures(cartographicArray, options, layers, filter)
-
Retrieve rendering features from a specified layer within a specified geographic range.
Name Type Description cartographicArrayArray.<Cartographic> | Cartographic Specify a geographic range, geographic coordinate point, or geographic coordinate array.
optionsObject Object.
layersArray.<string> The specified layer ID, if no layer ID is specified, returns the rendering features of all layers intersecting the specified range.
filterFilter filter.
-
querySourceFeatures(params)
-
Search for characteristic features. Based on the specified features, querying elements on the map now supports fuzzy queries.
Name Type Description paramsSearch based on the specified feature characteristics.
Example
var result = mvtMap.querySourceFeatures({ sourceLayer: selectLayer.id, // Sublayer name filter: ["like","NAME","京"] // Set fuzzy query filter criteria. For example, this can find features whose NAME attribute contains "Jing". }) -
releaseSelection()
-
Release the selected area.
-
removeImage(id)
-
Delete the image with the vector tile map ID as id.
Name Type Description idstring Image ID.
-
removeLayer(id)
-
Remove the layer with the specified ID.
Name Type Description idString The ID of the layer to be removed.
Example
// If a layer with id 'state-data' exists, remove it from the map if (map.getLayer('state-data')) map.removeLayer('state-data'); -
removeSource(id)
-
Remove a source with a specified ID from the map style
Name Type Description idstring The ID of the source to be removed
Example
map.removeSource('bathymetry-data'); -
setCRS(crs)
-
Docking with third-party MVT data (the coordinate system of the data must be set when loading third-party data).
Name Type Description crsString Currently supports EPSG: 4490, EPSG: 3857, default value EPSG: 4490.
Example
SuperMap3D.when(mvtMap.readyPromise, function(){ mvtMap.setCRS("EPSG:3857") }) -
setFilter(layerID, filter)
-
Setting the filter object filter used by the layer with a specified ID can control which features from its source objects are selected for rendering in a style layer. Only the features whose expression in the filter calculates' true 'will be rendered onto the map. Features with false calculation results will be hidden. You can use the setFilter method to control the subset of data in the data source you want to display. If you want to clarify the existing filters, the second parameter can be passed as' null 'or' undefined '
Name Type Description layerIDstring The ID of the layer using the filter
filterArray | null | undefined Filter information. Please refer to the [filter definition] section of Mapbox Style Specification for formatting. If passing 'null' or 'undefined', it will clear the existing filters of the layer
Examples
// In the 'my-layer' layer, only show those features whose 'name' attribute is 'CHINA' map.setFilter('my-layer', ['==', ['get', 'name'], 'CHINA']);// In the 'bike-docks' layer, only show those features whose 'available-spots' attribute value is greater than or equal to 5 map.setFilter('bike-docks', ['>=', ['get', 'available-spots'], 5]);// Remove the filter used in the style layer with id 'bike-docks' map.setFilter('bike-docks', null); -
setLayoutProperty(layerId, name, value, options)
-
Set the layout style for the layer with the specified ID. Through this interface, text wrapping display can be set.
Name Type Description layerIdString Proposed layer ID for setting layout style
nameString The name of the layout style.
valueString The value of layout style.
optionsObject optional Optional parameter object.
Example
设置文字换行的用法。 mvtMap.setLayoutProperty(子图层ID,'text-max-width',单行文本的最大字符数) mvtMap.setLayoutProperty("加油站注记#1", 'text-max-width',5 ) 设置文字图层不沿线旋转,默认值false。 mvtMap.setLayoutProperty("沿线文字图层id", 'ignore-line-rotation', true/false ) 设置沿线文字图层位置沿着矢量数据定义的顺序放置。 mvtMap.setLayoutProperty("沿线文字图层id", 'symbol-placement', 'line-direction') 沿线文字新增text-keep-upright-alignment风格,支持设置字体向上的对齐目标,默认值‘line'为mapbox渲染效果,与矢量线平行。viewport为文字渲染结果与视口平行。 mvtMap.setLayoutProperty(layer.id, 'text-keep-upright-alignment', 'viewport') 设置文字的方向,默认值为 ['horizontal', 'vertical'],'line' 为控制沿线文字按照矢量数据定义的顺序放置。 mvtMap.setLayoutProperty(layer.id, 'text-writing-mode', 'line') -
setPaintProperty(layerId, name, value, options)
-
Set the canvas style for the layer with the specified ID.
Name Type Description layerIdString Propose to set the layer ID for the canvas style.
nameString The name of the canvas.
valueString The value of the canvas.
optionsObject optional Optional parameter object.
-
setVisibleInViewport(index, visible)
-
Set the visibility of the viewport corresponding to the layer, mainly used for split screen and large screen display.
Name Type Description indexNumber Indexes.
visibleBoolean Visibility.
Throws:
-
the index is 0~8。
- Type
- DeveloperError
-
-
updateImage(id, image)
-
Update the image for the vector tile map.
Name Type Description idstring Image ID.
imageHTMLImageElement | ImageBitmap | ImageData | Object | StyleImageInterface Image data.