szgeoinfo.Map

Class: szgeoinfo.Map


new Map(div, options)

地图初始化

Parameters:
Name Type Description
div string

地图div控件the container of map object div

options object

Properties
Name Type Description
maptype szgeoinfo.MapType

地图类型,MAP2D二维,MAP23D二三维,MAP3D三维,默认三维

center szgeoinfo.Point

中心点 ,默认[114.0786518,22.53286926]

zoom int

默认地图层级,默认10

rotate int

地图方向,默认0

showmodel boolean

是否显示三维模型,默认true

showterrain boolean

是否显示地形图,默认true

terrainExaggeration int

地形图放大级别,默认1

showszimage boolean

是否显示深圳影像图,默认true

showszvector boolean

是否显示深圳矢量图,默认false

showSZVecGrey boolean

是否显示深圳灰底电子地图,默认false

showSZVecBlue boolean

是否显示深圳蓝底电子地图,默认false

showtdtimage boolean

是否显示天地图影像图,默认false

showtdtvector boolean

是否显示天地图矢量图,默认false

showtdtterrain boolean

是否显示天地图地形图,默认false

showGaodeImg boolean

是否显示高德影像图,默认false

showGaodeVec boolean

是否显示高德矢量图,默认false

showTencentImg boolean

是否显示腾讯影像图,默认false

showTencentVec boolean

是否显示腾讯矢量图,默认false

showBaiduImg boolean

是否显示百度影像图,默认false

showBaiduVec boolean

是否显示百度矢量图,默认false

showtdtVecAnn boolean

是否显示天地图矢量图注记,默认false

showtdtImgAnn boolean

是否显示天地图影像图注记,默认false

showBaiduRealTimeRoad boolean

是否显示百度实时路况图,默认false

showTencentRealTimeRoad boolean

是否显示腾讯实时路况图,默认false

showSZJWRealTimeRoad boolean

是否显示深圳交委实时路况图,默认false

loadBasicMap array

按地图类型加载切换图层的列表,szgeoinfo.BasicMaps.Shenzhen深圳本地地图 ,szgeoinfo.BasicMaps.Tianditu天地图,szgeoinfo.BasicMaps.Gaode高德地图,szgeoinfo.BasicMaps.Baidu百度地图 ,szgeoinfo.BasicMaps.Tencent腾讯地图,szgeoinfo.BasicMaps.BaiDuRealTimeRoad百度路况, szgeoinfo.BasicMaps.TencentRealTimeRoad腾讯路况

zdyBasicMap array

图层控件中自定义添加底图,其中格式数据为json类型(title,visible,url),加载的底图必须符合OGC-WMTS服务规范

enableLight boolean

三维模式下,是否使用太阳光

Example
var map = new szgeoinfo.Map("map", {
            maptype: szgeoinfo.MapType.MAP2D,
            center: new szgeoinfo.Point(114.241296177544, 22.8121778789908),
            zoom: 14,
			showmodel:false,
			showterrain:false,
            showtdtvector: true,
            showtdtVecAnn:true,
            showszvector: false,
            showszimage: false,
            showtdtVecAnn: true,
            loadBasicMap:[szgeoinfo.BasicMaps.Tianditu,szgeoinfo.BasicMaps.Tencent],//三维模式下,未能加载百度地图,正在开发中
            zdyBasicMap:[
            {"title":"自定义名称","visible":true,"url":"http://localhost:6080/arcgis/rest/services/szimage/MapServer"}]
         });

Methods


add3DMarker(point,imgUrl,id,name)

添加三维标记点

Parameters:
Name Type Description
point szgeoinfo.Point

点坐标数组

imgUrl string

引用的标记符号图片路径

id int

当前标记点的序号[可选择是否添加]

name string

当前标记点的名称[可选择是否添加]

Example
var point=new szgeoinfo.Point(114.091,22.545,50);
var imgUrl= "images/marker.png";
map.add3DMarker(point,imgUrl,101,"标记");
map.flyTo(point);

add3DModel(point, gltfurl) → {model}

添加3d模型,加载GLTF模型

Parameters:
Name Type Description
point szgeoinfo.Point

点坐标数组

gltfurl string

gltf模型的url

Returns:

3d模型

Example
var point = new szgeoinfo.Point(114.031022,22.546025,20);
var model = map.add3DModel(point,"model2.gltf");

add3dModelInfo(infoWin)

添加模型信息窗口

Parameters:
Name Type Description
infoWin szgeoinfo.ModelInfoWindow

模型信息窗口

Example
map.add3dModelInfo(infoWin);
                                

add3dPolylineTerrain(id,pointArr,width,color,isFill,callback)→ {primitive}

三维模式下,添加贴地折线

Parameters:
Name Type Description
id int|string

模型的Id

pointArr array

坐标点

width number

折线宽度,默认1

color string

折线颜色,默认#3C3F41

isFill boolean

是否填充

callback function

返回填充对象,id

Example
var point = [114.06119781467079,22.523162934774177];
map.add3dPolylineTerrain(undefined,point,1.5,"#FF0000",true,function (){});
                                

add3dPolygon(id, pointArr, extrudedHeight, red, green, blue, opacity) → {primitive}

三维模式下绘制面

Parameters:
Name Type Description
id string

多边形的Id

pointArr array

坐标数组

extrudedHeight number

多边形的挤压面和椭球面之间的距离(以米为单位)

red number

红色组件,取值[0~1],默认0

green number

绿色组件,取值[0~1],默认0

blue number

蓝色组件,取值[0~1],默认1

opacity number

透明度,取值[0~1],默认1

Returns:

面对象,生成的Id是以extrudedPolygon为前缀

Example
 var neArr = [114.06119781467079,22.523162934774177,114.06136947643337,22.52322239794711...];
 map.add3dPolygon("123",neArr,112,0.48235,0.40784,0.93333,0.9);

add3dPolyline(polyline) → {primitive}

三维模式下绘制折线

Parameters:
Name Type Description
polyline szgeoinfo.Polyline3d

折线对象

Returns:

折线对象

Example
var neArr = [114.0599325299263, 22.522135847165785,20,114.05996471643448, 22.521907903981045,20,114.05987352132796
,22.521873216941714,20,114.0597715973854, 22.521873216941714,20];
//添加折线
var py = new szgeoinfo.Polyline3d("5237",neArr,5,1,0.182,0.9,0.8);
map.add3dPolyline(py);
                                

addBillboard(id,url,fileName,optionType,callback,options) → {object}

三维模式下,添加或加载广告牌

Parameters:
Name Type Description
id int

广告牌的Id

url string

文件路径,video格式mp4,img格式jpg、png、jpeg、gif

fileName string

文件名称

optionType string

操作方式,'add'表示添加广告牌,'load'表示加载广告牌

callback function

回调函数

options object

Properties
Name Type Description
minHeight number

广告牌离地的高度

maxHeight number

广告牌的高度

left szgeoinfo.Point

左侧点的坐标

right szgeoinfo.Point

右侧点的坐标

Returns:
  • {int} 广告牌的Id

  • {number} 广告牌的高度

  • {number} 广告牌的离地高度

  • {entity} 广告牌的对象

  • {szgeoinfo.Point} 左侧点

  • {szgeoinfo.Point} 右侧点

