园林绿化
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

561 lines
24 KiB

  1. /**
  2. * Mars3D平台插件,结合supermap超图库使用的功能插件 mars3d-supermap
  3. *
  4. * 版本信息v3.4.18
  5. * 编译日期2022-12-15 15:18:50
  6. * 版权所有Copyright by 火星科技 http://mars3d.cn
  7. * 使用单位免费公开版 2022-10-01
  8. */
  9. (function (global, factory) {
  10. typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, (window.mars3d || require('mars3d'))) :
  11. typeof define === 'function' && define.amd ? define(['exports', 'mars3d'], factory) :
  12. (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["mars3d-supermap"] = {}, global.mars3d));
  13. })(this, (function (exports, mars3d) { 'use strict';
  14. function _interopNamespace(e) {
  15. if (e && e.__esModule) return e;
  16. var n = Object.create(null);
  17. if (e) {
  18. Object.keys(e).forEach(function (k) {
  19. if (k !== 'default') {
  20. var d = Object.getOwnPropertyDescriptor(e, k);
  21. Object.defineProperty(n, k, d.get ? d : {
  22. enumerable: true,
  23. get: function () { return e[k]; }
  24. });
  25. }
  26. });
  27. }
  28. n["default"] = e;
  29. return n;
  30. }
  31. var mars3d__namespace = /*#__PURE__*/_interopNamespace(mars3d);
  32. const Cesium$2 = mars3d__namespace.Cesium;
  33. const BaseLayer$1 = mars3d__namespace.layer.BaseLayer;
  34. /**
  35. * 超图S3M三维模型图层,
  36. * 需要引入 mars3d-supermap 插件库
  37. *
  38. * @param {Object} [options] 参数对象包括以下
  39. * @param {String} options.url supermap的S3M服务地址,示例"url": "http://www.supermapol.com/realspace/services/3D-Olympic/rest/realspace"
  40. * @param {String} [options.layername] 指定图层名称,未指定时打开iserver场景服务下所有图层
  41. * @param {String} [options.sceneName] 工作空间中有多个场景需要指定场景名称设置为undefined默认打开第一个
  42. * @param {Object} [options.s3mOptions] [S3M支持的参数]{@link http://support.supermap.com.cn:8090/webgl/docs/Documentation/S3MTilesLayer.html?classFilter=S3MTilesLayer} ,示例: {"selectEnabled":false},
  43. * @param {Object} [options.position] 模型新的中心点位置移动模型
  44. * @param {Number} options.position.alt 获取或设置底部高程单位
  45. *
  46. * @param {String|Number} [options.id = createGuid()] 图层id标识
  47. * @param {String|Number} [options.pid = -1] 图层父级的id一般图层管理中使用
  48. * @param {String} [options.name = ''] 图层名称
  49. * @param {Boolean} [options.show = true] 图层是否显示
  50. * @param {BaseClass|Boolean} [options.eventParent] 指定的事件冒泡对象默认为map对象false时不冒泡
  51. * @param {Object} [options.center] 图层自定义定位视角 {@link Map#setCameraView}
  52. * @param {Number} options.center.lng 经度值, 180 - 180
  53. * @param {Number} options.center.lat 纬度值, -90 - 90
  54. * @param {Number} [options.center.alt] 高度值
  55. * @param {Number} [options.center.heading] 方向角度值绕垂直于地心的轴旋转角度, 0至360
  56. * @param {Number} [options.center.pitch] 俯仰角度值绕纬度线旋转角度, -90至90
  57. * @param {Number} [options.center.roll] 翻滚角度值绕经度线旋转角度, -90至90
  58. * @param {Boolean} [options.flyTo] 加载完成数据后是否自动飞行定位到数据所在的区域
  59. * @export
  60. * @class S3MLayer
  61. * @extends {BaseLayer}
  62. */
  63. class S3MLayer extends BaseLayer$1 {
  64. /**
  65. * 模型对应的Cesium.S3MTilesLayer图层组
  66. * @type {Object[]}
  67. * @readonly
  68. * @see http://support.supermap.com.cn:8090/webgl/docs/Documentation/S3MTilesLayer.html
  69. */
  70. get layer() {
  71. return this._layerArr
  72. }
  73. /**
  74. * 设置S3M图层本身支持的参数
  75. * @type {Object}
  76. * @see [S3M支持的参数]{@link http://support.supermap.com.cn:8090/webgl/docs/Documentation/S3MTilesLayer.html?classFilter=S3MTilesLayer}
  77. */
  78. get s3mOptions() {
  79. return this.options.s3mOptions
  80. }
  81. set s3mOptions(value) {
  82. for (const key in value) {
  83. let val = value[key];
  84. this.options.s3mOptions[key] = val;
  85. if (key === "transparentBackColor") {
  86. // 去黑边,与offset互斥,注意别配置offset
  87. val = Cesium$2.Color.fromCssColorString(val);
  88. } else if (key === "transparentBackColorTolerance") {
  89. val = Number(val);
  90. }
  91. for (let i = 0; i < this._layerArr.length; i++) {
  92. const layer = this._layerArr[i];
  93. if (layer == null) {
  94. continue
  95. }
  96. layer[key] = val;
  97. }
  98. }
  99. }
  100. _showHook(show) {
  101. this.eachLayer((layer) => {
  102. layer.visible = show; // 不同超图版本,有的是visible,有的是show
  103. layer.show = show;
  104. }, this);
  105. }
  106. /**
  107. * 对象添加到地图前创建一些对象的钩子方法
  108. * 只会调用一次
  109. * @return {void}
  110. * @private
  111. */
  112. _mountedHook() {
  113. if (!this._map.scene.open) {
  114. throw new Error("请引入 超图版本Cesium库 或 超图S3M插件 ")
  115. }
  116. const centerOld = this._map.getCameraView();
  117. // 场景添加S3M图层服务
  118. let promise;
  119. if (this.options.layername) {
  120. promise = this._map.scene.addS3MTilesLayerByScp(this.options.url, {
  121. name: this.options.layername,
  122. autoSetView: this.options.flyTo,
  123. cullEnabled: this.options.cullEnabled
  124. });
  125. } else {
  126. promise = this._map.scene.open(this.options.url, this.options.sceneName, {
  127. autoSetView: this.options.flyTo
  128. });
  129. }
  130. promise.then(
  131. (smLayer) => {
  132. if (Array.isArray(smLayer)) {
  133. this._layerArr = smLayer;
  134. } else {
  135. this._layerArr = [smLayer];
  136. }
  137. for (let i = 0; i < this._layerArr.length; i++) {
  138. const layer = this._layerArr[i];
  139. if (!layer) {
  140. continue
  141. }
  142. try {
  143. this._initModelItem(layer);
  144. } catch (e) {
  145. mars3d__namespace.Log.logError("s3m图层初始化出错", e);
  146. }
  147. }
  148. this._showHook(this.show);
  149. if (this.options.flyTo) {
  150. this.flyToByAnimationEnd();
  151. } else if (this.options.flyTo === false) {
  152. this._map.setCameraView(centerOld, { duration: 0 });
  153. }
  154. this._readyPromise.resolve(this);
  155. this.fire(mars3d__namespace.EventType.load, { layers: this._layerArr });
  156. },
  157. (error) => {
  158. this._readyPromise && this._readyPromise.reject(error);
  159. }
  160. );
  161. // this._map.viewer.pickEvent.addEventListener(function (feature) {
  162. // debugger;
  163. // });
  164. }
  165. // 对单个s3m图层处理
  166. _initModelItem(layer) {
  167. // 图层参数合并
  168. if (this.options.s3mOptions) {
  169. for (const key in this.options.s3mOptions) {
  170. const val = this.options.s3mOptions[key];
  171. if (key === "transparentBackColor") {
  172. layer[key] = Cesium$2.Color.fromCssColorString(val); // 去黑边
  173. } else if (key === "transparentBackColorTolerance") {
  174. layer[key] = Number(val);
  175. } else {
  176. layer[key] = val;
  177. }
  178. }
  179. }
  180. // 选中颜色
  181. if (this.options.highlight) {
  182. layer.selectedColor = mars3d__namespace.Util.getColorByStyle(this.options.highlight);
  183. }
  184. // 高度调整
  185. if (this.options?.position?.alt) {
  186. layer.style3D.altitudeMode = Cesium$2.HeightReference.NONE;
  187. layer.style3D.bottomAltitude = this.options.position.alt;
  188. if (layer.refresh) {
  189. layer.refresh(); // 设置风格后需刷新
  190. }
  191. }
  192. }
  193. /**
  194. * 对象添加到地图上的创建钩子方法
  195. * 每次add时都会调用
  196. * @return {void}
  197. * @private
  198. */
  199. _addedHook() {
  200. this._showHook(this.show);
  201. }
  202. /**
  203. * 对象从地图上移除的创建钩子方法
  204. * 每次remove时都会调用
  205. * @return {void}
  206. * @private
  207. */
  208. _removedHook() {
  209. this._showHook(false);
  210. }
  211. /**
  212. * 遍历每一个子图层并将其作为参数传递给回调函数
  213. *
  214. * @param {Function} method 回调方法
  215. * @param {Object} [context] 侦听器的上下文(this关键字将指向的对象)
  216. * @return {GroupLayer} 当前对象本身,可以链式调用
  217. */
  218. eachLayer(method, context) {
  219. if (!this._layerArr) {
  220. return
  221. }
  222. this._layerArr.forEach((layer) => {
  223. method.call(context, layer);
  224. });
  225. return this
  226. }
  227. /**
  228. * 设置透明度
  229. * @param {Number} value 透明度
  230. * @return {void}
  231. */
  232. setOpacity(value) {
  233. this.eachLayer((layer) => {
  234. layer.style3D.fillForeColor.alpha = value;
  235. }, this);
  236. }
  237. // 定位至数据区域
  238. flyTo(options = {}) {
  239. if (this.options.center) {
  240. return this._map.setCameraView(this.options.center, options)
  241. } else if (this.options.extent) {
  242. return this._map.flyToExtent(this.options.extent, options)
  243. }
  244. }
  245. }
  246. mars3d__namespace.layer.S3MLayer = S3MLayer;
  247. // 注册下
  248. mars3d__namespace.LayerUtil.register("supermap_s3m", S3MLayer);
  249. const Cesium$1 = mars3d__namespace.Cesium;
  250. const BaseTileLayer = mars3d__namespace.layer.BaseTileLayer;
  251. /**
  252. * 超图影像瓦片服务图层,
  253. * 需要引入 mars3d-supermap 插件库
  254. *
  255. * @param {Object} [options] 参数对象包括以下
  256. * @param {String} options.url supermap的影像服务地址
  257. * @param {String|String[]} [options.subdomains] URL模板中用于 {s} 占位符的子域 如果此参数是单个字符串则字符串中的每个字符都是一个子域如果是 一个数组数组中的每个元素都是一个子域
  258. * @param {String} [options.tileFormat] 影像图片格式默认为png
  259. * @param {Boolean} [options.transparent=true] 设置请求的地图服务的参数是否为transparent
  260. * @param {String|Cesium.Color} [options.transparentBackColor] 设置影像透明色
  261. * @param {Number} [options.transparentBackColorTolerance] 去黑边,设置影像透明色容限取值范围为0.0~1.00.0表示完全透明1.0表示完全不透明
  262. * @param {String} [options.cacheKey] 影像的三维缓存密钥
  263. *
  264. * @param {Number} [options.minimumLevel=0] 瓦片所支持的最低层级如果数据没有第0层该参数必须配置,当地图小于该级别时平台不去请求服务数据
  265. * @param {Number} [options.maximumLevel] 瓦片所支持的最大层级,大于该层级时会显示上一层拉伸后的瓦片当地图大于该级别时平台不去请求服务数据
  266. * @param {Number} [options.minimumTerrainLevel] 展示影像图层的最小地形细节级别小于该级别时平台不显示影像数据
  267. * @param {Number} [options.maximumTerrainLevel] 展示影像图层的最大地形细节级别大于该级别时平台不显示影像数据
  268. * @param {Object} [options.rectangle] 瓦片数据的矩形区域范围
  269. * @param {Number} options.rectangle.xmin 最小经度值, -180 180
  270. * @param {Number} options.rectangle.xmax 最大经度值, -180 180
  271. * @param {Number} options.rectangle.ymin 最小纬度值, -90 90
  272. * @param {Number} options.rectangle.ymax 最大纬度值, -90 90
  273. * @param {Number[]} [options.bbox] bbox规范的瓦片数据的矩形区域范围,与rectangle二选一即可
  274. * @param {Number} [options.zIndex] 控制图层的叠加层次默认按加载的顺序进行叠加但也可以自定义叠加顺序数字大的在上面(只对同类型图层间有效)
  275. * @param {CRS} [options.crs=CRS.EPSG:3857] 瓦片数据的坐标系信息默认为墨卡托投影
  276. * @param {ChinaCRS} [options.chinaCRS] 标识瓦片的国内坐标系用于自动纠偏或加偏自动将瓦片转为map对应的chinaCRS类型坐标系
  277. *
  278. * @param {String} [options.proxy] 加载资源时要使用的代理服务url
  279. * @param {Object} [options.templateValues] 一个对象用于替换Url中的模板值的键/值对
  280. * @param {Object} [options.queryParameters] 一个对象其中包含在检索资源时将发送的查询参数比如queryParameters: {'access_token': '123-435-456-000'},
  281. * @param {Object} [options.headers] 一个对象将发送的其他HTTP标头比如headers: { 'X-My-Header': 'valueOfHeader' },
  282. * @param {Boolean} [options.enablePickFeatures=true] 如果为true {@link UrlTemplateImageryProvider#pickFeatures} 请求 pickFeaturesUrl 并尝试解释响应中包含的功能
  283. * 如果为 false{@link UrlTemplateImageryProvider#pickFeatures} 会立即返回未定义表示没有可拾取的内容 功能而无需与服务器通信如果您知道数据则将此属性设置为false 源不支持选择功能或者您不希望该提供程序的功能可供选择注意 可以通过修改 {@link UriTemplateImageryProvider#enablePickFeatures}来动态覆盖 属性
  284. * @param {Cesium.GetFeatureInfoFormat[]} [options.getFeatureInfoFormats] 在某处获取功能信息的格式 调用 {@link UrlTemplateImageryProvider#pickFeatures} 的特定位置如果这 参数未指定功能选择已禁用
  285. *
  286. * @param {Number} [options.opacity = 1.0] 透明度取值范围0.0-1.0
  287. * @param {Number|Function} [options.alpha=1.0] 同opacity
  288. * @param {Number|Function} [options.nightAlpha=1.0] enableLighting true 在地球的夜晚区域的透明度取值范围0.0-1.0
  289. * @param {Number|Function} [options.dayAlpha=1.0] enableLighting true 在地球的白天区域的透明度取值范围0.0-1.0
  290. * @param {Number|Function} [options.brightness=1.0] 亮度
  291. * @param {Number|Function} [options.contrast=1.0] 对比度 1.0使用未修改的图像颜色小于1.0会降低对比度而大于1.0则会提高对比度
  292. * @param {Number|Function} [options.hue=0.0] 色调 0.0 时未修改的图像颜色
  293. * @param {Number|Function} [options.saturation=1.0] 饱和度 1.0使用未修改的图像颜色小于1.0会降低饱和度而大于1.0则会增加饱和度
  294. * @param {Number|Function} [options.gamma=1.0] 伽马校正值 1.0使用未修改的图像颜色
  295. * @param {Number} [options.maximumAnisotropy=maximum supported] 使用的最大各向异性水平 用于纹理过滤如果未指定此参数则支持最大各向异性 将使用WebGL堆栈较大的值可使影像在水平方向上看起来更好 视图
  296. * @param {Cesium.Rectangle} [options.cutoutRectangle] 制图矩形用于裁剪此ImageryLayer的一部分
  297. * @param {Cesium.Color} [options.colorToAlpha] 用作Alpha的颜色
  298. * @param {Number} [options.colorToAlphaThreshold=0.004] 颜色到Alpha的阈值
  299. * @param {Boolean} [options.hasAlphaChannel=true] 如果此图像提供者提供的图像为真 包括一个Alpha通道否则为假如果此属性为false则为Alpha通道如果 目前将被忽略如果此属性为true则任何没有Alpha通道的图像都将 它们的alpha随处可见当此属性为false时内存使用情况 和纹理上传时间可能会减少
  300. * @param {Number} [options.tileWidth=256] 图像图块的像素宽度
  301. * @param {Number} [options.tileHeight=256] 图像图块的像素高度
  302. * @param {Object} [options.customTags] 允许替换网址模板中的自定义关键字该对象必须具有字符串作为键并且必须具有值
  303. *
  304. * @param {String|Number} [options.id = createGuid()] 图层id标识
  305. * @param {String|Number} [options.pid = -1] 图层父级的id一般图层管理中使用
  306. * @param {String} [options.name = ''] 图层名称
  307. * @param {Boolean} [options.show = true] 图层是否显示
  308. * @param {BaseClass|Boolean} [options.eventParent] 指定的事件冒泡对象默认为map对象false时不冒泡
  309. * @param {Object} [options.center] 图层自定义定位视角 {@link Map#setCameraView}
  310. * @param {Number} options.center.lng 经度值, 180 - 180
  311. * @param {Number} options.center.lat 纬度值, -90 - 90
  312. * @param {Number} [options.center.alt] 高度值
  313. * @param {Number} [options.center.heading] 方向角度值绕垂直于地心的轴旋转角度, 0至360
  314. * @param {Number} [options.center.pitch] 俯仰角度值绕纬度线旋转角度, -90至90
  315. * @param {Number} [options.center.roll] 翻滚角度值绕经度线旋转角度, -90至90
  316. * @param {Boolean} [options.flyTo] 加载完成数据后是否自动飞行定位到数据所在的区域
  317. * @export
  318. * @class SmImgLayer
  319. * @extends {BaseTileLayer}
  320. *
  321. * @see http://support.supermap.com.cn:8090/webgl/docs/Documentation/SuperMapImageryProvider.html?classFilter=SuperMapImageryProvider
  322. */
  323. class SmImgLayer extends BaseTileLayer {
  324. // 构建ImageryProvider
  325. _createImageryProvider(options) {
  326. return createImageryProvider(options)
  327. }
  328. // 添加时
  329. _addedHook() {
  330. super._addedHook();
  331. if (Cesium$1.defined(this.options.transparentBackColor)) {
  332. this._imageryLayer.transparentBackColor = mars3d__namespace.Util.getCesiumColor(this.options.transparentBackColor);
  333. this._imageryLayer.transparentBackColorTolerance = this.options.transparentBackColorTolerance; // 去黑边
  334. }
  335. }
  336. }
  337. function createImageryProvider(options) {
  338. options = mars3d__namespace.LayerUtil.converOptions(options);
  339. if (options.url instanceof Cesium$1.Resource) {
  340. options.url = options.url.url;
  341. }
  342. if (Cesium$1.defined(options.transparentBackColor)) {
  343. delete options.transparentBackColor;
  344. delete options.transparentBackColorTolerance;
  345. }
  346. return new Cesium$1.SuperMapImageryProvider(options)
  347. }
  348. /**
  349. * 创建用于图层的 ImageryProvider对象
  350. *
  351. * @param {Object} options Provider参数同图层构造参数
  352. * @return {Cesium.ImageryProvider} ImageryProvider类
  353. * @function
  354. */
  355. SmImgLayer.createImageryProvider = createImageryProvider;
  356. mars3d__namespace.layer.SmImgLayer = SmImgLayer;
  357. // 注册下
  358. const layerType = "supermap_img";
  359. mars3d__namespace.LayerUtil.register(layerType, SmImgLayer);
  360. mars3d__namespace.LayerUtil.registerImageryProvider(layerType, createImageryProvider);
  361. const Cesium = mars3d__namespace.Cesium;
  362. const BaseLayer = mars3d__namespace.layer.BaseLayer;
  363. /**
  364. * 超图MVT矢量瓦片图层,
  365. * 需要引入 mars3d-supermap 插件库
  366. *
  367. * @param {Object} [options] 参数对象包括以下
  368. * @param {String} options.url 适用于通过SuperMap桌面软件生成mvt数据,经iServer发布为rest风格的地图服务只需提供服务地址
  369. * @param {String} options.layer 图层名称,适用于第三方发布的WMTS服务
  370. * @param {Number} [options.canvasWidth] 用来绘制矢量的纹理边长默认是512越大越精细越小性能越高
  371. * @param {String} [options.format='mvt'] 适用于第三方发布的WMTS服务
  372. * @param {Object} [options.mapboxStyle] 使用的mapBox风格
  373. * @param {Object} [options.多个参数] 参考[supermap官方API]{@link http://support.supermap.com.cn:8090/webgl/docs/Documentation/Scene.html#addVectorTilesLayer}
  374. *
  375. *
  376. * @param {String|Number} [options.id = createGuid()] 图层id标识
  377. * @param {String|Number} [options.pid = -1] 图层父级的id一般图层管理中使用
  378. * @param {String} [options.name = ''] 图层名称
  379. * @param {Boolean} [options.show = true] 图层是否显示
  380. * @param {BaseClass|Boolean} [options.eventParent] 指定的事件冒泡对象默认为map对象false时不冒泡
  381. * @param {Object} [options.center] 图层自定义定位视角 {@link Map#setCameraView}
  382. * @param {Number} options.center.lng 经度值, 180 - 180
  383. * @param {Number} options.center.lat 纬度值, -90 - 90
  384. * @param {Number} [options.center.alt] 高度值
  385. * @param {Number} [options.center.heading] 方向角度值绕垂直于地心的轴旋转角度, 0至360
  386. * @param {Number} [options.center.pitch] 俯仰角度值绕纬度线旋转角度, -90至90
  387. * @param {Number} [options.center.roll] 翻滚角度值绕经度线旋转角度, -90至90
  388. * @param {Boolean} [options.flyTo] 加载完成数据后是否自动飞行定位到数据所在的区域
  389. * @export
  390. * @class SmMvtLayer
  391. * @extends {BaseLayer}
  392. */
  393. class SmMvtLayer extends BaseLayer {
  394. /**
  395. * 对应的supermap图层 Cesium.VectorTilesLayer
  396. * @type {*}
  397. * @readonly
  398. * @see http://support.supermap.com.cn:8090/webgl/docs/Documentation/VectorTilesLayer.html
  399. */
  400. get layer() {
  401. return this._mvtLayer
  402. }
  403. /**
  404. * 对象添加到地图前创建一些对象的钩子方法
  405. * 只会调用一次
  406. * @return {void}
  407. * @private
  408. */
  409. _mountedHook() {
  410. // options参考API文档:http://support.supermap.com.cn:8090/webgl/docs/Documentation/Scene.html
  411. this._mvtLayer = this._map.scene.addVectorTilesMap({
  412. canvasWidth: 512,
  413. viewer: this._map.viewer,
  414. ...this.options
  415. });
  416. this._mvtLayer.readyPromise.then(function (data) {
  417. // setPaintProperty(layerId, name, value, options)
  418. // for(var layerId in that.options.style){
  419. // that._mvtLayer.setPaintProperty(layerId, "fill-color", "rgba(255,0,0,0.8)");
  420. // }
  421. });
  422. const scene = this._map.scene;
  423. const handler = new Cesium.ScreenSpaceEventHandler(scene.canvas);
  424. handler.setInputAction((event) => {
  425. if (!this.show) {
  426. return
  427. }
  428. const position = mars3d__namespace.PointUtil.getCurrentMousePosition(scene, event.position);
  429. // 查询出相交图层的feature
  430. const features = this._mvtLayer.queryRenderedFeatures([position], {
  431. // layers: [selectLayer.id]
  432. });
  433. // eslint-disable-next-line array-callback-return
  434. features.reduce((memo, result) => {
  435. const attr = result.feature.properties;
  436. if (!attr) {
  437. // eslint-disable-next-line array-callback-return
  438. return
  439. }
  440. const content = mars3d__namespace.Util.getPopupForConfig(this.options, attr);
  441. const item = {
  442. data: attr,
  443. event: event
  444. };
  445. this._map.openPopup(position, content, item);
  446. });
  447. }, Cesium.ScreenSpaceEventType.LEFT_CLICK);
  448. this.handler = handler;
  449. }
  450. /**
  451. * 对象添加到地图上的创建钩子方法
  452. * 每次add时都会调用
  453. * @return {void}
  454. * @private
  455. */
  456. _addedHook() {
  457. this._mvtLayer.show = true;
  458. // this._mvtLayer.refresh();
  459. }
  460. /**
  461. * 对象从地图上移除的创建钩子方法
  462. * 每次remove时都会调用
  463. * @return {void}
  464. * @private
  465. */
  466. _removedHook() {
  467. if (this._mvtLayer) {
  468. this._mvtLayer.show = false;
  469. }
  470. }
  471. /**
  472. * 设置透明度
  473. * @param {Number} value 透明度
  474. * @return {void}
  475. */
  476. setOpacity(value) {
  477. if (this._mvtLayer) {
  478. this._mvtLayer.alpha = parseFloat(value);
  479. }
  480. }
  481. // 定位至数据区域
  482. flyTo(options = {}) {
  483. if (this.options.center) {
  484. return this._map.setCameraView(this.options.center, options)
  485. } else if (this.options.extent) {
  486. return this._map.flyToExtent(this.options.extent, options)
  487. } else if (this._mvtLayer) {
  488. return this._map.camera.flyTo({
  489. ...options,
  490. destination: this._mvtLayer.rectangle
  491. })
  492. }
  493. return Promise.resolve(false)
  494. }
  495. }
  496. mars3d__namespace.layer.SmMvtLayer = SmMvtLayer;
  497. // 注册下
  498. mars3d__namespace.LayerUtil.register("supermap_mvt", SmMvtLayer);
  499. exports.S3MLayer = S3MLayer;
  500. exports.SmImgLayer = SmImgLayer;
  501. exports.SmMvtLayer = SmMvtLayer;
  502. Object.defineProperty(exports, '__esModule', { value: true });
  503. }));
  504. //# sourceMappingURL=mars3d-supermap-src.js.map