查阅Cesium API

这个方法用于创建一个Geojson要素图层。

Author:
  • 金磊、张丹钊、张恒、薛鹏

属性

设置geojson图层的显示文本

方法

生成管状数据

computeCircle(radians)

参数描述:
名称 类型 描述
radians Float
创建circleGeofeaturelayer

createBillboardGeoJsonFeature(name, geojsonOrurl, option, disFnc)Promise.<Object>

参数描述:
名称 类型 描述
name String 可选 图层名称。
geojsonOrurl object | String 可选 geojosn对象或者地址
option object 可选 参数对象{ image: "",// Property optional A Property specifying the Image, URI, or Canvas to use for the billboard. show: true,// optional A boolean Property specifying the visibility of the billboard. scale: 1.0,//optional A numeric Property specifying the scale to apply to the image size. horizontalOrigin: this._cesium.HorizontalOrigin.CENTER,// optional A Property specifying the HorizontalOrigin. verticalOrigin: this._cesium.VerticalOrigin.CENTER,// optional A Property specifying the VerticalOrigin. eyeOffset: this._cesium.Cartesian3.ZERO,// optional A Cartesian3 Property specifying the eye offset. pixelOffset: this._cesium.Cartesian2.ZERO,// optional A Cartesian2 Property specifying the pixel offset. rotation: 0,// optional A numeric Property specifying the rotation about the alignedAxis. alignedAxis: this._cesium.Cartesian3.ZERO,// optional A Cartesian3 Property specifying the unit vector axis of rotation. width: undefined,// optional A numeric Property specifying the width of the billboard in pixels, overriding the native size. height: undefined,// optional A numeric Property specifying the height of the billboard in pixels, overriding the native size. color: this._cesium.Color.WHITE,// optional A Property specifying the tint Color of the image. heightReference: this._cesium.HeightReference.NONE,// optional A Property specifying what the height is relative to. }
disFnc function 可选 回调函数
返回:
返回一个Cesium的datasource对象。
创建circleGeofeaturelayer

createCirclePointGeoJsonFeatureLayer(name, geojsonOrurl, option, disFnc)Promise.<Object>

参数描述:
名称 类型 描述
name String 可选 图层名称。
geojsonOrurl object | String 可选 geojosn对象或者地址
option object 可选 参数对象{ radius:1, height: 0, heightReference: this._cesium.HeightReference.NONE, extrudedHeight: 0, extrudedHeightReference: this._cesium.HeightReference.NONE, show: true, fill: true, material: this._cesium.Color.WHITE, outline: false, outlineColor: this._cesium.Color.BLACK, outlineWidth: 1, near: 0, far: 5000 }
disFnc function 可选 回调函数
返回:
返回一个Cesium的datasource对象。
创建circleGeofeaturelayer街景

createEllipsoidlayerPointGeoJsonFeatureLayer(name, geojsonOrurl, option, disFnc)Promise.<Object>

参数描述:
名称 类型 描述
name String 可选 图层名称。
geojsonOrurl object | String 可选 geojosn对象或者地址
option object 可选 参数对象{ Name: "", text: "", font_size: '30px', font_family:'sans-serif' stylet: this._cesium.LabelStyle.FILL, fillColor: this._cesium.Color.WHITE,// optional A Property specifying the fill Color. outlineColor: this._cesium.Color.BLACK,// optional A Property specifying the outline Color. outlineWidth: 1.0,// optional A numeric Property specifying the outline width. show: true,// optional A boolean Property specifying the visibility of the label. showBackground: false,// optional A boolean Property specifying the visibility of the background behind the label. backgroundColor: new this._cesiumColor(0.165, 0.165, 0.165, 0.8),//optional A Property specifying the background Color. backgroundPadding: new Cartesian2(7, 5),//optional A Cartesian2 Property specifying the horizontal and vertical background padding in pixels. scale: 1.0,//optional A numeric Property specifying the scale to apply to the text. horizontalOrigin: this._cesiumHorizontalOrigin.CENTER, //optional A Property specifying the HorizontalOrigin. verticalOrigin: this._cesium.VerticalOrigin.CENTER,// optional A Property specifying the VerticalOrigin. eyeOffset: this._cesium.Cartesian3.ZERO,// optional A Cartesian3 Property specifying the eye offset. pixelOffset: this._cesium.Cartesian2.ZERO,// optional A Cartesian2 Property specifying the pixel offset. heightReference: this._cesium.HeightReference.NONE,// optional A Property specifying what the height is relative to. near: 0, far: 5000 }
disFnc function 可选 回调函数
返回:
返回一个Cesium的datasource对象。
创建geofeaturelayer

createGeoJsonDataSource(name, geojsonOrurl, disFnc)Promise.<Object>

参数描述:
名称 类型 描述
name String 可选 图层名称。
geojsonOrurl object | String 可选 geojosn对象或者地址
disFnc function 可选 回调函数
返回:
返回一个Cesium的datasource对象。
创建Geojson数据加载(全部加载)优化

createGeojsonFeatureLayer(name, geojsonOrurl, option, disFnc)Promise.<Object>

参数描述:
名称 类型 描述
name String 可选 图层名称。
geojsonOrurl object | String 可选 geojosn对象或者地址
option object 可选 参数对象{ color: this._cesium.Color.WHITE,// optional A Property specifying the Color of the point. pixelSize: 1,//optional A numeric Property specifying the size in pixels. outlineColor: this._cesium.Color.BLACK,// optional A Property specifying the Color of the outline. outlineWidth: 0,// optional A numeric Property specifying the the outline width in pixels. show: true,// optional A boolean Property specifying the visibility of the point. near: 0, far: 5000 }
disFnc function 可选 回调函数
返回:
返回一个Cesium的datasource对象。
创建geofeaturelayer

createGeoJsonFeatureLayer(name, geojsonOrurl, option, disFnc)Promise.<Object>

参数描述:
名称 类型 描述
name String 可选 图层名称。
geojsonOrurl object | String 可选 geojosn对象或者地址
option object 可选 参数对象{ "layertype": "", //图层类型 "text": "", //显示的文本 "font": "16px", //字体 "fillColor": this._cesium.ALICEBLUE,//字体填充颜色 "outlineColor": this._cesium.BLACK, //边框颜色 "outlineWidth": "1.0", //边框宽度 "scale": "1.0", //缩放 "maxDistanceDisplay": 55555555, //最大可视化距离 "minDistanceDisplay": 5000, //最小可视化距离 "icon": "" //显示的图标 }
disFnc function 可选 回调函数
返回:
返回一个Cesium的datasource对象。
创建geofeaturelayer

createGeoJsonFeatureLayerAlawys(name, geojsonOrurl, option, disFnc)Promise.<Object>

参数描述:
名称 类型 描述
name String 可选 图层名称。
geojsonOrurl object | String 可选 geojosn对象或者地址
option object 可选 参数对象{ "layertype": "", //图层类型 "text": "", //显示的文本 "font": "16px", //字体 "fillColor": this._cesium.ALICEBLUE,//字体填充颜色 "outlineColor": this._cesium.BLACK, //边框颜色 "outlineWidth": "1.0", //边框宽度 "scale": "1.0", //缩放 "maxDistanceDisplay": 55555555, //最大可视化距离 "minDistanceDisplay": 5000, //最小可视化距离 "icon": "" //显示的图标 }
disFnc function 可选 回调函数
返回:
返回一个Cesium的datasource对象。
创建geojson文本点数据

createLabelPointGeoJsonFeatureLayer(name, geojsonOrurl, option, GroupID, checked, disFnc)GeoJsonFeatureLayer

调用方法:
var urls = "http://183.162.245.49:8099/geoserver/POI/ows?service=WFS&version=1.0.0&request=GetFeature&typeName=POI:shenghui84&outputFormat=application%2Fjson";
    var data = {
        font_family: "微软雅黑",
        font_size: 16,
        horizontalOrigin: 0,
        verticalOrigin: -1,
        layertype: "labellayer",
        near: 0,
        far: 8000000,
        pointHeight: 60000,
        showBackground: false,
        text: "[name]",
    };
    var dx = sgworld.Creator.createLabelPointGeoJsonFeatureLayer("", urls, data, "0", true, function (data) {
        sgworld.Navigate.flyToObj(data);
    });
参数描述:
名称 类型 描述
name String 可选 图层名称。
geojsonOrurl object | String 可选 geojosn对象或者地址
option object 可选 参数
名称 类型 描述
id String 可选 id
text String 可选 文本内容
image String 可选 图标地址
color String 可选 图标颜色
fillColor String 可选 填充色
outlineColor String 可选 边框色
backgroundColor String 可选 背景色
font_size Number 可选 文本大小
font_family String 可选 字体
bold Boolean 可选 加粗
italic Boolean 可选 斜体
showBackground Boolean 可选 显示文本背景
outlineWidth Number 可选 文本边框大小
pointHeight Number | String 可选 点高度
heightReference Number 可选 高度类型
disableDepthTestDistance Number 可选 禁用深度检测距离,为Infinity则无视遮挡
near Number 可选 最小可视
far Number 可选 最大可视
labelData Cesium.LabelGraphics.ConstructorOptions 可选 文本扩展参数
imageData Cesium.BillbaordGraphics.ConstructorOptions 可选 图标扩展参数
GroupID String 可选 父节点id
checked Boolean 可选 是否显示
disFnc function 可选 回调函数
返回:
返回一个GeoJsonFeatureLayer对象。
创建geojson模型点数据

createModelGeojsonFeatureLayer(name, geojsonOrurl, option, GroupID, checked, disFnc)GeoJsonFeatureLayer

调用方法:
var urls = "http://183.162.245.49:8099/geoserver/sdkp/ows?service=WFS&version=1.0.0&request=GetFeature&typeName=sdkp:JTSS&outputFormat=application%2Fjson";
    var data = {
        url:"http://183.162.245.49:8099/ModelLibrary/电力设备/tower.glb",
        far: 2000,
        near: 0,
        height: 1,
    };
    var dx = sgworld.Creator.createModelGeojsonFeatureLayer("", urls, data, "0", true, function (data) {
        // sgworld.Navigate.flyToObj(data);
    });
参数描述:
名称 类型 描述
name String 可选 图层名称。
geojsonOrurl object | String 可选 geojosn对象或者地址
option object 可选 参数
名称 类型 描述
id String 可选 id
url String 可选 模型地址
color String 可选 颜色
scale Number 可选 比例
height Number | String 可选 高度
heading Number 可选 方向角
pitch Number 可选 俯仰角
roll Number 可选 翻滚角
near Number 可选 最小可视
far Number 可选 最大可视
GroupID String 可选 父节点id
checked Boolean 可选 是否显示
disFnc function 可选 回调函数
返回:
返回一个GeoJsonFeatureLayer对象。
创建circleGeofeaturelayer

createModelPointGeoJsonFeatureLayer(name, geojsonOrurl, option, disFnc)Promise.<Object>

参数描述:
名称 类型 描述
name String 可选 图层名称。
geojsonOrurl object | String 可选 geojosn对象或者地址
option object 可选 参数对象{ uri: "glb/gltf", show: true,// optional A boolean Property specifying the visibility of the model. scale: 1.0, //optional A numeric Property specifying a uniform linear scale. minimumPixelSize: 0.0,// optional A numeric Property specifying the approximate minimum pixel size of the model regardless of zoom. incrementallyLoadTextures: true,//optional Determine if textures may continue to stream in after the model is loaded. runAnimations: true,// optional A boolean Property specifying if glTF animations specified in the model should be started. clampAnimations: true,// optional A boolean Property specifying if glTF animations should hold the last pose for time durations with no keyframes. shadows: this._cesium.ShadowMode.ENABLED,// optional An enum Property specifying whether the model casts or receives shadows from each light source. heightReference: this._cesium.HeightReference.NONE,// optional A Property specifying what the height is relative to. color: this._cesium.Color.WHITE,// optional A Property specifying the Color that blends with the model's rendered color. }
disFnc function 可选 回调函数
返回:
返回一个Cesium的datasource对象。
创建geojson点数据

createPointGeojsonFeatureLayer(name, geojsonOrurl, option, GroupID, checked, disFnc)GeoJsonFeatureLayer

调用方法:
var urls = "http://183.162.245.49:8099/geoserver/POI/ows?service=WFS&version=1.0.0&request=GetFeature&typeName=POI:shenghui84&outputFormat=application%2Fjson";
    var data = {
        far: 90000,
        color: "#f00",
        outlineColor: "#ff0",
        near: 0,
        outlineWidth: 2,
        pixelSize: 10,
        pointHeight: 50000
    };
    var dx = sgworld.Creator.createPointGeojsonFeatureLayer("", urls, data, "0", true, function (data) {
        sgworld.Navigate.flyToObj(data);
    });
参数描述:
名称 类型 描述
name String 可选 图层名称。
geojsonOrurl object | String 可选 geojosn对象或者地址
option object 可选 参数
名称 类型 描述
id String 可选 id
color String 可选 填充色
outlineColor String 可选 边框色
pixelSize Number 可选 大小
outlineWidth Number 可选 边框大小
pointHeight Number | String 可选 点高度
near Number 可选 最小可视
far Number 可选 最大可视
GroupID String 可选 父节点id
checked Boolean 可选 是否显示
disFnc function 可选 回调函数
返回:
返回一个GeoJsonFeatureLayer对象。
创建PolygonGeoJsonFeatureLayer

createPolygonGeoJsonFeatureLayer(name, geojsonOrurl, option, GroupID, checked, disFnc)GeoJsonFeatureLayer

参数描述:
名称 类型 描述
name String 可选 名称
geojsonOrurl String geojson地址
option Object 参数
名称 类型 默认值 描述
id String 可选 id
material String "#ffffff" 可选 填充色
outlineColor String "#000000" 可选 边框色
fillColor String "#ffffff" 可选 文本填充色
labelOutlineColor String "#000000" 可选 文本边框色
height Number 可选 高度
extrudedHeight Number 可选 拉伸高度
classificationType Cesium.ClassificationType 可选 贴地类型
clampToGround Boolean 可选 是否贴地
outline Boolean 可选 是否显示边框
outlineWidth Number 可选 边框宽度
water Boolean 可选 是否水面
mask Boolean 可选 是否反选遮罩
bulidingWall Boolean 可选 是否建筑边界
bulidingWallWidth Number 可选 建筑边界宽度
text String 可选 注记内容
font String 可选 注记字体
font_size String 可选 注记大小
italic Boolean 可选 斜体
bold Boolean 可选 加粗
pixelOffset Cartesian2 可选 文本偏移
labelNear Number 可选 注记最小可视距离
labelFar Number 可选 注记最大可视距离
disableDepthTestDistance Number 可选 注记禁用深度检测距离
near Number 可选 最小可视距离
far Number 可选 最大可视距离
GroupID String 可选 父节点id
checked Boolean 是否显示
disFnc function 可选 回调函数
返回:
返回一个GeoJsonFeatureLayer对象。
创建PolylineGeoJsonFeatureLayer

createPolygonGeoJsonFeatureLayers(name, geojsonOrurl, option, disFnc)Promise.<Object>

参数描述:
名称 类型 描述
name String 可选 图层名称。
geojsonOrurl object | String 可选 geojosn对象或者地址
option object 可选 参数对象{ height: 0,// optional A numeric Property specifying the altitude of the polygon relative to the ellipsoid surface. extrudedHeight: 0,// optional A numeric Property specifying the altitude of the polygon's extruded face relative to the ellipsoid surface. heightReference: this._cesium.HeightReference.NONE,// optional A Property specifying what the extrudedHeight is relative to. show: true,// optional A boolean Property specifying the visibility of the polygon. fill: true,// optional A boolean Property specifying whether the polygon is filled with the provided material. material: this._cesium.Color.WHITE,//optional A Property specifying the material used to fill the polygon. outline: false,//optional A boolean Property specifying whether the polygon is outlined. outlineColor: this._cesium.Color.BLACK,// optional A Property specifying the Color of the outline. outlineWidth: 1.0,//optional A numeric Property specifying the width of the outline. stRotation: 0.0,// optional A numeric property specifying the rotation of the polygon texture counter-clockwise from north. granularity: this._cesium.Math.RADIANS_PER_DEGREE,// optional A numeric Property specifying the angular distance between each latitude and longitude point. perPositionHeight: false, //optional A boolean specifying whether or not the the height of each position is used. closeTop: true, //optional When false, leaves off the top of an extruded polygon open. closeBottom: true,// optional When false, leaves off the bottom of an extruded polygon open. shadows: this._cesium.ShadowMode.DISABLED,// optional An enum Property specifying whether the polygon casts or receives shadows from each light source. near: 0, far: 5000 }
disFnc function 可选 回调函数
返回:
返回一个Cesium的datasource对象。
创建geojson线数据

createPolylineGeoJsonFeatureLayer(name, geojsonOrurl, option, GroupID, checked, disFnc)GeoJsonFeatureLayer

调用方法:
var urls = "http://183.162.245.49:8099/geoserver/sdkdemo/ows?service=WFS&version=1.0.0&request=GetFeature&typeName=sdkdemo:shengjie&outputFormat=application%2Fjson";
    var data = {
        arcType: 0,
        material: '#00f',
        clampToGround: true,
        far: 50000000,
        near: 0,
        opacity: "1",
        width: 3,
    };
    var dx = sgworld.Creator.createPolylineGeoJsonFeatureLayer("", urls, data, "0", true, function (data) {
        sgworld.Navigate.flyToObj(data);
    });
参数描述:
名称 类型 描述
name String 可选 图层名称。
geojsonOrurl object | String 可选 geojosn对象或者地址
option object 可选 参数
名称 类型 描述
id String 可选 id
material String 可选 填充色
outlineColor String 可选 边框色
outlineWidth Number 可选 边框宽度
height Number | String 可选 高度
width Number 可选 宽度
clampToGround Boolean 可选 是否贴地
classificationType Cesium.ClassificationType 可选 贴地类型
dash Boolean 可选 是否虚线
dashLength Number 可选 虚线间隔
gapColor Number 可选 间隔颜色
near Number 可选 最小可视
far Number 可选 最大可视
GroupID String 可选 父节点id
checked Boolean 可选 是否显示
disFnc function 可选 回调函数
返回:
返回一个GeoJsonFeatureLayer对象。
创建circleGeofeaturelayer

createpolylineVolumeGeojsonFeatureLayer(name, geojsonOrurl, option, disFnc)Promise.<Object>

参数描述:
名称 类型 描述
name String 可选 图层名称。
geojsonOrurl object | String 可选 geojosn对象或者地址
option object 可选 参数对象{ show: true, // optional A boolean Property specifying the visibility of the volume. positions: [], // optional A Property specifying the array of Cartesian3 positions which define the line strip. shape: undefined, // optional A Property specifying the array of Cartesian2 positions which define the shape to be extruded. cornerType: this._cesium.CornerType.ROUNDED, // optional A CornerType Property specifying the style of the corners. granularity: this._cesium.Math.RADIANS_PER_DEGREE, // optional A numeric Property specifying the angular distance between each latitude and longitude point. fill: true, // optional A boolean Property specifying whether the volume is filled with the provided material. material: this._cesium.Color.WHITE, //optional ,//A Property specifying the material used to fill the volume. outline: false, //optional A boolean Property specifying whether the volume is outlined. outlineColor: this._cesium.Color.BLACK, //optional A Property specifying the Color of the outline. outlineWidth: 1.0, //optional A numeric Property specifying the width of the outline. shadows: this._cesium.ShadowMode.DISABLED, // optional An enum Property specifying whether the volume casts or receives shadows from each light source. }
disFnc function 可选 回调函数
返回:
返回一个Cesium的datasource对象。
创建管线

createpolylineVolumeGeojsonPrimitiveLayer(name, geojsonOrurl, option, GroupID, checked, disFnc)GeoJsonFeatureLayer

调用方法:
let url = "http://183.162.245.49:82/sdkdemo_2022/demo/json/js.json";
 let de = {
        material: '#ff0000',
        radius: 0.5,
        height: 1,
        near: 0,
        far: 1000,
        radiusScale: 1,
        slttype: 0, 
        connect: true
    }
    let layer = sgworld.Creator.createpolylineVolumeGeojsonPrimitiveLayer("管线", url, de, "0", true, function (data) {
    });
参数描述:
名称 类型 描述
name String 可选 图层名称。
geojsonOrurl object | String 可选 geojosn对象或者地址
option object 可选 参数
名称 类型 默认值 描述
id String 可选 id
material String 可选 填充色
radius String | Number 可选 管径
orth_width Number 可选 方管宽度,slttype为2有效
orth_height Number 可选 方管高度,slttype为2有效
number Number 可选 星形管边数,slttype为1有效
exradius Number 可选 星形管外径,slttype为1有效
inradius Number 可选 星形管内径,slttype为1有效
slttype Number 管线类型【0:圆管,1:星形管,2:方管】
radiusScale Number 1 可选 管径缩放比例
height Number | String | Object 可选 管线高度
connect Boolean 可选 是否添加管线接头
near Number 可选 最小可视
far Number 可选 最大可视
GroupID String 可选 父节点id
checked Boolean 可选 是否显示
disFnc function 可选 回调函数
返回:
返回一个GeoJsonFeatureLayer对象。
创建墙图层 *

createWallGeoFeatureLayer(name, geojsonOrurl, option, disFnc)Promise.<Object>

参数描述:
名称 类型 描述
name String 可选 图层名称。
geojsonOrurl object | String 可选 geojosn对象或者地址
option object 可选 参数对象{ show: true, // optional A boolean Property specifying the visibility of the wall. positions: [], // optional A Property specifying the array of Cartesian3 positions which define the top of the wall. minimumHeights: [], // optional A Property specifying an array of heights to be used for the bottom of the wall instead of the globe surface. maximumHeights: [], // optional A Property specifying an array of heights to be used for the top of the wall instead of the height of each position. granularity: Cesium.Math.RADIANS_PER_DEGREE, // optional A numeric Property specifying the angular distance between each latitude and longitude point. fill: true, // optional A boolean Property specifying whether the wall is filled with the provided material. material: Color.WHITE, // optional A Property specifying the material used to fill the wall. outline: false, // optional A boolean Property specifying whether the wall is outlined. outlineColor: Color.BLACK, // optional A Property specifying the Color of the outline. outlineWidth: 1.0, // optional A numeric Property specifying the width of the outline. shadows: ShadowMode.DISABLED, // optional An enum Property specifying whether the wall casts or receives shadows from each light source. }
disFnc function 可选 回调函数
返回:
返回一个Cesium的datasource对象。
删除geofeature图层
导出工程数据
获取当前的图层数据集的第一条

getFirstDataSourceItem()object

返回:
返回图例

getLegend()object

返回:
获取层级
获取图层属性元素信息

getProperties()Array

返回:
返回‘["innerid", "stroke-height", "stroke-opacity", "id", "stroke-width", "fill", "stroke", "fill-opacity"]’
当前图层加载类型
获取当前的图层类型
返回:
返回‘[ { label: "文本标签", value: "labellayer" }, { label: "图片标签", value: "billboardlayer" }, { label: "点标签", value: "pointlayer" }, { label: "模型", value: "modellayer" }, { label: "圆", value: "circlelayer" }]’
获取geo featurelayer的显示隐藏状态

getVisibility(label, width)Object

参数描述:
名称 类型 描述
label Object 可选 label对象
width Float 可选 透明度 0-1
返回:
返回一个Label对象。
设置geo featurelayer的显示隐藏
参数描述:
名称 类型 描述
b boolean 可选 true|false