Example
   //添加广告牌
     map.addBillboard(id,url,fileName,'add',function(id,maxHeight,minHeight,sphere,left,right){
              console.log(sphere);
    });
    //加载广告牌
    var options={
        minHeight: 5,
        maxHeight:80,
        left:new szgeoinfo.Point(114.03279435129183,22.546226059142647),
        right:new szgeoinfo.Point(114.0336989027813,22.546408446920157)
    }
    map.addBillboard(id,url,fileName,'load',null,options);
                                

addCircle(point, linecolor, linewidth, fillcolor, text, font, fontColor, radius) → {feature}

添加始终包围文本的圆

Parameters:
Name Type Description
point szgeoinfo.Point

圆点坐标

linecolor string

线颜色,默认#000000

linewidth int

线宽,默认2

fillcolor string

填充颜色,默认#ffffff

text string

文本信息

font string

字体风格,默认‘bold 20px 宋体’

fontColor string

字体颜色,默认#000000

radius number

圆的半径,默认6

Returns:

圆对象

Example
var point=new szgeoinfo.Point(114.0507591 ,22.58550907);
var circle= map.addCircle(point,"#FF0000",4,"#00FFFF","福田区 106栋","bold 20px 宋体","#FF0000",11);

addClippingPlaneByPoint(centerPoint,distance)

根据中心点添加裁切面(指定中心点和裁切半径,裁切构造出的四边形范围内的三维模型)

Parameters:
Name Type Description
centerPoint szgeoinfo.Point

裁切范围的中心点

distance double

單位米, 裁切范围的半徑

Example
var centerPoint = new szgeoinfo.Point(114.032539,22.546371,24);
map.addClippingPlaneByPoint(centerPoint,1000);

addClippingPlaneByPointsArray(pointsArray)

根据坐标数组添加裁切面(通过沿顺时针方向的多边形坐标数组,构造裁切范围,进行三维模型裁切)

Parameters:
Name Type Description
pointsArray szgeoinfo.Point

构成裁切多边形的坐标数组

Example
var points=[];
var point1= new szgeoinfo.Point(114.034930,22.588129,24);
var point2= new szgeoinfo.Point(114.034930,22.446129,24);
var point3= new szgeoinfo.Point(114.031930,22.446129,24);
var point4= new szgeoinfo.Point(114.031930,22.588129,24);
    points.push(point1);
    points.push(point2);
    points.push(point3);
    points.push(point4);
    map.addClippingPlaneByPointsArray(points);

addClickEvent(callback) → {object}

地图点击事件

Parameters:
Name Type Description
callback function

回调函数

Returns:
  • {szgeoinfo.Point} 真实坐标

  • {szgeoinfo.Point} 像素坐标

Example
map.addClickEvent(function(point,pixel) {
});

addControl(control)

添加控件

Parameters:
Name Type Description
control szgeoinfo.Control

控件

Example
var options=new Array();
 options.element=document.getElementById("controlDiv");
 options.className="divClass";
 options.style="width:100%";
 var control=new  szgeoinfo.Control(options);
 map.addControl(control);
                                

addDragEvent(callback) → {array,array}

添加地图的拉框事件

Parameters:
Name Type Description
callback function

回调函数,返回最小经纬度坐标和最大经纬度坐标

Returns:

返回最小经纬度坐标和最大经纬度坐标

Example
map.addDragEvent(function(point1,point2){});
                                

addGeoJsonData(url,callback,id)

加载GeoJson或者TopJson数据,json数据需要具有BLDG_HEIGH属性

Parameters:
Name Type Description
url string

GeoJson数据地址

callback function

回调函数,返回dataSource,选填

id int

二三维图层编码,选填

Example
map.addGeoJsonData(url,function(data){
     var dataSource=data;
 },id);

addLabel3D(label3d)

添加lable3D标注

Parameters:
Name Type Description
label3d szgeoinfo.Label3D

Label3D对象

Example
map.addLabel3D(label3d);//添加lable3D标注

addLayerControl()

添加图层控制控件

Example
map.addLayerControl();
map.removeLayerControl();//移除数据仓库控件

addArcGISRest(layer)

添加ArcGIS Rest服务图层

Parameters:
Name Type Description
layer szgeoinfo.layer.ArcGISLayer

ArcGIS Rest图层,支持MapServer和ImageServer

Example
var layer0 = new szgeoinfo.layer.ArcGISLayer(123, "图层","http://localhost:6080/arcgis/rest/services/theme/MapServer");
map.addArcGISRest(layer0);
                                

addLogoControl()

添加左下角Logo控件

Example
map.addLogoControl();

addJsonData(dataUrl,geojsonUrl)

加载包含GeoJaon或者TopJson数据的json数据源

Parameters:
Name Type Description
dataUrl string

数据目录地址

geojsonUrl string

json数据地址,数据结构中需包含TYPE(值为Json、GeoJson或TopoJson)、SQCODE属性和FileName属性

Example
map.addJsonData(dataUrl,geojsonUrl);//加载json数据
var szDataSource=map.getDataSourceArray();//获取DataSources列表
map.setLayer(707,szDataSource);//添加到图层列表,进行隐藏显示样式的调整

addMarker(marker)

添加marker或feature

Parameters:
Name Type Description
marker szgeoinfo.Marker

点线面 marker

Example
var one = new szgeoinfo.Point(114.0907591,22.54550907);
var stroke=new szgeoinfo.style.Stroke("rgba(253,206,4,1)",1);//边框颜色宽度
var size=[200,200];//图片尺寸
var image=new szgeoinfo.style.Image("images/box.png",size,1);
var style=new szgeoinfo.style.Style('',stroke,image,'');
var marker=new szgeoinfo.Marker(one,style);
map.addMarker(marker);
                                

addModelClickEvent(callback) → {object}

添加三维模型点击事件

Parameters:
Name Type Description
callback function

点击回调函数

Returns:
  • {json} 返回属性数组

  • {model} 返回模型对象

  • {szgeoinfo.Point} 返回当前点击的坐标

Example
map.addModelClickEvent(function(json,model,position){
        map.setModelColor(model,"#00f800");
});

addModelOverEvent(callback) → {object}

添加三维模型鼠标悬浮事件

Parameters:
Name Type Description
callback function

点击回调函数

Returns:
  • {json} 返回属性数组

  • {model} 返回模型对象

  • {szgeoinfo.Point} 返回当前点击的坐标

Example
map.addModelOverEvent(function(json,model,point){
                if(name != null){
                    map.setModelColor(model,"CD0801");
                    var modelName=name;
                }
 });

add3DTileset(url,id,maxSSE,maxMU)

加载3DTiles数据

Parameters:
Name Type Description
url string

3DTiles模型地址

id number

3DTiles模型图层编码

maxSSE number

控制模型加载时的最小比例,默认60

maxMU number

控制三维引擎的最大内存占用量,默认800

Example
map.add3DTileset(url,id);

addOverlay(marker)

添加覆盖物

Parameters:
Name Type Description
marker szgeoinfo.Overlay

点线面覆盖物

Example
var center = new szgeoinfo.Point(114.031022,22.546025);
var overlay=new szgeoinfo.Overlay(center,"images/pic/bluepoint.png");
overlay.name = "";
overlay.point = center;
//鼠标点击
overlay.setClickFun(function () {});
//鼠标悬浮
overlay.setMouseOverFun(function () {
        overlay.element.style='cursor:pointer';
        overlay.element.title="深圳";
});
//鼠标移开
overlay.setMouseOutFun(function () {});
map.addOverlay(overlay);
                                

