Class: WebMap

WebMap

对接 iPortal/Online 地图类。

Notice

该功能可能依赖以下插件,请确认引入该插件。

geostats: <script type="text/javascript" src="https://iclient.supermap.io/web/libs/geostats/geostats.js"></script>

jsonsql: <script type="text/javascript" src="https://iclient.supermap.io/web/libs/jsonsql/jsonsql.js"></script>

EchartLayer: <script type="text/javascript" src="https://iclient.supermap.io/web/libs/echartsLayer/EchartsLayer.min.js"></script>

echarts: <script type="text/javascript" src="https://iclient.supermap.io/web/libs/echarts/5.5.0/echarts.min.js"></script>

L7: <script type="text/javascript" src="https://iclient.supermap.io/web/libs/mapboxgl-l7-render/0.0.1/mapboxgl-l7-render.js"></script>

G2: <script type="text/javascript" src="https://iclient.supermap.io/web/libs/antv/g2/4.2.8/g2.min.js"></script>

G6: <script type="text/javascript" src="https://iclient.supermap.io/web/libs/antv/g6/4.3.2/g6.min.js"></script>

fast-xml-parser: <script type="text/javascript" src="https://iclient.supermap.io/web/libs/fast-xml-parser/4.2.7/fxparser.min.js"></script>

mapbox-gl-js-enhance: <script type="text/javascript" src="https://iclient.supermap.io/web/libs/mapbox-gl-js-enhance/1.12.1-7/mapbox-gl-enhance.js"></script>

new WebMap(id, options, mapOptions)

Usage
// 浏览器
<script type="text/javascript" src="https://iclient.supermap.io/dist/mapboxgl/iclient-mapboxgl.js"></script>
<script>
  new mapboxgl.supermap.WebMap(id, options, mapOptions);
  
</script>

// ES6 Import
import { WebMap } from '@supermapgis/iclient-mapboxgl';

new WebMap(id, options, mapOptions);

mapboxgl/mapping/WebMap.js, line 16
Name Type Description
id number

iPortal|Online 地图 ID。

options Object

基础参数。

Name Type Default Description
target string 'map' 可选

地图容器 ID。

server string "https://www.supermapol.com" 可选

地图的地址。当设置 id 时有效。

credentialKey string 可选

凭证密钥。当设置 id 时有效。

credentialValue string 可选

凭证值。当设置 id 时有效。

tiandituKey string 可选

用于访问天地图的服务。当设置 id 时有效。

googleMapsAPIKey string 可选

用于访问谷歌地图。当设置 id 时有效。

googleMapsLanguage string 可选

用于定义在谷歌地图图块上显示标签的语言。当设置 id 且底图为谷歌地图时有效。

withCredentials boolean false 可选

请求是否携带 cookie。当设置 id 时有效。

excludePortalProxyUrl boolean 可选

server 传递过来的 URL 是否带有代理。当设置 id 时有效。

ignoreBaseProjection boolean false 可选

是否忽略底图坐标系和叠加图层坐标系不一致。

isSuperMapOnline boolean 可选

是否是 SuperMap Online 地图。

iportalServiceProxyUrlPrefix string 可选

iportal的代理服务地址前缀。

proxy string | boolean 可选

HTTP 请求代理地址 。布尔值表示使用 iPortal 默认代理地址。

mapOptions Object

地图参数。

Name Type Description
center Array 可选

中心点。

zoom number 可选

缩放级别。

bearing number 可选

旋转角度。

pitch number 可选

倾角。

crs string | Object 可选

投影。

renderWorldCopies boolean 可选

连续渲染。

rasterTileSize number 可选

栅格瓦片大小。

style Object 可选

style 样式。

Version:
  • 9.1.2
Fires

Extends

Events

inherited deprecated addlayerssucceeded

common/mapping/WebMapBase.js, line 102

地图创建成功。自v11.2.1废弃,请使用WebMapBase#event:mapcreatesucceeded替代。

Properties:
Name Type Description
map Object

MapBoxGL Map 实例。

mapparams Object

地图信息。

mapParams.title string

地图标题。

mapParams.description string

地图描述。

layers Aarry

图层列表。

inherited baidumapnotsupport

common/mapping/WebMapBase.js, line 143

不支持百度地图。

inherited dataflowfeatureupdated

common/mapping/WebMapBase.js, line 153

数据流图层要素更新。

inherited deprecated getlayersfailed

common/mapping/WebMapBase.js, line 134

图层创建失败。自v11.2.1废弃,请使用WebMapBase#event:layercreatefailed替代。

Properties:
Name Type Description
error Object

失败原因。

map Object

MapBoxGL Map 实例。

layer Object

图层信息。

inherited deprecated getmapfailed

common/mapping/WebMapBase.js, line 119

地图创建失败。自v11.2.1废弃,请使用WebMapBase#event:mapcreatefailed替代。

Properties:
Name Type Description
error Object

失败原因。

inherited layercreatefailed

common/mapping/WebMapBase.js, line 126

图层创建失败。

Properties:
Name Type Description
error Object

失败原因。

map Object

MapBoxGL Map 实例。

layer Object

图层信息。

inherited layerorsourcenameduplicated

common/mapping/WebMapBase.js, line 148

图层名或数据源名重复。

inherited mapbeforeremove

common/mapping/WebMapBase.js, line 165

地图销毁前。

inherited mapcreatefailed

common/mapping/WebMapBase.js, line 113

地图创建失败。

