Class: MapboxStyles

ol.supermap.MapboxStyles

Mapbox 矢量瓦片风格。

Notice

该功能依赖 ol-mapbox-style 插件,请确认引入该插件。

``

new ol.supermap.MapboxStyles(options)

openlayers/overlay/vectortile/MapboxStyles.js, line 13
Name Type Description
options Object

初始化参数。

Name Type Description
url string | undefined 可选

SuperMap iServer 地图服务地址,例如'http://localhost:8090/iserver/services/map-mvt-test/rest/maps/test',与options.style互斥,优先级低于options.style。

opStyleMaptions.style Object | string | undefined 可选

Mapbox Style JSON 对象或获取 Mapbox Style JSON 对象的 URL。与 options.url 互斥,优先级高于 options.url。

options.resolutions Array.<number> 可选

地图分辨率数组,用于映射 zoom 值。通常情況与地图的 ol/View 的分辨率一致。
默认值为:[78271.51696402048,39135.75848201024, 19567.87924100512,9783.93962050256,4891.96981025128,2445.98490512564, 1222.99245256282,611.49622628141,305.748113140705,152.8740565703525, 76.43702828517625,38.21851414258813,19.109257071294063,9.554628535647032, 4.777314267823516,2.388657133911758,1.194328566955879,0.5971642834779395, 0.29858214173896974,0.14929107086948487,0.07464553543474244]。

options.source string | Array.<string> | undefined 可选

Mapbox Style 'source'的 key 值或者 'layer' 的 ID 数组。 当配置 'source' 的 key 值时,source 为该值的 layer 会被加载; 当配置为 'layer' 的 ID 数组时,指定的 layer 会被加载,注意被指定的 layer 需要有相同的 source。 当不配置时,默认为 Mapbox Style JSON 的 sources 对象中的第一个。

options.map ol/Map 可选

Openlayers 地图对象,仅用于面填充样式,若没有面填充样式可不填。

options.selectedStyle ol/StyleFunction 可选

选中样式Function。

options.withCredentials boolean 可选

请求是否携带 cookie。

Example
var mbStyle = new ol.supermap.MapboxStyles({
            url: url,
            source: 'California',
            resolutions: [78271.51696402048,39135.75848201024, 19567.87924100512,9783.93962050256,4891.96981025128,2445.98490512564]
    })
    mbStyle.on('styleLoaded', function () {
           var vectorLayer = new ol.layer.VectorTile({
                //设置避让参数
                declutter: true,
                source: new ol.source.VectorTileSuperMapRest({
                    url: url,
                    format: new ol.format.MVT({
                        featureClass: ol.Feature
                    }),
                    tileType: 'ScaleXY'
                }),
                style: mbStyle.featureStyleFuntion
            });
            map.addLayer(vectorLayer);
        })

Events

styleloaded

openlayers/overlay/vectortile/MapboxStyles.js, line 304

样式加载成功后触发。

Methods

addSelectedObjects(addSelectedObjects)

openlayers/overlay/vectortile/MapboxStyles.js, line 164

增加选中的要素或要素数组,该要素将会用 selectedStyle 样式绘制。调用该方法后需要调用 ol/layer/VectorTilechanged,才能生效。

Name Type Description
addSelectedObjects ol.supermap.MapboxStyles.selectedObject | Array.<ol.supermap.MapboxStyles.selectedObject>

选择的要素或要素数组。

Version:
  • 10.0.0

clearSelectedObjects()

openlayers/overlay/vectortile/MapboxStyles.js, line 176

清空选中状态。调用该方法后需要调用 ol/layer/VectorTilechanged,才能生效。

Version:
  • 10.0.0

clearSelectedObjects()

openlayers/overlay/vectortile/MapboxStyles.js, line 191

清空选中状态。调用该方法后需要调用 ol/layer/VectorTilechanged,才能生效。

Version:
  • 10.0.0

getStyleFunction(){ol/StyleFunction}

openlayers/overlay/vectortile/MapboxStyles.js, line 103

获取 ol/StyleFunction。

Returns:
Type Description
ol/StyleFunction 返回 ol/StyleFunction

getStylesBySourceLayer(sourceLayer)

openlayers/overlay/vectortile/MapboxStyles.js, line 111

根据图层名称获取样式。

Name Type Description
sourceLayer string

数据图层名称。

setSelectedId(selectedId, sourceLayer)

openlayers/overlay/vectortile/MapboxStyles.js, line 131

设置选中要素,该要素将会用 selectedStyle 样式绘制。调用该方法后需要调用 ol/layer/VectorTilechanged,才能生效。

Name Type Description
selectedId number

要素ID。

sourceLayer string

要素所在图层名称。

setSelectedObjects(addSelectedObjects)

openlayers/overlay/vectortile/MapboxStyles.js, line 151

设置选中要素或要素数组,该要素将会用 selectedStyle 样式绘制。调用该方法后需要调用 ol/layer/VectorTilechanged,才能生效。

Name Type Description
addSelectedObjects ol.supermap.MapboxStyles.selectedObject | Array.<ol.supermap.MapboxStyles.selectedObject>

选择的要素或要素数组。

Version:
  • 10.0.0

setStyle(style)

openlayers/overlay/vectortile/MapboxStyles.js, line 233

设置 Mapbox style 对象。

Name Type Description
style Object

Mapbox style 对象。

Version:
  • 9.1.1

updateStyles(layerStyles)

openlayers/overlay/vectortile/MapboxStyles.js, line 199

更新图层样式。

Name Type Description
layerStyles Object

图层样式或图层样式数组。

Type Definitions

ol.supermap.MapboxStyles.selectedObjectObject

要选择的要素对象。

Properties:
Name Type Description
selectedId number

要素ID。

sourceLayer string

要素所在图层名称。