addPmtsData(url,id)

加载PMTSCapabilities模型服务

Parameters:
Name Type Description
url string

PMTSCapabilities模型地址

id number

三维数据模型编码

Example
map.addPmtsData(url,id);

addPOIControl()

添加查询POI控件

Example
map.addPOIControl();
map.removePOIControl();//移除POI查询控件

addPoint(point, name, imgurl,options) → {feature}

添加点图标

Parameters:
Name Type Description
point szgeoinfo.Point

点坐标

name string

名称

imgurl string

图标url 默认image/marker.png

options array

Properties
Name Type Description
font string

字体风格,默认'bold 18px 宋体'

fillColor string

填充颜色,默认'rgb(0,0,0)'

strokeColor string

边框颜色,默认'rgb(255,255,255)'

strokeWidth int

边框宽度,默认10

offsetY int

Y偏移,二维默认-2

offsetX int

X偏移,二维默认25

Returns:

点对象

Example
 var options={};
 options.font = 'bold p18x 宋体';//字体风格
 options.fillColor = 'rgb(0,0,0)';//填充颜色
 options.strokeColor = 'pink';//边框颜色
 options.strokeWidth = 8;//边框宽度
 options.offsetY = -10;//Y偏移
 options.offsetX =110;//X偏移
 var one = new szgeoinfo.Point(114.0907591,22.54550907);
 var point = map.addPoint(one,"广东省深圳市","images/Page2.png",options);
 map.setFeatureId(point,"123");
 var two = new szgeoinfo.Point(114.1907591,22.54550907);
 var point = map.addPoint(two,"中心2","images/Page2.png");
 map.setFeatureId(point,245);
map.setFeatureClick(function(point, pixel, selfeature){
   alert(map.getFeatureId(selfeature));
});

addPointFeature(point,style) → {feature}

渲染的feature点的样式并返回渲染后的对象

Parameters:
Name Type Description
point szgeoinfo.Point

点坐标

style szgeoinfo.style.Style

自定义样式

Returns:

feature 要素

Example
var point=new szgeoinfo.Point(114.0907591,22.54550907,23);
var fill=new szgeoinfo.style.Fill("rgba(253,206,4,1)");//填充颜色
var stroke=new szgeoinfo.style.Stroke("rgba(253,206,4,1)",1);//边框颜色宽度
var text=new szgeoinfo.style.Text('bold 24px 宋体',0,0,'',new szgeoinfo.style.Fill("rgba(255,255,255,1)"),'',setFeatureText);//显示绘制后的坐标
var image=new szgeoinfo.style.Image("images/bluepoint.png",[500,500],1);
var style=new szgeoinfo.style.Style(fill,stroke,image,text);
map.addPointFeature(point,style);
                                

addPointMarker(callback,title) → {szgeoinfo.Point}

点击添加标注点

Parameters:
Name Type Description
callback function

回调函数

title string

点击位置的文本,默认是标记

Returns:

点击point对象

Example
map.addPointMarker(function(point) {
},'');

addPolygon(points, linecolor, linewidth, linetype, fillcolor, opacity) → {feature}

添加面

Parameters:
Name Type Description
points szgeoinfo.Point

点坐标数组

linecolor string

线颜色,默认#000000

linewidth int

线宽,默认2

linetype string

线类型,默认是实线,1为实线,2为虚线

fillcolor string

填充颜色,默认#ffffff

opacity int

透明度,默认1

Returns:

面对象

Example
var ps=[];
 ps.push(new szgeoinfo.Point( 114.0896358 ,22.54673895,20));
 ps.push(new szgeoinfo.Point( 114.0920923 ,22.54766566,20));
 ps.push(new szgeoinfo.Point(114.089097, 22.54756566,20));
 var plo=map.addPolygon(ps,"#FF0000",4,1,"#ffffff",0.5);

addPolyline(points, linecolor, linewidth, linetype) → {feature}

添加线

Parameters:
Name Type Description
points szgeoinfo.Point

点坐标数组

linecolor string

线颜色,默认#00000

linewidth int

线宽,默认2

linetype string

线类型,默认是实线,1为实线,2为虚线

Returns:

线对象

Example
var ps=[];
 ps.push(new szgeoinfo.Point(114.0900388 ,22.54558073,20));
 ps.push(new szgeoinfo.Point(114.0906597 ,22.54599398,20));
 ps.push(new szgeoinfo.Point(114.0844816,22.54664931,20));
 map.addPolyline(ps,"#FF0000",4);

addPopUp(options, point, html)

添加弹出框

Parameters:
Name Type Description
point szgeoinfo.Point

显示位置

options object

Properties
Name Type Description
autoPan object

true表示调用时将叠加层在当前视图中完全可见,默认true

autoPanAnimation object

用于覆盖图平移到视图中的动画选项,此动画仅在autoPan启用时使用

Name Type Description
duration number

动画的持续时间,以毫秒为单位,默认250

html string

显示内容

Example
map.clearOverlays();//清空之前的PopUp对象
var html='<h1>标题</h1><dl><dd>内容</dd><dt>时间</dt></dl>';
var point = new szgeoinfo.Point(114.031022,22.546025,20);
var popup= map.addPopUp({
         width:"100px",
         height:"100px"
       },point,html);
popup.hide();//隐藏PopUp的对象

addPrimitiveClickEvent(callback) → {primitive}

添加primitive的点击事件,如多边形、折线

Parameters:
Name Type Description
callback function

回调函数

Returns:

primitive对象

Example
 map.addPrimitiveClickEvent(function(primitive){
            if(primitive){
                   alert(map.getPrimitiveId(primitive));//获取多边形的Id
                   if(map.getPrimitiveId(primitive) == 'extrudedPolyline5237'){
                       map.setPrimitiveStyle(primitive,0,1,1,0.8);
                   }else{
                       map.setPrimitiveStyle(primitive);
                   }
            }
 });
 map.removePrimitiveClickEvent();//移除primitive的点击事件
 

addRectWithText(point, linecolor, linewidth, fillcolor, text, font, fontColor) → {feature}

添加始终包围文本的矩形

Parameters:
Name Type Description
point szgeoinfo.Point

圆点坐标

linecolor string

线颜色,默认#000000

linewidth int

线宽,默认2

fillcolor string

填充颜色,默认#ffffff

text string

文本信息

font string

字体风格,默认‘bold 20px 宋体’

fontColor string

字体颜色,默认#000000

Returns:

矩形对象

Example
var point=new szgeoinfo.Point(114.0507591 ,22.58550907);
var rect= map.addRectWithText(point,"#FF0000",4,"#00FFFF","福田区 106栋","bold 20px 宋体","#FF0000");

addressResolution(place, callback) → {array}

地址解析

Parameters:
Name Type Description
place string

地址

callback function

回调函数

Returns:

返回解析后的坐标数组

Example
map.addressResolution("规划大厦",function(data){
for(var i = 0; i < data.length; i++){
    var name=data[i]["name"];
    var address=data[i]["address"];
    var lon=data[i]["lon"];
    var lat=data[i]["lat"];
    console.log("名称:"+name+",地址"+address+",经纬度["+lon+","+lat+"]");
   }
});

addScaleLineControl()

添加比例尺控件