Properties:
Name Type Description
error Object

失败原因。

inherited mapcreatesucceeded

common/mapping/WebMapBase.js, line 92

地图创建成功。

Properties:
Name Type Description
map Object

MapBoxGL Map 实例。

mapparams Object

地图信息。

mapParams.title string

地图标题。

mapParams.description string

地图描述。

layers Aarry

图层列表。

inherited mapinitialized

common/mapping/WebMapBase.js, line 86

地图初始化成功。

Properties:
Name Type Description
map Object

MapBoxGL Map 实例。

inherited projectionnotmatch

common/mapping/WebMapBase.js, line 158

底图投影与底图投影不匹配。

Methods

inherited clean(removeMap)

common/mapping/WebMapBase.js, line 466

删除地图或者清空地图上的图层和事件。

Name Type Default Description
removeMap boolean true 可选

是否删除地图。false 表示只清空地图上的图层和事件。

Version:
  • 11.2.1

inherited cleanLayers()

common/mapping/WebMapBase.js, line 487

删除追加的图层和事件。当设置 map 时有效

Version:
  • 11.2.1

inherited copyLayer(id, layerInfo){Array}

common/mapping/WebMapBase.js, line 454

复制指定图层。

Name Type Description
id string

指定图层 id。

layerInfo Object 可选

复制图层信息。如 id、source、layout

Version:
  • 11.2.1
Returns:
Type Description
Array 复制成功的信图层信息。

inherited getLayerCatalog(){Array}

common/mapping/WebMapBase.js, line 394

获取图层组。

Version:
  • 11.2.1
Returns:
Type Description
Array 图层组。

inherited getLayers(){Array}

common/mapping/WebMapBase.js, line 374

获取图层。

Version:
  • 11.2.1
Returns:
Type Description
Array 图层。

inherited getLegends(){Array}

common/mapping/WebMapBase.js, line 384

获取图例。

Version:
  • 11.2.1
Returns:
Type Description
Array 图例。

inherited getWebMapType(){String}

common/mapping/WebMapBase.js, line 419

获取地图类型。

Version:
  • 11.2.1
Returns:
Type Description
String 地图类型。

inherited rectifyLayersOrder(layers, topLayerBeforeId)

common/mapping/WebMapBase.js, line 429

根据已知顺序的可感知图层,对地图上图顺序进行排序。

Name Type Description
layers Array

图层列表。

topLayerBeforeId string

图层列表中置顶图层指定的 beforeId。

Version:
  • 11.2.1

inherited resize(keepBounds)

common/mapping/WebMapBase.js, line 178

调整地图大小。

Name Type Default Description
keepBounds boolean false 可选

是否保持当前地图范围。

inherited setBearing(pitch)

common/mapping/WebMapBase.js, line 250

更新地图旋转角度。

Name Type Description
pitch number

地图旋转角度。

inherited setCenter(center)

common/mapping/WebMapBase.js, line 223

更新地图中心点。

Name Type Description
center Array

地图中心点。

inherited setCRS(crs)

common/mapping/WebMapBase.js, line 196

更新地图投影。

Name Type Description
crs string | Object

地图 crs。

inherited deprecated setMapOptions(mapOptions)

common/mapping/WebMapBase.js, line 356

设置 map 参数。

Name Type Description
mapOptions Object

map 参数。

inherited setMaxBounds(maxBounds)

common/mapping/WebMapBase.js, line 307

更新地图 maxbounds。

Name Type Description
maxBounds number

地图最大缩放范围。

inherited setMaxZoom(maxZoom)

common/mapping/WebMapBase.js, line 332

更新地图 maxzoom。

Name Type Description
maxZoom number

地图最大缩放级别。

Version:
  • 11.2.1

inherited setMinZoom(minZoom)

common/mapping/WebMapBase.js, line 319

更新地图 minzoom。

Name Type Description
minZoom number

地图最小缩放级别。

Version:
  • 11.2.1

inherited setPitch(pitch)

common/mapping/WebMapBase.js, line 264

更新地图倾角。

Name Type Description
pitch number

地图倾角。

inherited setRasterTileSize(tileSize)

common/mapping/WebMapBase.js, line 290

更新地图栅格图层瓦片大小。

Name Type Description
tileSize number

栅格瓦片大小。

inherited setRenderWorldCopies(isWorldCopy)

common/mapping/WebMapBase.js, line 238

更新地图连续渲染。

Name Type Description
isWorldCopy boolean

地图是否连续渲染。

inherited setStyle(style)

common/mapping/WebMapBase.js, line 278

更新地图样式。

Name Type Description
style Object

地图 style 样式

inherited deprecated setWebMapOptions(webMapOptions)

common/mapping/WebMapBase.js, line 345

设置 webMap 参数。

Name Type Description
webMapOptions Object

webMap 参数。

inherited toggleLayerVisible(layer, visible)

common/mapping/WebMapBase.js, line 408

设置图层显隐。

Name Type Description
layer string

图层信息。

visible boolean

图层是否可见。true 表示显示,false 表示隐藏。

Version:
  • 11.2.1

inherited updateOverlayLayer(layerInfo, features, mergeByField)

common/mapping/WebMapBase.js, line 440

更新 geojson 图层要素信息。

Name Type Description
layerInfo Object

图层信息。

Name Type Description
id string 可选

图层信息 id。

renderSource string 可选

图层渲染 source 信息。

features Array

要素信息。

mergeByField string

属性关联字段。

Version:
  • 11.2.1