|
@@ -151,6 +151,8 @@ Object.assign(LoadMapData.prototype, /** @lends LoadMapData.prototype */ {
|
|
|
* @param {Object} options 具有以下属性:
|
|
|
* @param {String} options.url 地形服务url
|
|
|
* @param {Number} [options.terrainExaggeration=1] 地形夸张系数
|
|
|
+ * @param {Number} [options.requestVertexNormals=false] 请求地形照明数据
|
|
|
+ * @param {Number} [options.requestWaterMask=false] 请求水体效果所需要的海岸线数据
|
|
|
*
|
|
|
* @example
|
|
|
* layer.addTerrain({
|
|
@@ -247,7 +249,7 @@ Object.assign(LoadMapData.prototype, /** @lends LoadMapData.prototype */ {
|
|
|
* @param {string} options.url 服务地址
|
|
|
* @param {string} [options.CRS] 坐标系,纠偏-“WGS84”
|
|
|
* @param {Number} [options.minimumLevel=0] 最小层级
|
|
|
- * @param {Number} [options.maximumLevel] 最大层级
|
|
|
+ * @param {Number} [options.maximumLevel=18] 最大层级
|
|
|
* @param {Number} [options.alpha=1] 透明度
|
|
|
* @return {String} 服务Id
|
|
|
*
|
|
@@ -270,12 +272,15 @@ Object.assign(LoadMapData.prototype, /** @lends LoadMapData.prototype */ {
|
|
|
let _ConstructorOptions = {
|
|
|
url: options.url
|
|
|
};
|
|
|
+
|
|
|
if (options.minimumLevel) {
|
|
|
_ConstructorOptions.minimumLevel = options.minimumLevel;
|
|
|
}
|
|
|
|
|
|
if (options.maximumLevel) {
|
|
|
_ConstructorOptions.maximumLevel = options.maximumLevel;
|
|
|
+ } else {
|
|
|
+ _ConstructorOptions.maximumLevel = 18;
|
|
|
}
|
|
|
|
|
|
var imageryProvider = new Cesium.UrlTemplateImageryProvider(_ConstructorOptions);
|
|
@@ -333,6 +338,8 @@ Object.assign(LoadMapData.prototype, /** @lends LoadMapData.prototype */ {
|
|
|
|
|
|
if (options.maximumLevel) {
|
|
|
_ConstructorOptions.maximumLevel = options.maximumLevel;
|
|
|
+ } else {
|
|
|
+ _ConstructorOptions.maximumLevel = 18;
|
|
|
}
|
|
|
|
|
|
var imageryProvider = new Cesium.TileMapServiceImageryProvider(_ConstructorOptions);
|
|
@@ -368,7 +375,7 @@ Object.assign(LoadMapData.prototype, /** @lends LoadMapData.prototype */ {
|
|
|
* layer.addWebMapTileService({
|
|
|
* url: 'http://t0.tianditu.gov.cn/cia_w/wmts?tk=10f42f91b6e50d2a8eec980577e6a2e6', //加载全国中文注记(经纬度)
|
|
|
* layers: 'cia',
|
|
|
- * layerstyle: 'default',
|
|
|
+ * style: 'default',
|
|
|
* tileMatrixSetID: 'w',
|
|
|
* format: 'tiles',
|
|
|
* maximumLevel: 18
|
|
@@ -412,6 +419,8 @@ Object.assign(LoadMapData.prototype, /** @lends LoadMapData.prototype */ {
|
|
|
|
|
|
if (options.maximumLevel) {
|
|
|
_ConstructorOptions.maximumLevel = options.maximumLevel;
|
|
|
+ } else {
|
|
|
+ _ConstructorOptions.maximumLevel = 18;
|
|
|
}
|
|
|
|
|
|
let imageryProvider = new Cesium.WebMapTileServiceImageryProvider(_ConstructorOptions);
|
|
@@ -434,6 +443,13 @@ Object.assign(LoadMapData.prototype, /** @lends LoadMapData.prototype */ {
|
|
|
* @param {String} [options.id=guid] 服务ID(不支持全数字),加入到整体图层中 以便可以删除对应的图层
|
|
|
* @param {string} options.url 服务地址
|
|
|
* @param {string} options.layers 加载图层目录,要包含的层,用逗号分隔。
|
|
|
+ * @param {Number} [options.parameters={
|
|
|
+ service:'WMS',
|
|
|
+ version:'1.1.1',
|
|
|
+ request:'GetMap',
|
|
|
+ styles:'',
|
|
|
+ format:'image/jpeg'
|
|
|
+ }] 基础参数
|
|
|
* @param {Number} [options.minimumLevel=0] 最小层级
|
|
|
* @param {Number} [options.maximumLevel] 最大层级
|
|
|
* @param {Number} [options.alpha=1] 透明度
|
|
@@ -461,13 +477,19 @@ Object.assign(LoadMapData.prototype, /** @lends LoadMapData.prototype */ {
|
|
|
|
|
|
let _ConstructorOptions = {
|
|
|
url: options.url,
|
|
|
- layer: options.layers,
|
|
|
- parameters: {
|
|
|
+ layers: options.layers,
|
|
|
+ };
|
|
|
+
|
|
|
+ if (options.parameters) {
|
|
|
+ _ConstructorOptions.parameters = options.parameters;
|
|
|
+ } else {
|
|
|
+ _ConstructorOptions.parameters = {
|
|
|
+ service: 'WMS',
|
|
|
transparent: true, //是否透明
|
|
|
request: "GetMap", //添加上则显示,好像变成了必填
|
|
|
format: "image/png",
|
|
|
- },
|
|
|
- };
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
if (options.minimumLevel) {
|
|
|
_ConstructorOptions.minimumLevel = options.minimumLevel;
|
|
@@ -475,6 +497,8 @@ Object.assign(LoadMapData.prototype, /** @lends LoadMapData.prototype */ {
|
|
|
|
|
|
if (options.maximumLevel) {
|
|
|
_ConstructorOptions.maximumLevel = options.maximumLevel;
|
|
|
+ } else {
|
|
|
+ _ConstructorOptions.maximumLevel = 18;
|
|
|
}
|
|
|
|
|
|
let imageryProvider = new Cesium.WebMapServiceImageryProvider(_ConstructorOptions);
|
|
@@ -609,6 +633,8 @@ Object.assign(LoadMapData.prototype, /** @lends LoadMapData.prototype */ {
|
|
|
*
|
|
|
*/
|
|
|
addCesium3DTilesetBm: function(options, callSuccess) {
|
|
|
+ let _self = this;
|
|
|
+
|
|
|
if (!Cesium.defined(options) || !Cesium.defined(options.url)) {
|
|
|
throw new Cesium.DeveloperError("options.url is required.");
|
|
|
}
|
|
@@ -997,51 +1023,6 @@ Object.assign(LoadMapData.prototype, /** @lends LoadMapData.prototype */ {
|
|
|
billboard.scale = Cesium.defaultValue(billboard.scale, 1);
|
|
|
billboard.pixelOffset = Cesium.defaultValue(billboard.pixelOffset, 0);
|
|
|
|
|
|
- billboard.near = Cesium.defaultValue(billboard.near, 1.5e2);
|
|
|
- billboard.nearValue = Cesium.defaultValue(billboard.nearValue, 1);
|
|
|
- billboard.far = Cesium.defaultValue(billboard.far, 2400);
|
|
|
- billboard.farValue = Cesium.defaultValue(billboard.farValue, 0);
|
|
|
-
|
|
|
- let label = options.label || {};
|
|
|
- label.text = Cesium.defaultValue(label.text, "");
|
|
|
- label.textField = Cesium.defaultValue(label.textField, "");
|
|
|
- label.font = Cesium.defaultValue(label.font, "24px Helvetica");
|
|
|
- if (label.fillColor instanceof Array) {
|
|
|
- label.fillColor = new Cesium.Color(label.fillColor[0] / 255, label.fillColor[1] / 255, label.fillColor[2] / 255, label.fillColor[3]);
|
|
|
- } else if (typeof options.color === 'string') {
|
|
|
- label.fillColor = new Cesium.Color.fromCssColorString(label.fillColor);
|
|
|
- } else {
|
|
|
- label.fillColor = new Cesium.Color.fromCssColorString("#ff0000");
|
|
|
- }
|
|
|
-
|
|
|
- if (label.outlineColor instanceof Array) {
|
|
|
- label.outlineColor = new Cesium.Color(label.outlineColor[0] / 255, label.outlineColor[1] / 255, label.outlineColor[2] / 255, label.outlineColor[3]);
|
|
|
- } else if (label.outlineColor instanceof String) {
|
|
|
- label.outlineColor = new Cesium.Color.fromCssColorString(label.outlineColor);
|
|
|
- } else {
|
|
|
- label.outlineColor = new Cesium.Color.fromCssColorString("#FFFF00");
|
|
|
- }
|
|
|
- label.outlineWidth = Cesium.defaultValue(label.outlineWidth, 1);
|
|
|
-
|
|
|
- //是否显示背景颜色
|
|
|
- label.showBackground = Cesium.defaultValue(label.showBackground, false);
|
|
|
- //背景颜色
|
|
|
- if (label.backgroundColor instanceof Array) {
|
|
|
- label.backgroundColor = new Cesium.Color(label.backgroundColor[0] / 255, label.backgroundColor[1] / 255, label.backgroundColor[2] / 255, label.backgroundColor[3]);
|
|
|
- } else if (label.backgroundColor instanceof String) {
|
|
|
- label.backgroundColor = new Cesium.Color.fromCssColorString(label.backgroundColor);
|
|
|
- } else {
|
|
|
- label.backgroundColor = new Cesium.Color.fromCssColorString("#FFFF00");
|
|
|
- }
|
|
|
-
|
|
|
- label.pixelOffset = Cesium.defaultValue(label.pixelOffset, 0);
|
|
|
- label.scale = Cesium.defaultValue(label.scale, 1);
|
|
|
-
|
|
|
- label.near = Cesium.defaultValue(label.near, 1.5e2);
|
|
|
- label.nearValue = Cesium.defaultValue(label.nearValue, 1);
|
|
|
- label.far = Cesium.defaultValue(label.far, 2400);
|
|
|
- label.farValue = Cesium.defaultValue(label.farValue, 0);
|
|
|
-
|
|
|
const dataSource = new Cesium.GeoJsonDataSource(options.id); // 创建并取名
|
|
|
dataSource.load(options.url, {
|
|
|
clampToGround: true
|
|
@@ -1059,45 +1040,269 @@ Object.assign(LoadMapData.prototype, /** @lends LoadMapData.prototype */ {
|
|
|
disableDepthTestDistance: Number.POSITIVE_INFINITY,
|
|
|
};
|
|
|
|
|
|
- let labelText = label.text;
|
|
|
- if (entity.properties[label.textField]) {
|
|
|
- labelText = entity.properties[label.textField]._value;
|
|
|
- }
|
|
|
- if (labelText === "") {
|
|
|
- labelText = (i + 1).toString();
|
|
|
+ if (billboard.scaleByDistance) {
|
|
|
+ billboard.scaleByDistance.near = Cesium.defaultValue(billboard.scaleByDistance.near, 0);
|
|
|
+ billboard.scaleByDistance.nearValue = Cesium.defaultValue(billboard.scaleByDistance.nearValue, 0);
|
|
|
+ billboard.scaleByDistance.far = Cesium.defaultValue(billboard.scaleByDistance.far, 1);
|
|
|
+ billboard.scaleByDistance.farValue = Cesium.defaultValue(billboard.scaleByDistance.farValue, 0);
|
|
|
+
|
|
|
+ entity.billboard.scaleByDistance = new Cesium.NearFarScalar(billboard.scaleByDistance.near, billboard.scaleByDistance.nearValue, billboard.scaleByDistance.far, billboard.scaleByDistance.farValue) //按距离缩放,即距离大于180米时,图标不显示 Cesium.NearFarScalar(near, nearValue, far, farValue)相机范围的下界。相机范围下界的值。相机范围的上限。该值位于摄像机范围的上界。
|
|
|
}
|
|
|
|
|
|
- entity.label = {
|
|
|
- text: labelText.toString(),
|
|
|
- font: label.font,
|
|
|
- fillColor: label.fillColor, //填充颜色
|
|
|
- outlineColor: label.outlineColor, //边框颜色
|
|
|
- outlineWidth: label.outlineWidth, //边框宽度
|
|
|
- style: Cesium.LabelStyle.FILL_AND_OUTLINE, //FILL不要轮廓 , OUTLINE只要轮廓,FILL_AND_OUTLINE轮廓加填充
|
|
|
-
|
|
|
- verticalOrigin: Cesium.VerticalOrigin.BOTTOM,
|
|
|
- showBackground: label.showBackground, //指定标签后面背景的可见性
|
|
|
- backgroundColor: label.backgroundColor, // 背景颜色
|
|
|
- backgroundPadding: new Cesium.Cartesian2(6, 6), //指定以像素为单位的水平和垂直背景填充padding
|
|
|
- disableDepthTestDistance: Number.POSITIVE_INFINITY,
|
|
|
+ if (options.label) {
|
|
|
+ let label = options.label || {};
|
|
|
+ label.text = Cesium.defaultValue(label.text, "");
|
|
|
+ label.textField = Cesium.defaultValue(label.textField, "");
|
|
|
+ label.font = Cesium.defaultValue(label.font, "24px Helvetica");
|
|
|
+ if (label.fillColor instanceof Array) {
|
|
|
+ label.fillColor = new Cesium.Color(label.fillColor[0] / 255, label.fillColor[1] / 255, label.fillColor[2] / 255, label.fillColor[3]);
|
|
|
+ } else if (typeof options.color === 'string') {
|
|
|
+ label.fillColor = new Cesium.Color.fromCssColorString(label.fillColor);
|
|
|
+ } else {
|
|
|
+ label.fillColor = new Cesium.Color.fromCssColorString("#ff0000");
|
|
|
+ }
|
|
|
|
|
|
- pixelOffset: new Cesium.Cartesian2(0, label.pixelOffset), //偏移量
|
|
|
- scale: label.scale, //尺寸
|
|
|
- }
|
|
|
+ if (label.outlineColor instanceof Array) {
|
|
|
+ label.outlineColor = new Cesium.Color(label.outlineColor[0] / 255, label.outlineColor[1] / 255, label.outlineColor[2] / 255, label.outlineColor[3]);
|
|
|
+ } else if (label.outlineColor instanceof String) {
|
|
|
+ label.outlineColor = new Cesium.Color.fromCssColorString(label.outlineColor);
|
|
|
+ } else {
|
|
|
+ label.outlineColor = new Cesium.Color.fromCssColorString("#FFFF00");
|
|
|
+ }
|
|
|
+ label.outlineWidth = Cesium.defaultValue(label.outlineWidth, 1);
|
|
|
+
|
|
|
+ //是否显示背景颜色
|
|
|
+ label.showBackground = Cesium.defaultValue(label.showBackground, false);
|
|
|
+ //背景颜色
|
|
|
+ if (label.backgroundColor instanceof Array) {
|
|
|
+ label.backgroundColor = new Cesium.Color(label.backgroundColor[0] / 255, label.backgroundColor[1] / 255, label.backgroundColor[2] / 255, label.backgroundColor[3]);
|
|
|
+ } else if (label.backgroundColor instanceof String) {
|
|
|
+ label.backgroundColor = new Cesium.Color.fromCssColorString(label.backgroundColor);
|
|
|
+ } else {
|
|
|
+ label.backgroundColor = new Cesium.Color.fromCssColorString("#FFFF00");
|
|
|
+ }
|
|
|
+
|
|
|
+ label.pixelOffset = Cesium.defaultValue(label.pixelOffset, 0);
|
|
|
+ label.scale = Cesium.defaultValue(label.scale, 1);
|
|
|
|
|
|
- if (label.scaleByDistance) {
|
|
|
- label.scaleByDistance.near = Cesium.defaultValue(label.scaleByDistance.near, 0);
|
|
|
- label.scaleByDistance.nearValue = Cesium.defaultValue(label.scaleByDistance.nearValue, 0);
|
|
|
- label.scaleByDistance.far = Cesium.defaultValue(label.scaleByDistance.far, 1);
|
|
|
- label.scaleByDistance.farValue = Cesium.defaultValue(label.scaleByDistance.farValue, 0);
|
|
|
+ label.near = Cesium.defaultValue(label.near, 1.5e2);
|
|
|
+ label.nearValue = Cesium.defaultValue(label.nearValue, 1);
|
|
|
+ label.far = Cesium.defaultValue(label.far, 2400);
|
|
|
+ label.farValue = Cesium.defaultValue(label.farValue, 0);
|
|
|
+
|
|
|
+
|
|
|
+ let labelText = label.text;
|
|
|
+ if (entity.properties[label.textField]) {
|
|
|
+ labelText = entity.properties[label.textField]._value;
|
|
|
+ }
|
|
|
+ if (labelText === "") {
|
|
|
+ labelText = (i + 1).toString();
|
|
|
+ }
|
|
|
|
|
|
- entity.label.scaleByDistance = new Cesium.NearFarScalar(label.scaleByDistance.near, label.scaleByDistance.nearValue, label.scaleByDistance.far, label.scaleByDistance.farValue) //按距离缩放,即距离大于180米时,图标不显示 Cesium.NearFarScalar(near, nearValue, far, farValue)相机范围的下界。相机范围下界的值。相机范围的上限。该值位于摄像机范围的上界。
|
|
|
+ entity.label = {
|
|
|
+ text: labelText.toString(),
|
|
|
+ font: label.font,
|
|
|
+ fillColor: label.fillColor, //填充颜色
|
|
|
+ outlineColor: label.outlineColor, //边框颜色
|
|
|
+ outlineWidth: label.outlineWidth, //边框宽度
|
|
|
+ style: Cesium.LabelStyle.FILL_AND_OUTLINE, //FILL不要轮廓 , OUTLINE只要轮廓,FILL_AND_OUTLINE轮廓加填充
|
|
|
+
|
|
|
+ verticalOrigin: Cesium.VerticalOrigin.BOTTOM,
|
|
|
+ showBackground: label.showBackground, //指定标签后面背景的可见性
|
|
|
+ backgroundColor: label.backgroundColor, // 背景颜色
|
|
|
+ backgroundPadding: new Cesium.Cartesian2(6, 6), //指定以像素为单位的水平和垂直背景填充padding
|
|
|
+ disableDepthTestDistance: Number.POSITIVE_INFINITY,
|
|
|
+
|
|
|
+ pixelOffset: new Cesium.Cartesian2(0, label.pixelOffset), //偏移量
|
|
|
+ scale: label.scale, //尺寸
|
|
|
+ }
|
|
|
+
|
|
|
+ if (label.scaleByDistance) {
|
|
|
+ label.scaleByDistance.near = Cesium.defaultValue(label.scaleByDistance.near, 0);
|
|
|
+ label.scaleByDistance.nearValue = Cesium.defaultValue(label.scaleByDistance.nearValue, 0);
|
|
|
+ label.scaleByDistance.far = Cesium.defaultValue(label.scaleByDistance.far, 1);
|
|
|
+ label.scaleByDistance.farValue = Cesium.defaultValue(label.scaleByDistance.farValue, 0);
|
|
|
+
|
|
|
+ entity.label.scaleByDistance = new Cesium.NearFarScalar(label.scaleByDistance.near, label.scaleByDistance.nearValue, label.scaleByDistance.far, label.scaleByDistance.farValue) //按距离缩放,即距离大于180米时,图标不显示 Cesium.NearFarScalar(near, nearValue, far, farValue)相机范围的下界。相机范围下界的值。相机范围的上限。该值位于摄像机范围的上界。
|
|
|
+ }
|
|
|
}
|
|
|
})
|
|
|
|
|
|
if (callSuccess) callSuccess(options.id);
|
|
|
})
|
|
|
},
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据GeoJson添加广告牌
|
|
|
+ * @param {Object} options
|
|
|
+ * @param {String} options.url geoJson文件路径
|
|
|
+ * @param {String} options.id 用于移除
|
|
|
+ * @param {Object} [options.billboard] 广告牌的样式,具有以下属性:
|
|
|
+ * @param {Number} [options.billboard.imgUrl] 广告牌图片
|
|
|
+ * @param {Number} [options.billboard.scale=1] 尺寸
|
|
|
+ * @param {Object} [options.billboard.scaleByDistance] 距离相机的距离缩放点。
|
|
|
+ * @param {Number} [options.billboard.scaleByDistance.near=0] 相机范围的下界。
|
|
|
+ * @param {String} [options.billboard.scaleByDistance.nearValue=0] 相机范围下界的值。
|
|
|
+ * @param {String} [options.billboard.scaleByDistance.far=1] 相机范围的上限。
|
|
|
+ * @param {Number} [options.billboard.scaleByDistance.farValue=0] 该值位于摄像机范围的上界。
|
|
|
+ *
|
|
|
+ * @param {Object} [options.lable] lable的样式,具有以下属性:
|
|
|
+ * @param {Number} [options.lable.text=""] 文字
|
|
|
+ * @param {Number} [options.lable.textField=""] 文字字段
|
|
|
+ * @param {String} [options.lable.font="24px Helvetica"] 指定CSS字体的属性,字体大小及样式
|
|
|
+ * @param {String} [options.lable.fillColor=[255,255,0,1]] 字体颜色
|
|
|
+ * @param {String} [options.lable.outlineColor=[255,255,255,1]] 字体边框颜色
|
|
|
+ * @param {Number} [options.lable.outlineWidth=1] 边框宽度
|
|
|
+ * @param {Number} [options.lable.showBackground=false] 是否显示背景颜色
|
|
|
+ * @param {Number} [options.lable.backgroundColor=[255,255,255,1]] 背景颜色
|
|
|
+ * @param {Number} [options.lable.pixelOffset=0] 偏移量
|
|
|
+ * @param {Number} [options.lable.scale=1] 尺寸
|
|
|
+ * @param {Object} [options.lable.scaleByDistance] 距离相机的距离缩放点。
|
|
|
+ * @param {Number} [options.lable.scaleByDistance.near=0] 相机范围的下界。
|
|
|
+ * @param {String} [options.lable.scaleByDistance.nearValue=0] 相机范围下界的值。
|
|
|
+ * @param {String} [options.lable.scaleByDistance.far=1] 相机范围的上限。
|
|
|
+ * @param {Number} [options.lable.scaleByDistance.farValue=0] 该值位于摄像机范围的上界。
|
|
|
+ */
|
|
|
+ addBillboardByJson(options, callSuccess) {
|
|
|
+
|
|
|
+ let _self = this;
|
|
|
+ let viewer = this._viewer;
|
|
|
+
|
|
|
+ if (!Cesium.defined(options.url)) {
|
|
|
+ resolve("options.url is required.");
|
|
|
+ throw new Cesium.DeveloperError("options.url is required.");
|
|
|
+ }
|
|
|
+
|
|
|
+ options.id = options.id || this._guid();
|
|
|
+
|
|
|
+ let billboard = options.billboard || {};
|
|
|
+ billboard.imgUrl = Cesium.defaultValue(billboard.imgUrl, 'jt3dSDK/imgs/point/point3.png');
|
|
|
+
|
|
|
+ billboard.scale = Cesium.defaultValue(billboard.scale, 1);
|
|
|
+ billboard.pixelOffset = Cesium.defaultValue(billboard.pixelOffset, 0);
|
|
|
+
|
|
|
+ fetch(options.url).then(res => {
|
|
|
+ return res.json();
|
|
|
+ }).then(res => {
|
|
|
+
|
|
|
+
|
|
|
+ for (var i = 0; i < res.features.length; i++) {
|
|
|
+ let coordinates = res.features[i].geometry.coordinates;
|
|
|
+ let position = Cesium.Cartesian3.fromDegrees(coordinates[0], coordinates[1], coordinates[2] || 0);
|
|
|
+
|
|
|
+ //先创建一个CustomDataSource源,然后把entity存入这里面
|
|
|
+ let Point = new Cesium.CustomDataSource(options.id);
|
|
|
+ viewer.dataSources.add(Point);
|
|
|
+
|
|
|
+ let entity = new Cesium.Entity({
|
|
|
+ // id: options.id,
|
|
|
+ name: "add billboard",
|
|
|
+ //位置
|
|
|
+ position: position,
|
|
|
+ //图片标签
|
|
|
+ billboard: {
|
|
|
+ image: billboard.imgUrl,
|
|
|
+ horizontalOrigin: Cesium.HorizontalOrigin.CENTER, //水平
|
|
|
+ verticalOrigin: Cesium.VerticalOrigin.BOTTOM, //垂直位置
|
|
|
+ scale: billboard.scale, //尺寸
|
|
|
+ pixelOffset: new Cesium.Cartesian2(0, billboard.pixelOffset),
|
|
|
+ disableDepthTestDistance: Number.POSITIVE_INFINITY,
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ if (billboard.scaleByDistance) {
|
|
|
+ billboard.scaleByDistance.near = Cesium.defaultValue(billboard.scaleByDistance.near, 0);
|
|
|
+ billboard.scaleByDistance.nearValue = Cesium.defaultValue(billboard.scaleByDistance.nearValue, 0);
|
|
|
+ billboard.scaleByDistance.far = Cesium.defaultValue(billboard.scaleByDistance.far, 1);
|
|
|
+ billboard.scaleByDistance.farValue = Cesium.defaultValue(billboard.scaleByDistance.farValue, 0);
|
|
|
+
|
|
|
+ entity.billboard.scaleByDistance = new Cesium.NearFarScalar(billboard.scaleByDistance.near, billboard.scaleByDistance.nearValue, billboard.scaleByDistance.far, billboard.scaleByDistance.farValue) //按距离缩放,即距离大于180米时,图标不显示 Cesium.NearFarScalar(near, nearValue, far, farValue)相机范围的下界。相机范围下界的值。相机范围的上限。该值位于摄像机范围的上界。
|
|
|
+ }
|
|
|
+
|
|
|
+ if (options.label) {
|
|
|
+ let label = options.label || {};
|
|
|
+ label.text = Cesium.defaultValue(label.text, "");
|
|
|
+ label.textField = Cesium.defaultValue(label.textField, "");
|
|
|
+ label.font = Cesium.defaultValue(label.font, "24px Helvetica");
|
|
|
+ if (label.fillColor instanceof Array) {
|
|
|
+ label.fillColor = new Cesium.Color(label.fillColor[0] / 255, label.fillColor[1] / 255, label.fillColor[2] / 255, label.fillColor[3]);
|
|
|
+ } else if (typeof options.color === 'string') {
|
|
|
+ label.fillColor = new Cesium.Color.fromCssColorString(label.fillColor);
|
|
|
+ } else {
|
|
|
+ label.fillColor = new Cesium.Color.fromCssColorString("#ff0000");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (label.outlineColor instanceof Array) {
|
|
|
+ label.outlineColor = new Cesium.Color(label.outlineColor[0] / 255, label.outlineColor[1] / 255, label.outlineColor[2] / 255, label.outlineColor[3]);
|
|
|
+ } else if (label.outlineColor instanceof String) {
|
|
|
+ label.outlineColor = new Cesium.Color.fromCssColorString(label.outlineColor);
|
|
|
+ } else {
|
|
|
+ label.outlineColor = new Cesium.Color.fromCssColorString("#FFFF00");
|
|
|
+ }
|
|
|
+ label.outlineWidth = Cesium.defaultValue(label.outlineWidth, 1);
|
|
|
+
|
|
|
+ //是否显示背景颜色
|
|
|
+ label.showBackground = Cesium.defaultValue(label.showBackground, false);
|
|
|
+ //背景颜色
|
|
|
+ if (label.backgroundColor instanceof Array) {
|
|
|
+ label.backgroundColor = new Cesium.Color(label.backgroundColor[0] / 255, label.backgroundColor[1] / 255, label.backgroundColor[2] / 255, label.backgroundColor[3]);
|
|
|
+ } else if (label.backgroundColor instanceof String) {
|
|
|
+ label.backgroundColor = new Cesium.Color.fromCssColorString(label.backgroundColor);
|
|
|
+ } else {
|
|
|
+ label.backgroundColor = new Cesium.Color.fromCssColorString("#FFFF00");
|
|
|
+ }
|
|
|
+
|
|
|
+ label.pixelOffset = Cesium.defaultValue(label.pixelOffset, 0);
|
|
|
+ label.scale = Cesium.defaultValue(label.scale, 1);
|
|
|
+
|
|
|
+ label.near = Cesium.defaultValue(label.near, 1.5e2);
|
|
|
+ label.nearValue = Cesium.defaultValue(label.nearValue, 1);
|
|
|
+ label.far = Cesium.defaultValue(label.far, 2400);
|
|
|
+ label.farValue = Cesium.defaultValue(label.farValue, 0);
|
|
|
+
|
|
|
+ let labelText = label.text;
|
|
|
+ if (res.features[i].properties[label.textField]) {
|
|
|
+ labelText = res.features[i].properties[label.textField];
|
|
|
+ }
|
|
|
+ if (labelText === "") {
|
|
|
+ labelText = (i + 1).toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ entity.label = {
|
|
|
+ text: labelText.toString(),
|
|
|
+ font: label.font,
|
|
|
+ fillColor: label.fillColor, //填充颜色
|
|
|
+ outlineColor: label.outlineColor, //边框颜色
|
|
|
+ outlineWidth: label.outlineWidth, //边框宽度
|
|
|
+ style: Cesium.LabelStyle.FILL_AND_OUTLINE, //FILL不要轮廓 , OUTLINE只要轮廓,FILL_AND_OUTLINE轮廓加填充
|
|
|
+
|
|
|
+ verticalOrigin: Cesium.VerticalOrigin.BOTTOM,
|
|
|
+ showBackground: label.showBackground, //指定标签后面背景的可见性
|
|
|
+ backgroundColor: label.backgroundColor, // 背景颜色
|
|
|
+ backgroundPadding: new Cesium.Cartesian2(6, 6), //指定以像素为单位的水平和垂直背景填充padding
|
|
|
+ disableDepthTestDistance: Number.POSITIVE_INFINITY,
|
|
|
+
|
|
|
+ pixelOffset: new Cesium.Cartesian2(0, label.pixelOffset), //偏移量
|
|
|
+ scale: label.scale, //尺寸
|
|
|
+ }
|
|
|
+
|
|
|
+ if (label.scaleByDistance) {
|
|
|
+ label.scaleByDistance.near = Cesium.defaultValue(label.scaleByDistance.near, 0);
|
|
|
+ label.scaleByDistance.nearValue = Cesium.defaultValue(label.scaleByDistance.nearValue, 0);
|
|
|
+ label.scaleByDistance.far = Cesium.defaultValue(label.scaleByDistance.far, 1);
|
|
|
+ label.scaleByDistance.farValue = Cesium.defaultValue(label.scaleByDistance.farValue, 0);
|
|
|
+
|
|
|
+ entity.label.scaleByDistance = new Cesium.NearFarScalar(label.scaleByDistance.near, label.scaleByDistance.nearValue, label.scaleByDistance.far, label.scaleByDistance.farValue) //按距离缩放,即距离大于180米时,图标不显示 Cesium.NearFarScalar(near, nearValue, far, farValue)相机范围的下界。相机范围下界的值。相机范围的上限。该值位于摄像机范围的上界。
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // viewer.entities.add(entity);
|
|
|
+ Point.entities.add(entity)
|
|
|
+ }
|
|
|
+
|
|
|
+ if (callSuccess) callSuccess(options.id);
|
|
|
+ });
|
|
|
+ },
|
|
|
+
|
|
|
});
|
|
|
|
|
|
/**
|