Example
map.addScaleLineControl();
                                

addSZGeoLayerControl(menuUrl,dataUrl)

添加SZGeo图层控件

Parameters:
Name Type Description
menuUrl string

数据目录的一二级菜单,默认加载数据仓库数据

dataUrl string

数据地址和元数据信息,默认加载数据仓库数据

Example
map.addSZGeoLayerControl("menu.json","data.json");
    

addToolControl(options)

添加Tool控件,可自定义视图、工具、功能

Parameters:
Name Type Description
options object

Properties
Name Type Description
view array

视图(2D、3D、23D)

tool array

工具(放大、缩小、地形、全图)

widget array

参照主页面的功能,填写相应功能的中文名(地区导航、地图打印.......)

Example
//添加全部的功能
 map.addToolControl();
 //添加自定义的功能
  map.addToolControl({
		view:['2D','3D'],
        tool:['放大','缩小','全图'],
        widget:['地下管线','地图打印']
  }); 

addWFSLayer(layer)

添加WFS图层

Parameters:
Name Type Description
layer szgeoinfo.layer.WFSLayer

添加WFS图层

Example
var layer0 = new szgeoinfo.layer.WFSLayer(123,"图层","http://localhost:6080/arcgis/rest/services/theme/MapServer","EPSG:3857","modelmap:futianmac");
map.addWFSLayer(layer0);
                                

addWMSLayer(layer)

添加WMS图层

Parameters:
Name Type Description
layer szgeoinfo.layer.WMSLayer

添加WMS图层

Example
var wmc=new szgeoinfo.layer.WMSLayer(1,"USA_Population_Density","海岸线","https://localhost/arcgis/rest/services/Demographics/USA_Population_Density/MapServer");
map.addWMSLayer(wmc);
                                

addWMTSLayer(layer,levels)

添加WMTS图层(图层切片方案最好与底图一致,尽量参考GoogleMap或者天地图的切片方案)

Parameters:
Name Type Description
layer szgeoinfo.layer.WMTSLayer

添加WMTS图层

levels number

切片层级数,默认20级,可根据实际情况增减

Example
var url = 'http://localhost/arcgis/rest/services/test/MapServer';//显示该服务的所有图层,试用地址 'https://services.arcgisonline.com/arcgis/rest/services/Demographics/USA_Population_Density/MapServer'
 var wmts = new szgeoinfo.layer.WMTSLayer(123,'图层',url,'EPSG:3857');
 map.addWMTSLayer(wmts);
                                

addZoomControl()

添加Zoom控件,全图、定位

Example
map.addZoomControl();
                                

addZoomInAndOutControl()

添加Zoom控件,放大、缩小

Example
map.addZoomInAndOutControl();
                                

changeLayer(layertype)

改变图层类型

Parameters:
Name Type Description
layertype szgeoinfo.LayerType

显示的图层类型,TDTVector天地图矢量、TDTImage天地图卫星、TDTTerrain天地图地形、GoogleVector谷歌矢量、GoogleImage谷歌卫星、GoogleTerrain谷歌地形图

Example
map.changeLayer(szgeoinfo.LayerType.TDTImage);

changeMapCenter(point)

改变地图中心点

Parameters:
Name Type Description
point szgeoinfo.Point

显示的地图中心点

Example
map.changeMapCenter(new szgeoinfo.Point(114.041296177544,22.52));

changeMapType(maptype, div)

改变地图类型

Parameters:
Name Type Description
maptype szgeoinfo.MapType

地图类型,MAP2D二维,MAP23D二三维,MAP3D三维

div element

修改地图类型的div

Example
map.changeMapType(szgeoinfo.MapType.MAP2D},"map");//div的对象

changeZoom(zoom)

改变地图级别

Parameters:
Name Type Description
zoom int

显示的地图级别

Example
map.changeZoom(12);

changeZoomAndCenter(point, zoom)

改变地图中心点和级别

Parameters:
Name Type Description
point szgeoinfo.Point

显示的地图中心点

zoom int

显示的地图级别

Example
map.changeZoomAndCenter(new szgeoinfo.Point(114.041296177544,22.52),12);

clearClippingPlane()

清除所有三维裁切面

Example
map.clearClippingPlane();

clearEntities()

在三维模式下,清空所有手动绘制的多边形

Example
map.clearEntities();
                                

clearMarker()

清除所有的marker

Example
map.clearMarker();
                                

clearModelColor()

清除三维模型颜色和透明度

Example
map.clearModelColor();
                                

clearOverlays()

清除所有的Overlay

Example
map.clearOverlays();
                                

closeInfoWindow()

关闭信息窗口

Example
map.closeInfoWindow();
                                

destory()

销毁map对象

Example
map.destory();
                                

downloadImage(downImage,callback,imgName) → {dataurl}

将当前的场景保存图片

Parameters:
Name Type Description
downImage boolean

是否下载图片,默认是false

callback function

回调函数

imgName string

图片的名称,图片类型默认是png

Returns:
  • 图片dataurl
Example
map.downloadImage(false,function(img){
            $(selector).attr("src",img)
        });

drawEntity(typeSelect,callback) → {object}

在三维模式下,绘制多边形折线

Parameters:
Name Type Description
drawType szgeoinfo.DrawType

Polygon表示多边形,Polyline表示折线

callback function

回调函数

Returns:
  • 返回绘制的实体对象和坐标点
Example
 var polygon = null;
 map.drawEntity(szgeoinfo.DrawType.Polygon,function(points,entity){
          polygon=entity;
          var points=points;
 });

 //map.removeEntity(polygon);//清除绘制的实体对象

drawPolygonEntity(id,points,color)

根据环形坐标点绘制多边形实体

Parameters:
Name Type Description
id number

对应的ID编号,也可设置成undefined

points array

环形坐标点数组

color string

Cesium标准色或者css颜色字符串,标准色如Cesium.Color.RED,CSS颜色格式如#rgb, #rrggbb, rgb(), rgba(), hsl(), 或者hsla()

Example
var points = [114.031022,22.546025,114.031132,22.546465,114.033033,22.546759];
  map.drawPolygonEntity("undefined",points,"red")

drawTool(drawType, style, callback,clear,download) → {feature}

二维手动绘制点线面

Parameters:
Name Type Description
drawType szgeoinfo.DrawType

Polygon表示多边形,Point表示点,Polyline表示折线

style szgeoinfo.style.Style

多边形的Style

callback function

回调函数

clear boolean

是否清空上一次绘制的图形,默认true

download boolean

是否添加右键导出坐标功能,默认false

Returns:
  • 返回绘制的feature
Example
var fill=new szgeoinfo.style.Fill("rgba(253,206,4,1)");//填充颜色
var stroke=new szgeoinfo.style.Stroke("rgba(253,206,4,1)",1);//边框颜色宽度
var text=new szgeoinfo.style.Text('bold 24px 宋体',0,0,'',new szgeoinfo.style.Fill("rgba(255,255,255,1)"),'',setFeatureText);//显示绘制后的坐标
var image=new szgeoinfo.style.Image("images/bluepoint.png",[500,500],1);
var style=new szgeoinfo.style.Style(fill,stroke,image,text);
map.drawTool(szgeoinfo.DrawType.Point,style,callback);//添加绘制交互
function callback(feature){
      var drawFeature=feature;
}
function setFeatureText(){
    var coordinates=map.showCoordinates();
    return coordinates.toString();
}
     map.removeDrawTool();//移除绘制的交互

