Map

GeoGlobe. Map

GeoGlobe.Map类。

Constructor

new Map(options)

Example
var simple = {
    "version": 8,
    "source": {
        "geostar": {
            "type": "raster",
            "tiles": ["http://t2.tianditu.com/DataServer?T=vec_w&x={x}&y={y}&l={z}"],
            "tileSize": 256
        },
        "layers": [
            {
                "id": "1",
                "type": "raster",
                "source": "geostar",
                "raster-opacity": 1
            }
        ]
    }
};
var map = new GeoGlobe.Map({
    style: simple,
    container: 'map',
    zoom: 4,
    center: [112.939, 31.377],
    isAttributionControl: false
});
Parameters:
Name Type Description
options Object 地图对象相关选项设置。
Properties
Name Type Description
mapCRS Object 坐标参考系统
Properties
Name Type Description
topTileExtent Array 顶层瓦片范围
coordtransform function 自定义坐标变换函数
resolutions Array 栅格瓦片金字塔分辨率,0-22级,不足以null补全,例:[null,null,105,52,23,...]
tileSize Int 栅格瓦片大小,缺省则默认256
units String 地图单位。默认"degrees"。可能的值有"degrees","m"。Xian80、Beijing54地方坐标系设置"m"。
isIntScrollZoom Boolean 缩放级别是否为整数处理模式
renderWorldCopies Boolean 是否渲染世界多个副本
container HTMLElement | string 将在其中呈现地图的HTML元素,或元素的字符串ID
style Object | string 地图的样式。必须是符合样式规范中描述的模式的JSON对象,或者是此类JSON的URL
center LngLat | Array 地图的初始地理中心点
zoom Number 地图的初始缩放级别,默认为0
bearing Number 地图的初始方位(旋转),默认为0
pitch Number 地图的初始俯仰(倾斜),默认为0
xxx 更多属性参见 https://docs.mapbox.com/mapbox-gl-js/api/

Members

is3Dpitching :Boolean

设置是否倾斜
Type:
  • Boolean

pitch3Dzoom :Int

可选,3D倾斜层级,默认为16
Type:
  • Int

skipLevelOfZooming :Boolean

设置是否处理快速缩放时的注记图层显示的体验问题
Type:
  • Boolean

units :String

获取地图单位。默认"degrees"。可能的值有"degrees","m"
Type:
  • String

Methods

addCanvasLayer(canvaslayer)

添加canvas图层
Parameters:
Name Type Description
canvaslayer Object canvas图层

addLayer(layer)

添加图层
Parameters:
Name Type Description
layer Object 图层.

addLayerGroup(layers, groupid, beforeId)

在地图上添加一个图层组。
Parameters:
Name Type Description
layers ArrayObject layers The Mapbox style spec layers of the new group
groupid string id The id of the new group
beforeId string [beforeId] The layer id or group id after which the group will be inserted. If ommitted the group is added to the bottom of the style.

addLayers(layers)

添加多个图层
Parameters:
Name Type Description
layers Array 图层组

addLayerToGroup(layer, groupId)

在图层组上添加单个图层.
Parameters:
Name Type Description
layer Object layer The Mapbox style spec layer
groupId string The id of group

addVisualLayer(layer)

添加可视化图层
Parameters:
Name Type Description
layer Object

addWidget(widget, position)

移动图层容器
Parameters:
Name Type Description
widget GeoGlobe.Widget.Base widget对象
position Object widget位置

getLayer(id)

获取图层
Parameters:
Name Type Description
id Object 图层id

getLayerContainer(className)

获取图层容器
Parameters:
Name Type Description
className String 图层容器className

getLayersfromGroup(id)

获取图层组中图层
Parameters:
Name Type Description
id string The id of the group.

getLayersfromGroup(id)

清空图层组
Parameters:
Name Type Description
id string The id of the group.

getResolutionForLevel(level, tileSize)

根据层级获取分辨率
Parameters:
Name Type Description
level Int 层级.
tileSize Int 瓦片大小.

getResolutions()

获取地图分辨率

hideLayer(layerid)

根据图层id隐藏图层
Parameters:
Name Type Description
layerid string 图层id.

initialize(options)

Parameters:
Name Type Description
options Object

loadSprite(glyphs)

加载glyphs文件(字体url)
Parameters:
Name Type Description
glyphs String 路径.

loadSprite(sprite, imgPrefix)

加载sprite文件(图标集合)
Parameters:
Name Type Description
sprite String 路径.
imgPrefix String 可选sprite内小图片名称的前缀.

moveGroup(id, groupId)

移动整个图层组.
Parameters:
Name Type Description
id string The id of the group to be move.
groupId string The id of group

moveLayer(id, beforeId)

移动图层顺序
Parameters:
Name Type Description
id String 要移动的图层的ID
beforeId String 之前插入新图层的现有图层的ID。如果省略此参数,则新图层将移动到最上层

moveLayerContainer(className, before)

移动图层容器
Parameters:
Name Type Description
className String 图层容器className
before String 图层容器className

removeAllImages()

删除所有的图片符号

removeAllLayers()

删除所有的图层

removeAllSources()

删除所有的source

removeCanvasLayer(canvaslayer)

移除canvas图层
Parameters:
Name Type Description
canvaslayer Object canvas图层

removeLayer(id)

移除图层
Parameters:
Name Type Description
id String 要移除的图层的ID

removeLayerAndSource(layerid)

删除layer的同时删除与layerid一致的source
Parameters:
Name Type Description
layerid String 图层id.

removeLayerFromGroup(id, groupId)

移除图层组中单个图层.
Parameters:
Name Type Description
id string The layer's id of the group to be removed.
groupId string The id of group

removeLayerGroup(groupid)

移除图层组。
Parameters:
Name Type Description
groupid string The id of the group

removeLayers(ids)

移除多个图层
Parameters:
Name Type Description
ids Array.<String> 要移除的图层的ID

removeVisualLayer(layer)

移除可视化图层
Parameters:
Name Type Description
layer String

removeWidget(widget)

移动图层容器
Parameters:
Name Type Description
widget GeoGlobe.Widget.Base widget对象

set3Dzoom(zoom)

设置倾斜的层级
Parameters:
Name Type Description
zoom Int 倾斜的层级,层级在zoom和zoom+1之间的情况下,都会自动倾斜

setIs3DPZoom(is3Dpitching)

判断是否倾斜
Parameters:
Name Type Description
is3Dpitching Boolean 是否倾斜,默认为false

setIsConstrain(isConstrain)

设置地图是否在地图边界以内拖动
Parameters:
Name Type Description
isConstrain Boolean 判断地图是否在地图边界以内拖动.

setOpacity(layerid)

根据图层id设置图层透明度
Parameters:
Name Type Description
layerid string 图层id.

setZoompitch()

设置地图倾斜

showLayer(layerid)

根据图层id显示图层
Parameters:
Name Type Description
layerid string 图层id.

Events

boxcancel

See:
Properties:
Name Type Description
data MapBoxEvent
矩形拉框控件的取消事件

boxend

See:
Properties:
Name Type Description
data MapBoxEvent
矩形拉框控件的结束事件
Type:
  • Object

boxstart

See:
Properties:
Name Type Description
data MapBoxEvent
矩形拉框控件的开始事件