flyTo(point,hpr)

飞行到指定的位置,仅在三维模式下

Parameters:
Name Type Description
hpr szgeoinfo.Point

飞行到目的中心点

point szgeoinfo.HeadingPitchRoll

视角旋转

Example
var point=new szgeoinfo.Point(114.041296177544,22.52,1000);
var hpr=new szgeoinfo.HeadingPitchRoll(-5, -10, 0);
map.flyTo(point,hpr);

feaHighlight(layerurl,id,fieldName,fieldValue,centerFlag,clearFlag)

图层属性查询高亮显示,点图层选中后添加标注,面图层选中后黄色多边形显示

Parameters:
Name Type Description
layerurl string

图层Url

int int

图层组中图层id

fieldName string

字段名称

fieldValue string

字段值

centerFlag boolean

feature是否居中显示,默认true

clearFlag boolean

是否清除所有的featrue,默认是true

Example
map.feaHighlight(url,0,"FID","FID.value",false,false);
                                

fullScreen()

全屏显示

Example
map.fullScreen();
                                

exitFullScreen()

退出全屏

Example
map.exitFullScreen();
                                

get2DMap() → {map}

获取二维地图对象

Returns:

二维地图对象

Example
var map2d=map.get2DMap();

get3DScene() → {map}

获取三维地图对象

Returns:

三维地图对象

Example
varsetLayerAlp map3d=map.get3DScene();

getCenter() → {szgeoinfo.Point}

获取地图的中心点

Returns:

中心点坐标

Example
map.getCenter();
                                

getDataSourceArray()

获取被载入Json数据的DataSources列表

Example
map.addJsonData(geojsonUrl,url);//加载json数据
var szDataSource=map.getDataSourceArray();//获取DataSources列表
map.setLayer(707,szDataSource);//添加到图层列表,进行隐藏显示样式的调整

getExtend(features) → {szgeoinfo.Extend}

根据features的数据返回区域

Parameters:
Name Type Description
features array

features数组

Returns:

返回指定区域

Example
var features = new ol.format.EsriJSON().readFeatures(dates);
var extend = map.getExtend(features);
map.setExtend(extend);

getFeatureId(feature)→ {string | int}

获取feature的Id

Parameters:
Name Type Description
feature feature

feature对象

Returns:

feature对象的Id

Example
map.getFeatureId(feature);
                                

getLayers()→ {array}

获取图层列表

Returns:

图层数组

Example
map.getLayers()[44201];
                                

getLayerAlp(layer)→ {number}

获取图层的透明度

Parameters:
Name Type Description
layer szgeoinfo.layer

图层对象

Returns:

图层的透明度,取值[0~1]

Example
var url = 'http://suplicmap.szpl.gov:9080/dzdt2kdata1/rest/services/MapServer/SZMAP_CIMAP_WGS84_201806/MapServer';
 var wmts = new szgeoinfo.layer.WMTSLayer(123,'图层',url);
 map.addWMTSLayer(wmts);
 map.getLayerAlp(map.getLayers()[123]);
                                

getLayerIndex(layer)→ {number}

获取图层的堆叠值

Parameters:
Name Type Description
layer szgeoinfo.layer

图层对象

Returns:

图层的堆叠值

var url = 'http://suplicmap.szpl.gov:9080/dzdt2kdata1/rest/services/MapServer/SZMAP_CIMAP_WGS84_201806/MapServer';
 var wmts = new szgeoinfo.layer.WMTSLayer(456,'图层',url);
 map.addWMTSLayer(wmts);
 map.getLayerIndex(map.getLayers()[456]);

getMapExtent(callback) → {object}

获取屏幕左上角和右下角的经纬度坐标

Parameters:
Name Type Description
callback function

回调函数

Returns:
  • {szgeoinfo.Point} 屏幕左上角的坐标

  • {szgeoinfo.Point} 屏幕右下角的坐标

Example
map.getMapExtent(function (luPoint,rdPoint) {
        console.log("左上角:"+luPoint);
        console.log("右下角:"+rdPoint);
});

getPrimitiveId(primitive)→{string}

获取primitive对象的Id

Parameters:
Name Type Description
primitive szgeoinfo.Polyline3d

primitive的对象

Returns:

primitive对象的Id

Example
var neArr1=[114.06145720500,22.523970131470,8,114.062202858793,22.5235241619530,20,114.062283325385,22.5232714446730,24];
var pyl=new szgeoinfo.Polyline3d("5237",neArr1,5,1,0.182,0.9,0.8); //添加3DPolyline
var polyline = map.add3dPolyline(pyl);
map.getPrimitiveId(polyline);
                                

getResolution() → {number}

获取地图比例尺

Returns:

地图当前的比例尺

Example
map.getResolution();
                                

getVisualAngle(callback) → {szgeoinfo.Point,json}

三维获取相机的当前视野范围,包括相机最终坐标和视角旋转坐标

Parameters:
Name Type Description
callback function

回调函数

Returns:

相机在WGS84世界坐标系中的最终位置和json格式的视角参数

Example
map.getVisualAngle(function(point,hpr){
             var center=point;//获取相机最终位置
             var view=hpr;//获取视角旋转坐标
			//根据相机最终位置和视角旋转坐标渲染地图
            //var headingPitchRoll=new szgeoinfo.HeadingPitchRoll(view["heading"],view["pitch"],view["roll"]);
            //map.set3DView(center,headingPitchRoll);
        });

getZoom() → {int}

获取地图当前层级

Returns:

地图当前的层级

Example
map.getZoom();
                                

goHome()

回到起始点

Example
map.goHome();
                                

hideAllControl()

隐藏所有控件

Example
map.hideAllControl();
                                

removeBaseMapControl()

移除底图控件

Example
map.removeBaseMapControl();
                                

removeDataLayerControl()

移除数据目录控件

Example
map.removeDataLayerControl();
                                

removeLayerControl()

移除基础底图控件

Example
map.removeLayerControl();
                                

hideListModulePanel()

隐藏已加载图层列表面板

Example
map.hideListModulePanel();
                                

removeLogoControl()

移除Logo控件

Example
map.removeLogoControl();
                                

removeInstructionsControl()

移除使用说明控件

Example
map.removeInstructionsControl();
                                

removeMapMode()

移除地图视图切换面板(移动端)

Example
map.removeMapMode();
                                

removeMapChat()

移除工具栏(移动端)

Example
map.removeMapChat();
                                

removePOIControl()

移除POI查询控件

Example
map.removePOIControl();
                                

removeSelectFeaControl()

移除属性查询控件

Example
map.removeSelectFeaControl();
                                

removeSZGeoLayerControl()

移除数据仓库控件

Example
map.removeSZGeoLayerControl();
                                

removeToolControl()

移除工具控件

Example
map.removeToolControl();
                                

removeZoomControl()

移除全图、定位控件

Example
map.removeZoomControl();
                                

removeZoomInAndOutControl()

移除放大、缩小控件

Example
map.removeZoomInAndOutControl();
                                

highlightModelByPoint(position,color,timeout)

根据坐标选中该位置的模型并进行高亮和居中显示

Parameters:
Name Type Description
position szgeoinfo.Point

坐标点

color string

标准色(可设置透明度)或者css颜色字符串,标准如Cesium.Color.RED、ff00ff、#EE82EE

timeout int

最长查找时间,默认4000毫秒

Example
map.highlightModelByPoint(position,color,timeout);
                                

initModelPick()

添加默认的模型悬浮和点击函数

Example
var point=new szgeoinfo.Point(114.041296177544,22.52,1000);
map.add3DModel(point,"model2.gltf");
map.initModelPick();

inverseAddressResolution(point, callback) → {string}

逆地址解析

Parameters:
Name Type Description
point szgeoinfo.Point

当前点坐标

callback function

回调函数

Returns:

逆地址

Example
map.inverseAddressResolution(new szgeoinfo.Point(114.03142705802577,22.54651350355484),function(address){
        console.log(address);
    })
                                

loadModel(modelType,id)

根据模型类别加载模型

Parameters:
Name Type Description
modelType szgeoinfo.ModelType

模型类型,WhiteModel表示白模、SimplifiedModel表示简模、FineModel表示精模

id number

Id标识

Example
map.loadModel(szgeoinfo.ModelType.FineModel,43089001);//加载精模

mapSlipping(callback) → {object}

地图滑动监听

Parameters:
Name Type Description
callback function

回调函数

Returns:
  • {szgeoinfo.Point} 滑动之前的中心坐标

  • {szgeoinfo.Point} 滑动之后的中心坐标

Example
map.mapSlipping(function(moveStartCenterPoint,moveEndCenterPoint) {
         console.log("开始滑动:["+moveStartCenterPoint["lon"]+","+moveStartCenterPoint["lat"]+"]");
         console.log("结束滑动:["+moveEndCenterPoint["lon"]+","+moveEndCenterPoint["lat"]+"]");
});

mesureTool(mesuretype)

二维地图测量

Parameters:
Name Type Description
mesuretype szgeoinfo.MesureTool

测量类型,DISTANCE测量距离、AREA测量面积

Example
map.mesureTool(szgeoinfo.MesureTool.DISTANCE);//测量距离

pickPosition(callback) → {szgeoinfo.Point}

三维拾取坐标

Parameters:
Name Type Description
callback function

回调函数

Returns:

坐标点

Example
map.pickPosition(function(point){
        var html='<div class="infoBox-description"><table class="infoBox-defaultTable"><tbody>'+"<tr><th>经度</th><td>"+point.lon+
           "</td></tr><tr><th>纬度</th><td>"+point.lat+"</td></tr><tr><th>高度</th><td>"+point.height+"</td></tr></tbody></table></div>";
            $("#content").html(html);
        map.clearMarker();//清除之前添加的点
        map.addPoint(point,"","images/Page2.png");
});

QueryByPoint(zbx,zby,async,callback) → {object}

根据经纬度获取建筑物几何信息和文字属性

Parameters:
Name Type Description
zbx szgeoinfo.point

经度

zby szgeoinfo.point

纬度

async Boolean

异步,默认为异步(true)

callback function

回调函数,返回所查找到的建筑物信息跟属性

Returns:

建筑物信息跟属性

Example
map.QueryByPoint(point.lon, point.lat,false,function(data){
    var properties=data.properties;
    var geoStr = data.geometry;
}

regeditChangeResolution(callback) → {object}

地图比例尺变动事件

Parameters:
Name Type Description
callback function

回调函数

Returns:
  • {double} 变动前比例尺

  • {double} 变动后比例尺

Example
map.regeditChangeResolution(function (data) {
        console.log(data);
 });
                                

remove3dPolygon(primitive)

删除单个3dPolygon或3dPolyline

Parameters:
Name Type Description
primitive szgeoinfo.Polyline3d

多边形的对象

Example
var neArr1 = [114.06145720500,22.523970131470,8,114.062202858793,22.5235241619530,20,114.062283325385,22.5232714446730,24];
    //折线数组,经度纬度高度
    var pyl=new szgeoinfo.Polyline3d("5237",neArr1,5,1,0.182,0.9,0.8); //添加3DPolyline
    var polyline = map.add3dPolyline(pyl);
    map.remove3dPolygon(polyline);
                                

removeAll3DTileset()

移除所有的3DTileset

Example
map.removeAll3DTileset();
                                

remove3dPolygonAll()

清空所有的3dPolygon或3dPolyline

Example
map.remove3dPolygonAll();
                                

removeClickEvent()

移除地图点击事件

Example
map.removeClickEvent();

removeControl(Control)

删除控件

Parameters:
Name Type Description
Control szgeoinfo.Control

控件

Example
map.removeControl(control);
                                

removeDrawTool()

从地图中删除绘制的交互

Example
map.removeDrawTool();
                                

removeEntity(entity)

在三维模式下,清除单个手动绘制的实体对象

Parameters:
Name Type Description
entity entity

实体对象

Example
map.removeEntity(entity);

removeLabel3D(label3d)

根据label3d对象删除数据

Parameters:
Name Type Description
label3d szgeoinfo.Label3D

Label3D对象

Example
map.removeLabel3D(label3d);

removeLabel3DAll()

删除所有的Label3D对象

Example
map.removeLabel3DAll();

removeLabel3DById(labelid)

根据label3d对象ID删除数据

Parameters:
Name Type Description
labelid string

Label3D对象中的ID

Example
map.removeLabel3DById(labelid);

removeLayer(id)

移除图层,移除tileset数据

Parameters:
Name Type Description
id string

图层id

Example
map.removeLayer(layer.id);

removeMarker(marker)

删除marker或feature

Parameters:
Name Type Description
marker szgeoinfo.Marker

删除单个marker对象

Example
map.removeMarker(marker);
                                

removeOverlay(overlay)

删除覆盖物

Parameters:
Name Type Description
overlay szgeoinfo.Overlay

删除单个Overlay

Example
map.removeOverlay(marker);
                                

removePrimitiveClickEvent()

移除primitive的点击事件

Example
map.removePrimitiveClickEvent();
                                

renderFeatures(features)

渲染feature,根据feature的geometry的类型进行渲染,点的渲染,线的渲染,面的渲染。并将feature结果集展示在地图视野范围内。

Parameters:
Name Type Description
features array

feature集合

Example
var layer = new szgeoinfo.layer.ArcGISLayer(1212,"产业用房","http://suplicmap.szpl.gov:9080/publicdata101/rest/services/peomap/cyyf_2k/MapServer", "EPSG:3857");
    map.addArcGISRest(layer);
    var querys = [];
    if(querys != null || querys.length > 0){
        querys = [];
    }
    var query1 = new szgeoinfo.layer.QueryParam("PROJ_NAME",szgeoinfo.Operator.LIKE,"深圳");
    querys.push(query1);
    layer.multipleQuery(0,querys,szgeoinfo.Connector.AND,function (features) {
        map.renderFeatures(features);
    });
                                

removeVector()

移除矢量图层的所有feature

Example
map.removeVector();
                                

set3DView(point,hpr)

初始化三维视野范围

Parameters:
Name Type Description
point szgeoinfo.Point

初始化的点坐标

hpr szgeoinfo.HeadingPitchRoll

视角范围,默认(-10, -90, 0)

Example
 var point=new szgeoinfo.Point(118.55323112487789,24.803266090340306,500);
 var headingPitchRoll=new szgeoinfo.HeadingPitchRoll(-10, -90, 0);
 map.set3DView(point,headingPitchRoll);

searchModelByID(mid, modelType,callback,id)

根据ID显示模型

Parameters:
Name Type Description
mid number

模型的Id

modelType szgeoinfo.ModelType

模型类型,WhiteModel表示白模、SimplifiedModel表示简模、FineModel表示精模

callback function

回调函数,返回中心点坐标

id number

Id标识

Example
map.searchModelByID("4403040070060900001",szgeoinfo.ModelType.SimplifiedModel,function (result) {
        var point = new szgeoinfo.Point(result.lon,result.lat,800);
        var hprDefault=new szgeoinfo.HeadingPitchRoll(-10,-90,0);
        map.set3DView(point,hprDefault);
    },2001);

searchModelByJD(jiedao, modelType,callback,id)

根据街道显示模型

Parameters:
Name Type Description
jiedao string

街道拼音的拼写

modelType szgeoinfo.ModelType

模型类型,WhiteModel表示白模、SimplifiedModel表示简模、FineModel表示精模

callback function

回调函数,返回中心点坐标

id number

Id标识

Example
map.searchModelByJD($spanVal,szgeoinfo.ModelType.FineModel,function (result) {
       var hprDefault=new szgeoinfo.HeadingPitchRoll(-20, -25, 0);
       map.flyTo(new szgeoinfo.Point(result.lon,result.lat,500),hprDefault);
 },2002);

searchModelByPolygon(pointList, modelType,id)

根据多边形显示模型

Parameters:
Name Type Description
pointList array | {szgeoinfo.Point}

多边形坐标数组

modelType szgeoinfo.ModelType

模型类型,WhiteModel表示白模、SimplifiedModel表示简模、FineModel表示精模

id number

Id标识

Example
 var ps=[];
 ps.push(new szgeoinfo.Point(114.0896358 ,22.54673895));
 ps.push(new szgeoinfo.Point(114.0920923 ,22.54766566));
 ps.push(new szgeoinfo.Point(114.089097, 22.54756566));
 map.searchModelByPolygon(ps,szgeoinfo.ModelType.SimplifiedModel,2003);

searchModelByName(name,callback)

根据模型名称模糊搜索

Parameters:
Name Type Description
name string

模型名称

callback function

回调函数,返回数组对象(模型Id,模型名称)

Example
map.searchModelByName('交易大厦',function(result){
        var item0 = result[0].MODELID;
        map.searchModelByID(String(item0),szgeoinfo.ModelType.FineModel,function (result) {
            if("error"==result){
                console.log("未查询到相关资源");
            }else{
                var point = new szgeoinfo.Point(result.lon,result.lat,500);
                var hprDefault = new szgeoinfo.HeadingPitchRoll(-10,-90,0);
                map.set3DView(point,hprDefault);
            }
        });
    });

setExtend(extend)

设置显示区域

Parameters:
Name Type Description
extend szgeoinfo.Extend

控件

Example
var extend = new szgeoinfo.Extend(114.089097, 22.54756566,114.099097, 22.55756566);
map.setExtend(extend);
                                

setFeatureId(feature, id)

设置feature的Id

Parameters:
Name Type Description
feature feature

feature对象

id string | int

feature的id

Example
var one = new szgeoinfo.Point(114.031132,22.546465,50);
 var point = map.addPoint(one,"土地房产交易大厦","images/marker.png");
 map.setFeatureId(point,"123");
                                

setFeatureClick(callback) → {object}

feature的点击事件,仅支持二维模式

Parameters:
Name Type Description
callback function

回调函数

Returns:
  • {szgeoinfo.Point} 真实坐标

  • {szgeoinfo.Point} 像素坐标

  • {feature} 获取点击后的Feature

Example
var layer = new szgeoinfo.layer.ArcGISLayer(1212,"产业用房","http://suplicmap.szpl.gov:9080/publicdata101/rest/services/peomap/cyyf_2k/MapServer", "EPSG:3857");
    map.addArcGISRest(layer);
    var querys = [];
    if(querys != null || querys.length > 0){
        querys = [];
    }
    var query1 = new szgeoinfo.layer.QueryParam("PROJ_NAME",szgeoinfo.Operator.LIKE,"深圳");
    querys.push(query1);
    layer.multipleQuery(0,querys,szgeoinfo.Connector.AND,function (features) {
        map.renderFeatures(features);
    });
    layer.multipleQuery(0,querys,szgeoinfo.Connector.AND,function (features) {
        map.renderFeatures(features);
        map.setFeatureClick(function (point, pixel, selfeature) {
            var self = this;
            var id = selfeature.getId();
            var queryArr = [];
            var queryF = new szgeoinfo.layer.QueryParam("FID",szgeoinfo.Operator.EQUAL,id);
            queryArr.push(queryF);
            layer.query(0,queryArr,function (features) {
                console.log(features[0]);
            });
        })
    });

setGeoJsonStyle(id,elevationOption,colorOption)

设置GeoJson数据的样式

Parameters:
Name Type Description
id int

GeoJson数据的Id

elevationOption string|int

拉伸值属性或者自定义高度,默认拉伸高度为40

colorOption string

渲染方式,默认颜色为白色

Example
 map.setGeoJsonStyle(123,"BLDG_AREA","BLDCOND");//按照面积属性的值进行拉伸
 map.setGeoJsonStyle(123,112,"BLDCOND");//自定义高度拉伸

setLayer(id,dataSource)

设置图层列表的索引和内容

Parameters:
Name Type Description
id int | string

索引值

layer layer | dataSource

数据源

Example
map.setLayer(707,szDataSource);
                                

setLayerAlp(layer,alp)

设置图层的透明度

Parameters:
Name Type Description
layer szgeoinfo.layer

图层对象

alp number

透明度,取值[0,1],默认1

Example
var layer=map.getLayers()[id];//根据Id从图层数组获取图层
var range=0.5;
map.setLayerAlp(layer,range);

setLayerIndex(layer,zIndex)

设置图层的堆叠顺序

Parameters:
Name Type Description
layer szgeoinfo.layer

图层对象

zIndex number

堆叠值

Example
var layer=map.getLayers()[id];//根据Id从图层数组获取图层
var zIndex=1000;
map.setLayerIndex(layer,zIndex);//设置图层的堆叠值
var zIndex=map.getLayerIndex(layer);//获取图层的堆叠值

setModelArea(modelArea)

设置显示模型区域

Parameters:
Name Type Description
modelArea szgeoinfo.ModelArea

显示的模型区域,SHENZHEN表示深圳、FUTIAN表示福田区、LUOHU表示罗湖区、NANSHAN表示南山区、YANTIAN表示盐田区、BAOAN表示宝安区、LONGGANG表示龙岗区、YANTIAN表示盐田区、PINGSHAN表坪山区、LONGHUA表示龙华区、GUANGMING表示光明区

Example
map.setModelArea(szgeoinfo.ModelArea.SHENZHEN);

setModelColor(model, color)

设置三维模型颜色

Parameters:
Name Type Description
model model

三维模型

color string

模型颜色字符串 如 #ff00ff

Example
map.setModelColor(model,"#FF00FF");
                                

setModelVisible(model, show)

设置3d模型显示隐藏

Parameters:
Name Type Description
model model

3d模型

show boolean

显示与隐藏

Example
map.setModelVisible(model,false);

setPrimitiveStyle(polyline3d,red,green,blue,opacity)

设置primitive的样式,如多边形、折线

Parameters:
Name Type Description
polyline3d szgeoinfo.Polyline3d

polyline3d对象

red number

红色组件,取值[0~1],默认0

green number

绿色组件,取值[0~1],默认1

blue number

蓝色组件,取值[0~1],默认1

opacity number

透明度,取值[0~1],默认0.8

Example
var neArr1=[114.06145720500,22.523970131470,8,114.062202858793,22.5235241619530,20,114.062283325385,22.5232714446730,24];
   //折线数组,经度纬度高度
   var pyl=new szgeoinfo.Polyline3d("5237",neArr1,5,1,0.182,0.9,0.8); //添加3DPolyline
   map.add3dPolyline(pyl);
   setTimeout(function () {
   map.setPrimitiveStyle(pyl,0.5,0.2,0.1,0.6);
},2000)

setRotateDisabled()

二维地图设置不可旋转

Example
map.setRotateDisabled();
                                

setView(point, zoom, minZoom, maxZoom)

二维地图设置view

Parameters:
Name Type Description
point szgeoinfo.Point

中心点坐标

zoom int

显示的地图级别

minZoom int

显示的地图最小级别

maxZoom int

显示的地图最大级别

Example
var point=new szgeoinfo.Point(114.0920923 ,22.56766566);
map.setView(point,12,10,15);
								

setZoom(zoom)

改变地图级别

Parameters:
Name Type Description
zoom int

设置地图级别

Example
map.setZoom(12);

showAllControl()

显示隐藏的控件

Example
map.showAllControl();
                                

showCoordinates() → {array}

返回手动绘制多边形坐标数组,点的坐标数据

Returns:

返回绘制的坐标数组

Example
var fill=new szgeoinfo.style.Fill("rgba(253,206,4,1)");//填充颜色
    var stroke=new szgeoinfo.style.Stroke("rgba(253,206,4,1)",2);//边框颜色宽度
    var text=new szgeoinfo.style.Text('bold 24px 宋体',0,0,'',new szgeoinfo.style.Fill("rgba(255,255,255,1)"),'',setFeatureText);//显示绘制后的坐标
    var image=new szgeoinfo.style.Image("images/bluepoint.png",[500,500],1);
    var style=new szgeoinfo.style.Style(fill,stroke,image,text);
    map.drawTool(szgeoinfo.DrawType.Polygon,style,callback);//添加绘制交互
    function callback(feature){
        console.log(feature);
    }
    function setFeatureText(){
        var coordinates=map.showCoordinates();
        return coordinates.toString();
    }
                                

showInfoWin(ind)

显示信息窗口

Parameters:
Name Type Description
ind int

列表中显示第几个信息窗口,仅在添加POI控件才可使用

Example
map.addPOIControl();
map.showInfoWin(3);

showLayer(id, show)

隐藏显示图层

Parameters:
Name Type Description
id string

图层id

show boolean

隐藏显示

Example
var url = 'http://suplicmap.szpl.gov:9080/dzdt2kdata1/rest/services/MapServer/SZMAP_CIMAP_WGS84_201806/MapServer';
   var wmts = new szgeoinfo.layer.WMTSLayer(123,'图层',url);
   map.addWMTSLayer(wmts);
   map.showLayer(123,false);

showLayerInfo(id)

根据Id添加图层

Parameters:
Name Type Description
id string

图层id

Example
map.showLayerInfo(id);

showLocation(imgUrl)

根据当前定位添加图标

Parameters:
Name Type Description
imgUrl string

图片url

Example
map.showLocation(imgUrl);
                                

showMapChat()

手机端,显示工具栏

Example
map.showMapChat();
                                

showModelByID(modelID,color,timeout)

根据建筑物编码定位到模型位置并高亮显示

Parameters:
Name Type Description
modelID string

建筑物模型编码

color string

标准色(可设置透明度)或者css颜色字符串,标准如Cesium.Color.RED、ff00ff、#EE82EE

timeout int

查找间隔时间,默认3000毫秒

Example
map.showModelByID("4403060110100600007","#00f800");
                                

showMapMode()

显示地图视图切换面板(移动端)

Example
map.showMapMode();
                                

showModelName(mid,callback) → {string}

根据模型的Id查询名称

Parameters:
Name Type Description
mid number

模型Id

callback function

回调函数

Returns:

模型名称

Example
map.showModelName(mid,callback);
                                

showOrHideModelTile()

显示隐藏3d建筑物模型

Example
map.showOrHideModelTile();
                                

showOrHideTerrain()

显示隐藏地形切片

Example
map.showOrHideTerrain();
                                

showPolygonByPoint(zbx,zby,color)

通过坐标获取建筑普查数据的基底并渲染出三维轮廓范围

Parameters:
Name Type Description
zbx string

wgs84坐标经度

zby string

wgs84坐标纬度

color string

标准色(可设置透明度)或者css颜色字符串,标准如Cesium.Color.RED、ff00ff、#EE82EE

Example
map.showPolygonByPoint(lon,lat,color);
                                

startRotate(options)

绕点飞行

Parameters:
Name Type Description
options object

Properties
Name Type Description
lon String

经度

lat String

纬度

height String

坐标高度

time String

旋转一周时间

distance String

相机距离

Example
var ps = [];
    ps.lon = 114.0907591;
    ps.lat = 22.54550907;
    ps.height = 22.54550907;
    ps.time = 15;
    ps.distance = 600;
    map.startRotate(ps);
                                

stopRotate()

停止飞行

Example
map.stopRotate();
                                

updateBillboard(id,left,right,maxHeight,minHeight)

根据Id修改广告牌

Parameters:
Name Type Description
id int

广告牌的Id

left szgeoinfo.Point

左侧点的坐标

right szgeoinfo.Point

右侧点的坐标

maxHeight number

广告牌的高度

minHeight number

广告牌的离地高度

Example
//修改广告牌的参数
map.updateBillboard(id,left,right,maxHeight,minHeight);
//删除单个广告牌
var entity=map.scene.entities.getById(id);
map.scene.entities.remove(entity);
//删除全部的广告牌
map.scene.entities.removeAll();
                                

updateEntitiesPosition(entityCollection)

更新entityCollection的position属性,若有3DTiles模型可实现动态更新

Parameters:
Name Type Description
entityCollection EntityCollection

实体的集合

Example
map.updateEntitiesPosition(entityCollection);
                                

updatePositionBySampleTerrain(entityCollection)

获取地表高程,更新entityCollection的position属性

Parameters:
Name Type Description
entityCollection EntityCollection

实体的集合

Example
map.updatePositionBySampleTerrain(entityCollection);
                                

updatePositionByPickPosition(entityCollection)

获取场景高程,更新entityCollection的position属性

Parameters:
Name Type Description
entityCollection EntityCollection

实体的集合

Example
map.updatePositionByPickPosition(entityCollection);
                                

zoomIn()

放大地图一级

Example
map.zoomIn();
                                

zoomInTool()

拉框放大

Example
map.zoomInTool();
                                

zoomOut()

缩小地图一级

Example
map.zoomOut();
                                

zoomOutTool()

拉框缩小

Example
map.zoomOutTool();
                                

zoomToCenter(lon, lat)

缩放至中心点

Parameters:
Name Type Description
lon number

经度

lat number

纬度

Example
map.zoomToCenter(lon, lat);