diff --git a/.gitignore b/.gitignore
index 5210144b7..36acd7e0d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -7,7 +7,7 @@
/docs/mapboxgl/
/docs/openlayers/
/docs/cesium/
-
+dist-libs
/src/service/node_modules/
src/mapboxgl/node_modules/
/src/service/dist*/
diff --git a/README.md b/README.md
index 25af6f129..fad92b38d 100644
--- a/README.md
+++ b/README.md
@@ -35,7 +35,7 @@ MapGIS Client for JavaScript:是增强的MapGIS Web开发平台,集成Openla
## 一、开始
### 1、司马云
-[MapGIS Client for JavaScript](http://develop.smaryun.com:8899/)
+[MapGIS Client for JavaScript](http://develop.smaryun.com/)
> 本脚本所有的示例都在对应的演示站点有详细的说明教程
diff --git a/docs/jsdoc-config/leaflet/index.md b/docs/jsdoc-config/leaflet/index.md
index e1dab62c5..beea464f4 100644
--- a/docs/jsdoc-config/leaflet/index.md
+++ b/docs/jsdoc-config/leaflet/index.md
@@ -16,7 +16,7 @@
1. `移动设备`的支持-内部代码框架设计的时候考虑到移动设备的支持.针对移动设备天然支持.
-* 官网(website):[http://client.snanyun.com:8899/ui/index.html](http://client.snanyun.com:8899/ui/index.html)
+* 官网(website):[http://develop.smaryun.com/#/index](http://develop.smaryun.com/#/index)
* 源码(source code):[https://github.com/ParnDeedlit/WebClient-Leaflet](https://github.com/ParnDeedlit/WebClient-Leaflet)
diff --git a/docs/jsdoc-config/mapboxgl/docs.json b/docs/jsdoc-config/mapboxgl/docs.json
index adca77895..e6c4e8e05 100644
--- a/docs/jsdoc-config/mapboxgl/docs.json
+++ b/docs/jsdoc-config/mapboxgl/docs.json
@@ -21,7 +21,9 @@
"src/service/node_modules/turf-jsts",
"src/service/node_modules/@turf",
"src/service/node_modules/polygon-clipping",
- "src/service/node_modules/splaytree"
+ "src/service/node_modules/splaytree",
+ "src/mapboxgl/node_modules",
+ "src/mapboxgl/theme"
]
},
"plugins": ["plugins/markdown"],
diff --git a/docs/jsdoc-config/mapboxgl/index.md b/docs/jsdoc-config/mapboxgl/index.md
index 9e0de3b96..7e187abbf 100644
--- a/docs/jsdoc-config/mapboxgl/index.md
+++ b/docs/jsdoc-config/mapboxgl/index.md
@@ -6,16 +6,14 @@
#### MapboxGL 优点
-> leaflet是常规的的最适合常规gis开发的地图,因此核心功能就是`传统GIS`功能.
+> MapboxGL是最适合常规gis开发的地图,因此核心功能就是`传统GIS`功能.
1. `高效矢量瓦片`-真正高效实用的矢量瓦片
1. 顶级可视化-真正`顶级的可视化渲染`,mapboxGL,echartGL,KeplerGl等。
1. `高清矢量图形`- 真正顶级的高清矢量图形绘制SVG,Canvas.
1. Top级互联网技术加持 - 国内Baidu,国外Uber,Mapbox等顶级可视化巨头技术加持.
-
-
-* 官网(website):[http://client.snanyun.com:8899/ui/index.html](http://client.snanyun.com:8899/ui/index.html)
+* 官网(website):[http://develop.smaryun.com/#/index](http://develop.smaryun.com/#/index)
* 源码(source code):[https://github.com/ParnDeedlit/WebClient-MapboxGL](https://github.com/ParnDeedlit/WebClient-mapboxgl)
diff --git a/docs/jsdoc-config/openlayers/index.md b/docs/jsdoc-config/openlayers/index.md
index c61789ce8..429c0cf0b 100644
--- a/docs/jsdoc-config/openlayers/index.md
+++ b/docs/jsdoc-config/openlayers/index.md
@@ -14,7 +14,7 @@
1. 兼容性 - 兼容老的ie6789等疑难浏览器问题.
-* 官网(website):[http://client.snanyun.com:8899/ui/index.html](http://client.snanyun.com:8899/ui/index.html)
+* 官网(website):[http://develop.smaryun.com/#/index](http://develop.smaryun.com/#/index)
* 源码(source code):[https://github.com/ParnDeedlit/WebClient-openlayers](https://github.com/ParnDeedlit/WebClient-openlayers)
diff --git "a/docs/jsdoc-config/service/tutorials/1.\345\277\253\351\200\237\345\205\245\351\227\250.md" "b/docs/jsdoc-config/service/tutorials/1.\345\277\253\351\200\237\345\205\245\351\227\250.md"
new file mode 100644
index 000000000..e69de29bb
diff --git a/package.json b/package.json
index 591715135..7585777bf 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "@mapgis/webclient",
- "version": "10.5.4",
+ "version": "10.5.6",
"description": "",
"main": "index.js",
"scripts": {
@@ -35,7 +35,7 @@
"test-init": "node ./node_modules/karma/bin/karma init karma.conf.js"
},
"author": "mapgis",
- "license": "Apache2",
+ "license": "Apache-2.0",
"devDependencies": {
"babel-core": "^6.26.3",
"babel-eslint": "^10.1.0",
@@ -86,16 +86,19 @@
"@mapgis/mapbox-gl": "^1.9.0",
"@turf/turf": "^6.3.0",
"axios": "^0.18.0",
- "cesium": "^1.70.1",
+ "cesium": "1.84.0",
"d3": "^5.16.0",
"echarts": "^4.4.0",
"fast-xml-parser": "^3.17.6",
+ "fetch-ie8": "^1.5.0",
"jsdoc": "^3.6.3",
"leaflet": "^1.7.1",
"mapv": "^2.0.40",
"ol": "5.3.3",
"proj4": "2.3.15",
+ "promise-polyfill": "^8.2.3",
"qs": "^6.9.4",
- "webfont-matcher": "^1.1.0"
+ "webfont-matcher": "^1.1.0",
+ "svg-pathdata": "^6.0.0"
}
}
diff --git a/src/cesiumjs/index.js b/src/cesiumjs/index.js
index b05aeaef7..313ba64c1 100644
--- a/src/cesiumjs/index.js
+++ b/src/cesiumjs/index.js
@@ -1,4 +1,3 @@
-import { CesiumZondy } from './core/Base';
export { CesiumZondy } from './core/Base';
export * from './ui';
@@ -454,4 +453,4 @@ export {
WMTSCapabilities,
OGCWMTSInfo,
OGCWMSInfo
-};
+};
\ No newline at end of file
diff --git a/src/cesiumjs/layer/M3DLayer.js b/src/cesiumjs/layer/M3DLayer.js
index 0ad208ff1..64a88d5cc 100644
--- a/src/cesiumjs/layer/M3DLayer.js
+++ b/src/cesiumjs/layer/M3DLayer.js
@@ -78,6 +78,7 @@ export default class M3DLayer extends BaseLayer {
* @param {Boolean} [optionsParam.autoReset = true] 是否自动定位
* @param {Boolean} [optionsParam.synchronous = true] 是否异步请求
* @param {Function} [optionsParam.loaded = function] 回调函数
+ * @param {Function} [options.getDocLayers = function] 回调函数,用于获取文档中的所有图层对象
* @param {DefaultProxy} [optionsParam.proxy = defaultProxy] 代理
* @param {Boolean} [optionsParam.showBoundingVolume = false] 是否显示包围盒
* @param {Number} [optionsParam.maximumScreenSpaceError = 16] 用于控制模型显示细节 值较大将会渲染更少的贴图,进而可以提高性能,而较低的值将提高视觉质量
@@ -95,12 +96,19 @@ export default class M3DLayer extends BaseLayer {
* // layers=hide:0,1 表示只隐藏 layerIndex 为 0, 1 的图层
*
* let result = m3d.append('http://develop.smaryun.com:6163/igs/rest/g3d/ModelM3D, {
- * autoReset:false,
- * synchronous:true,
- * showBoundingVolume:false,
- * maximumScreenSpaceError:16,
- * layers:'layers=show:0',
- * loaded:callBackfunction
+ * autoReset:false,
+ * synchronous:true,
+ * showBoundingVolume:false,
+ * maximumScreenSpaceError:16,
+ * layers:'layers=show:0',
+ * loaded:callBackfunction
+ * });
+ *
+ * m3d.append('http://develop.smaryun.com:6163/igs/rest/g3d/ModelM3D', {
+ * autoReset:false,
+ * synchronous:true,
+ * layers: 'layers=show:0',
+ * getDocLayers: function (docLayers) { docLayers[0].flyTo(viewer); }
* });
*
*/
@@ -156,6 +164,10 @@ export default class M3DLayer extends BaseLayer {
synchronous = Cesium.defaultValue(options.synchronous, true);
}
+ const docReadyPromise = new Cesium.when.defer();
+
+ docReadyPromise.resolve(docLayers);
+
const _callBack = (params) => {
const _params = params;
if (Cesium.defined(options.loaded) && typeof options.loaded === 'function') {
@@ -163,12 +175,20 @@ export default class M3DLayer extends BaseLayer {
}
};
+ const _callBack2 = (params) => {
+ const _params = params;
+ if (Cesium.defined(options.getDocLayers) && typeof options.getDocLayers === 'function') {
+ options.getDocLayers(_params);
+ }
+ };
+
const parseDocInfo = (info) => {
if (info !== undefined && info.sceneInfos.length > 0) {
const { layers } = info.sceneInfos[0];
- layers.forEach((layer) => {
+ for (let i = 0; i < layers.length; i++) {
+ const layer = layers[i];
const type = parseInt(layer.layerType, 10);
- if (type === LayerType.M3DLAYER) {
+ if (type === LayerType.M3DLAYER || type === LayerType.MODELLAYER) {
const { layerRenderIndex, layerIndex, gdbpUrl, isVisible } = layer;
let isShow = true;
@@ -183,7 +203,10 @@ export default class M3DLayer extends BaseLayer {
docLayers.push(m3d);
m3d.readyPromise.then(_callBack);
}
- });
+ }
+ if (docReadyPromise !== undefined) {
+ docReadyPromise.then(_callBack2);
+ }
}
};
diff --git a/src/cesiumjs/layer/TerrainLayer.js b/src/cesiumjs/layer/TerrainLayer.js
index 293852010..6e320b190 100644
--- a/src/cesiumjs/layer/TerrainLayer.js
+++ b/src/cesiumjs/layer/TerrainLayer.js
@@ -113,8 +113,8 @@ export default class TerrainLayer extends BaseLayer {
if (info !== undefined && info.sceneInfos.length > 0) {
const { layers } = info.sceneInfos[0];
layers.forEach((layer) => {
- const { layerType, layerRenderIndex, elevationScale, range, range3D , terrainLayer } = layer;
- const { terrainColorTblInfo } = terrainLayer;
+ const { layerType, layerRenderIndex, range, range3D , terrainLayer } = layer;
+ const { terrainColorTblInfo, elevationScale } = terrainLayer;
const type = parseInt(layerType, 10);
if (type === LayerType.TERRAINLAYER) {
const sceneIndex = 0;
diff --git a/src/cesiumjs/layer/ThirdPartyLayer.js b/src/cesiumjs/layer/ThirdPartyLayer.js
index 2c38514a6..d7d4d34dc 100644
--- a/src/cesiumjs/layer/ThirdPartyLayer.js
+++ b/src/cesiumjs/layer/ThirdPartyLayer.js
@@ -140,7 +140,7 @@ export default class ThirdPartyLayer extends BaseLayer {
* let tilelayer = thirdLayer.appendBaiduMap({ptype:'sate'});
*/
appendBaiduMap(optionsParam) {
- const baiduProvider = this.viewer.imageryLayers.addImageryProvider(new Cesium.BaiduMapProvider(optionsParam));
+ const baiduProvider = this.viewer.imageryLayers.addImageryProvider(new Cesium.BaiduMapImagerProvider(optionsParam));
return baiduProvider;
}
diff --git a/src/cesiumjs/manager/AnalysisManager.js b/src/cesiumjs/manager/AnalysisManager.js
index 6865bcc2e..e3a9c36d5 100644
--- a/src/cesiumjs/manager/AnalysisManager.js
+++ b/src/cesiumjs/manager/AnalysisManager.js
@@ -556,7 +556,7 @@ export default class AnalysisManager {
* @param {Object} tileset 图层集
* @param {Array} planes 平面集
* @param {Object} options 动态剖切参数
- * @param {Object} [options.color=Color.WHITE.withAlpha(0.5)] 材质
+ * @param {Color} [options.color=Color.WHITE.withAlpha(0.5)] 材质
* @param {Number} [options.scaleHeight=2.5] 高度缩放比
* @param {Number} [options.scaleWidth=2.5] 宽度缩放比
* @param {Boolean} [options.interaction] 交互
@@ -567,8 +567,8 @@ export default class AnalysisManager {
if (!Cesium.defined(tilesets) && tilesets.length > 0) {
return undefined;
}
- var scaleHeight = defaultValue(options.scaleHeight, 2.5);
- var scaleWidth = defaultValue(options.scaleWidth, 2.5);
+ var scaleHeight = Cesium.defaultValue(options.scaleHeight, 2.5);
+ var scaleWidth = Cesium.defaultValue(options.scaleWidth, 2.5);
let material = Cesium.Color.WHITE.withAlpha(0.5);
let interaction = false;
const optionsParam = Cesium.defaultValue(options, {});
@@ -593,7 +593,7 @@ export default class AnalysisManager {
for (let i = 0; i < planes.length; i += 1) {
const normal = planes[i].normal._cartesian3;
const planeEntity = this.viewer.entities.add({
- position: Cesium.CommFunction.getPointOntoPlane(center, normal, tileSet.boundingSphere.center, new Cesium.Cartesian3),
+ position: Cesium.CommonFunction.getPointOntoPlane(center, normal, tileset.boundingSphere.center, new Cesium.Cartesian3),
plane: {
dimensions: new Cesium.Cartesian2(radius * scaleWidth, radius * scaleHeight),
material
diff --git a/src/cesiumjs/manager/LabelLayer.js b/src/cesiumjs/manager/LabelLayer.js
index 3accd5b4e..7476b0514 100644
--- a/src/cesiumjs/manager/LabelLayer.js
+++ b/src/cesiumjs/manager/LabelLayer.js
@@ -236,8 +236,9 @@ export default class LabelLayer extends BaseLayer {
* @param {String} [options.labelHorizontalOrigin] 文字注记相对于原点的水平位置 默认值: HorizontalOrigin.BOTTOM
* @param {String} [options.attribute] 属性参数 默认值: undefined
* @example
+ * let labelLayer = new LabelLayer({viewer:viewer});
* const options = { iconUrl: '/car.png', text: '注记文本', font: '14pt 楷体', labelShowBackground: true, attribute: '这是属性信息查询时可以看到' }
- * const labelIcon = webGlobe.appendLabelIconEx(110, 33, 0, options);
+ * const labelIcon = labelLayer.appendLabelIconEx(110, 33, 0, options);
* @returns {Entity} labelIcon 图标注记对象 移除通过removeEntity(entity)
*/
appendLabelIconEx(lon, lat, height, options) {
diff --git a/src/cesiumjs/manager/WebSceneControl.js b/src/cesiumjs/manager/WebSceneControl.js
new file mode 100644
index 000000000..9d2370698
--- /dev/null
+++ b/src/cesiumjs/manager/WebSceneControl.js
@@ -0,0 +1,270 @@
+import { CesiumZondy } from '../core/Base';
+
+/**
+ * 三维视图的主要类
+ * @alias WebSceneControl
+ * @constructor
+ * @class module:客户端视图管理.WebSceneControl
+ * @param {Element|String} elementId 放置视图的div的id
+ * @param {Object} [options] 包含以下属性的对象
+ * @param {String} [options.viewerMode=‘3D’] 初始视图模式默认为三维球视图 '2D'表示二维视图 'COLUMBUS_VIEW' 表示三维平面视图
+ * @param {Boolean} [options.showInfo=false] 是否显示默认的属性信息框
+ * @param {Boolean} [options.animation=true] 默认动画控制不显示
+ * @param {Boolean} [options.baseLayerPicker=true] If set to false, the BaseLayerPicker widget will not be created.
+ * @param {Boolean} [options.fullscreenButton=true] If set to false, the FullscreenButton widget will not be created.
+ * @param {Boolean} [options.vrButton=false] If set to true, the VRButton widget will be created.
+ * @param {Boolean} [options.onCopy=false] 是否禁用复制,默认为false禁用
+ * @example
+ * var webGlobe = new CesiumZondy.WebSceneControl('GlobeView');
+ *
+ * var webGlobe = new CesiumZondy.WebSceneControl('GlobeView',{showInfo:true});
+ * //或者如下
+ * var options ={
+ * showInfo:false,
+ * viewerMode:'3D',
+ * keyEventEnable:false
+ * };
+ * var webGlobe = new CesiumZondy.WebSceneControl('GlobeView',options);
+ */
+export default class WebSceneControl {
+ constructor(elementId, op) {
+ const options = Cesium.defaultValue(op, {});
+
+ /** 默认动画控制不显示 */
+ options.animation = Cesium.defaultValue(options.animation, false);
+ // 默认不显示图层控制显示
+ options.baseLayerPicker = Cesium.defaultValue(options.baseLayerPicker, false);
+ // 默认不显示全屏控制按钮
+ options.fullscreenButton = Cesium.defaultValue(options.fullscreenButton, false);
+ // 默认不显示地名查询框
+ options.geocoder = Cesium.defaultValue(options.geocoder, false);
+ // 默认不显示复位按钮
+ options.homeButton = Cesium.defaultValue(options.homeButton, false);
+ // 默认不显示信息框
+ options.infoBox = Cesium.defaultValue(options.infoBox, false);
+ // 默认不显示3D/2D选择器
+ options.sceneModePicker = Cesium.defaultValue(options.sceneModePicker, false);
+ // 默认不显示选取指示器组件
+ options.selectionIndicator = Cesium.defaultValue(options.selectionIndicator, false);
+ // 默认创建但不显示时间轴
+ options.timeline = Cesium.defaultValue(options.timeline, false);
+ // 默认不显示帮助按钮
+ options.navigationHelpButton = Cesium.defaultValue(options.navigationHelpButton, false);
+
+ options.navigationInstructionsInitiallyVisible = Cesium.defaultValue(options.navigationInstructionsInitiallyVisible, true);
+ // 默认不显示渲染错误信息面板
+ options.showRenderLoopErrors = Cesium.defaultValue(options.showRenderLoopErrors, false);
+ // 默认场景为三维球面视图
+ options.sceneMode = Cesium.defaultValue(options.sceneMode, Cesium.SceneMode.SCENE3D);
+ // 默认地图投影为web 墨卡托
+ options.mapProjection = Cesium.defaultValue(options.mapProjection, new Cesium.WebMercatorProjection());
+ // 默认可视化数据源集合
+ options.dataSources = Cesium.defaultValue(options.dataSources, new Cesium.DataSourceCollection());
+ // 默认支持阴影
+ options.shadows = Cesium.defaultValue(options.shadows, false);
+
+ // 使用 ThreeJS 默认要关闭自动渲染
+ if (this._useThreeJs) {
+ options.useDefaultRenderLoop = false;
+ }
+
+ this._threeContainer = undefined;
+
+ // 管理append添加的图层组
+ this._appendCollection = [];
+
+ // 默认支持键盘事件
+ this._keyEventEnable = Cesium.defaultValue(options.keyEventEnable, true);
+ // 创建默认视图对象
+ this._viewer = new Cesium.Viewer(elementId, options);
+
+ //隐藏版权信息
+ this._viewer.cesiumWidget.creditContainer.style.display = 'none';
+
+ // 场景对象
+ this._scene = this._viewer.scene;
+
+ this._screenSpaceEventHandler = new Cesium.ScreenSpaceEventHandler(this._viewer.scene.canvas);
+
+ this._elementID = elementId;
+
+ this._popupContain = []; // 用于管理多个popup,主要考虑到多个popup场景变化时需响应其事件,改变其位置
+
+ const screenSpaceCameraController = this._viewer.scene.screenSpaceCameraController;
+ //默认关闭hdr
+ this._viewer.scene.highDynamicRange = false;
+ screenSpaceCameraController.minimumZoomDistance = 1;
+ screenSpaceCameraController.maximumZoomDistance = 2400000000000000;
+ this._viewer.canvas.onclick = function () {
+ this.focus();
+ };
+
+ this._cameraParameter = {};
+ const flags = {
+ looking: false,
+ rotateLeft: false,
+ rotateRight: false,
+ moveUp: false,
+ moveDown: false,
+ moveLeft: false,
+ moveRight: false,
+ goHome: false,
+ wireFrame: false,
+ showFPS: false
+ };
+
+ //与activex球保持一致
+ function getFlagForKeyCode(keyCode) {
+ switch (keyCode) {
+ case 'W'.charCodeAt(0): //向下平移镜头
+ return 'moveDown';
+ case 'S'.charCodeAt(0): //向上平移镜头
+ return 'moveUp';
+ case 'A'.charCodeAt(0): //向右平移镜头
+ return 'moveRight';
+ case 'D'.charCodeAt(0): //向左平移镜头
+ return 'moveLeft';
+ case 'Q'.charCodeAt(0): //向右旋转镜头
+ return 'rotateRight';
+ case 'E'.charCodeAt(0): //向左旋转镜头
+ return 'rotateLeft';
+ case 'Z'.charCodeAt(0): //空格键复位
+ return 'goHome';
+ case 'G'.charCodeAt(0): //G键显示网
+ return 'wireFrame';
+ case 'F'.charCodeAt(0): //F键显示帧率
+ return 'showFPS';
+ default:
+ return undefined;
+ }
+ }
+
+ document.addEventListener(
+ 'keydown',
+ function (e) {
+ const flagName = getFlagForKeyCode(e.keyCode);
+ if (typeof flagName !== 'undefined') {
+ flags[flagName] = true;
+ }
+ },
+ false
+ );
+ document.addEventListener(
+ 'keyup',
+ function (e) {
+ const flagName = getFlagForKeyCode(e.keyCode);
+ if (typeof flagName !== 'undefined') {
+ flags[flagName] = false;
+ }
+ },
+ false
+ );
+
+ this._shouldAnimate = Cesium.defaultValue(options.shouldAnimate, false); //记录全局是否允许动画
+ var that = this;
+
+ this._viewer.clock.onTick.addEventListener(function () {
+ //获取相机高度
+ if (that.keyEventEnable) {
+ const position = that._viewer.camera.position;
+ const cameraHeight = that._viewer.scene.globe.ellipsoid.cartesianToCartographic(position).height;
+ const moveRate = cameraHeight / 40.0;
+ if (flags.rotateLeft) {
+ that._viewer.camera.rotateLeft(0.01);
+ }
+ if (flags.rotateRight) {
+ that._viewer.camera.rotateRight(0.01);
+ }
+ if (flags.moveUp) {
+ that._viewer.camera.moveBackward(moveRate);
+ }
+ if (flags.moveDown) {
+ that._viewer.camera.moveForward(moveRate);
+ }
+ if (flags.moveLeft) {
+ that._viewer.camera.moveLeft(moveRate);
+ }
+ if (flags.moveRight) {
+ that._viewer.camera.moveRight(moveRate);
+ }
+ if (flags.goHome) {
+ that._viewer.camera.flyTo({
+ destination: Cesium.Cartesian3.fromDegrees(104, 30, 15682725)
+ });
+ }
+ if (flags.wireFrame) {
+ var bShowWireframe = that._viewer.scene.globe._surface.tileProvider._debug.wireframe;
+ that._viewer.scene.globe._surface.tileProvider._debug.wireframe = !bShowWireframe;
+ flags.wireFrame = false;
+ }
+ if (flags.showFPS) {
+ var bShowFPS = that._viewer.scene.debugShowFramesPerSecond;
+ that._viewer.scene.debugShowFramesPerSecond = !bShowFPS;
+ flags.showFPS = false;
+ }
+ }
+ });
+ /**
+ * 禁用右键菜单
+ */
+ document.oncontextmenu = function () {
+ event.returnValue = false;
+ };
+ // /**
+ // * 禁用选中功能
+ // */
+ // document.onselectstart = function(){
+ // event.returnValue = false;
+ // };
+ /**
+ * 禁用复制功能
+ */
+ document.oncopy = function () {
+ event.returnValue = that._onCopy;
+ };
+
+ this.scene.skyAtmosphere.showGroundAtmosphere = false;
+ this._isRecoverExplosion = false;
+ }
+
+ /**
+ * 视图
+ * @memberof WebSceneControl.prototype
+ * @type {Viewer}
+ * @readonly
+ */
+ get viewer() {
+ return this._viewer;
+ }
+
+ /**
+ * 场景
+ * @memberof WebSceneControl.prototype
+ * @readonly
+ * @type {Scene}
+ */
+ get scene() {
+ return this._scene;
+ }
+
+ /**
+ * 事件句柄
+ * @memberof WebSceneControl.prototype
+ * @readonly
+ */
+ get screenSpaceEventHandler() {
+ return this._screenSpaceEventHandler;
+ }
+
+ /**
+ * 当前椭球
+ * @memberof WebSceneControl.prototype
+ * @type {Ellipsoid}
+ * @readonly
+ */
+ get ellipsoid() {
+ return this._viewer.scene.globe.ellipsoid;
+ }
+}
+
+CesiumZondy.WebSceneControl = WebSceneControl;
diff --git a/src/cesiumjs/manager/index.js b/src/cesiumjs/manager/index.js
index 3e6bb68e2..4dd2436f7 100644
--- a/src/cesiumjs/manager/index.js
+++ b/src/cesiumjs/manager/index.js
@@ -8,6 +8,7 @@ import LabelLayer from "./LabelLayer";
import MouseEventManager from "./MouseEventManager";
import PopupController from "./PopupController";
import SceneManager from "./SceneManager";
+import WebSceneControl from './WebSceneControl';
export {
AnalysisManager,
@@ -19,4 +20,5 @@ export {
MouseEventManager,
PopupController,
SceneManager,
+ WebSceneControl
};
\ No newline at end of file
diff --git a/src/cesiumjs/overlay/MapvLayer.js b/src/cesiumjs/overlay/MapvLayer.js
index d180714e4..9a08ec0ff 100644
--- a/src/cesiumjs/overlay/MapvLayer.js
+++ b/src/cesiumjs/overlay/MapvLayer.js
@@ -15,7 +15,7 @@ var idIndex = 0;
* @param {Boolean} [mapVOptions.cesium.postRender=false] 是否实时渲染
* @param {Boolean} [mapVOptionscesium.cesium.postRenderFrame=30] 每间隔多少帧渲染一次
* @param container - {Element} 外部传入的div;外接的方式使用mapv
- * @example
+ * @example
* // 构建对应的dataset
var dataSet = new mapv.DataSet(data);
@@ -140,7 +140,7 @@ export default class MapvLayer {
this.scene.camera.moveStart.removeEventListener(this.postStartEvent, this);
this.scene.camera.moveEnd.removeEventListener(this.postEndEvent, this);
} else {
- let handler = this.handler;
+ let handler = this.handler;
if (handler) {
handler.removeInputAction(this.innerMoveEnd, Cesium.ScreenSpaceEventType.WHEEL);
handler.removeInputAction(this.innerMoveStart, Cesium.ScreenSpaceEventType.LEFT_DOWN);
@@ -274,10 +274,19 @@ export default class MapvLayer {
canvas.style.pointerEvents = 'none';
canvas.style.zIndex = this.mapVOptions.zIndex || 100;
- canvas.width = parseInt(this.map.canvas.width);
- canvas.height = parseInt(this.map.canvas.height);
- canvas.style.width = this.map.canvas.style.width;
- canvas.style.height = this.map.canvas.style.height;
+ // canvas.width = parseInt(this.map.canvas.width);
+ // canvas.height = parseInt(this.map.canvas.height);
+ // canvas.style.width = this.map.canvas.style.width;
+ // canvas.style.height = this.map.canvas.style.height;
+ canvas.width =
+ parseInt(this.map.canvas.width) ||
+ parseInt(this.map.container.offsetWidth);
+ canvas.height =
+ parseInt(this.map.canvas.height) ||
+ parseInt(this.map.container.offsetHeight);
+ canvas.style.width = parseInt(this.map.container.offsetWidth) + "px";
+ canvas.style.height = parseInt(this.map.container.offsetHeight) + "px";
+
var devicePixelRatio = this.devicePixelRatio;
if (this.mapVOptions.context == '2d') {
canvas.getContext(this.mapVOptions.context).scale(devicePixelRatio, devicePixelRatio);
@@ -296,10 +305,18 @@ export default class MapvLayer {
canvas.style.pointerEvents = 'none';
canvas.style.zIndex = this.mapVOptions.zIndex || 100;
- canvas.width = parseInt(this.map.canvas.width);
- canvas.height = parseInt(this.map.canvas.height);
- canvas.style.width = this.map.canvas.style.width;
- canvas.style.height = this.map.canvas.style.height;
+ // canvas.width = parseInt(this.map.canvas.width);
+ // canvas.height = parseInt(this.map.canvas.height);
+ // canvas.style.width = this.map.canvas.style.width;
+ // canvas.style.height = this.map.canvas.style.height;
+ canvas.width =
+ parseInt(this.map.canvas.width) ||
+ parseInt(this.map.container.offsetWidth);
+ canvas.height =
+ parseInt(this.map.canvas.height) ||
+ parseInt(this.map.container.offsetHeight);
+ canvas.style.width = parseInt(this.map.container.offsetWidth) + "px";
+ canvas.style.height = parseInt(this.map.container.offsetHeight) + "px";
var devicePixelRatio = this.devicePixelRatio;
if (this.mapVOptions.context == '2d') {
canvas.getContext('2d').scale(devicePixelRatio, devicePixelRatio);
@@ -378,10 +395,18 @@ export default class MapvLayer {
canvas.style.position = 'absolute';
canvas.style.top = '0px';
canvas.style.left = '0px';
- canvas.width = parseInt(this.map.canvas.width);
- canvas.height = parseInt(this.map.canvas.height);
+ // canvas.width = parseInt(this.map.canvas.width);
+ // canvas.height = parseInt(this.map.canvas.height);
//canvas.style.width = this.map.canvas.style.width;
//canvas.style.height = this.map.canvas.style.height;
+ canvas.width =
+ parseInt(this.map.canvas.width) ||
+ parseInt(this.map.container.offsetWidth) * this.devicePixelRatio;
+ canvas.height =
+ parseInt(this.map.canvas.height) ||
+ parseInt(this.map.container.offsetHeight) * this.devicePixelRatio;
+ canvas.style.width = parseInt(this.map.container.offsetWidth) + 'px';
+ canvas.style.height = parseInt(this.map.container.offsetHeight) + 'px';
var devicePixelRatio = this.devicePixelRatio;
if (this.mapVOptions.context == '2d') {
canvas.getContext('2d').scale(devicePixelRatio, devicePixelRatio);
diff --git a/src/cesiumjs/overlay/PopupLayer.js b/src/cesiumjs/overlay/PopupLayer.js
index 3d1b1f100..e8c34f718 100644
--- a/src/cesiumjs/overlay/PopupLayer.js
+++ b/src/cesiumjs/overlay/PopupLayer.js
@@ -1,7 +1,6 @@
import { CesiumZondy } from '../core/Base';
import { updataPopupPosition } from './popup/popup';
-import Cesium from '../../../node_modules/cesium/Source/Cesium';
var popupsIdIndex = 0;
@@ -72,6 +71,7 @@ export default class PopupLayer {
this.popupContentId = options.popupContentId || 'cesium-popup-content-id-' + popupsIdIndex++;
this.options.postRender = this.options.postRender === undefined ? true : this.options.postRender;
+ this.Cesium = options.Cesium || window['Cesium'];
this.scene = map.scene;
this.camera = map.camera;
@@ -80,10 +80,10 @@ export default class PopupLayer {
if (options.callback) {
const { onShow, onHide } = options.callback;
this.onShow = onShow;
- this.onHide = onHide
+ this.onHide = onHide;
}
- let ScreenSpaceEventHandler = Cesium.ScreenSpaceEventHandler || window['Cesium'].ScreenSpaceEventHandler;
+ let ScreenSpaceEventHandler = this.Cesium.ScreenSpaceEventHandler || window['Cesium'].ScreenSpaceEventHandler;
this.handler = new ScreenSpaceEventHandler(this.scene.canvas);
@@ -96,7 +96,7 @@ export default class PopupLayer {
this.cartesian =
this.cartesian ||
this.position.cartesian ||
- Cesium.Cartesian3.fromDegrees(this.position.longitude, this.position.latitude, this.position.height);
+ this.Cesium.Cartesian3.fromDegrees(this.position.longitude, this.position.latitude, this.position.height);
let vc = this.map.container;
let cesumWidgetContainer = undefined;
@@ -136,18 +136,34 @@ export default class PopupLayer {
let infoDiv = window.document.createElement('div');
infoDiv.id = this.popupId;
infoDiv.style.display = 'none';
- infoDiv.innerHTML =
- '
';
+ if (typeof this.container === 'string') {
+ infoDiv.innerHTML =
+ '';
+ } else {
+ let popupContentDiv = window.document.createElement('div');
+ popupContentDiv.id = this.popupContentId;
+ popupContentDiv.className = 'cesium-popup';
+ let popupContentWrapperDiv = window.document.createElement('div');
+ popupContentWrapperDiv.className = 'cesium-popup-content-wrapper';
+ popupContentWrapperDiv.appendChild(this.container);
+ popupContentDiv.appendChild(popupContentWrapperDiv);
+
+ let tipContainerDiv = window.document.createElement('div');
+ tipContainerDiv.className = 'cesium-popup-tip-container';
+ let tipDiv = window.document.createElement('div');
+ tipDiv.className = 'cesium-popup-tip';
+ tipContainerDiv.appendChild(tipDiv);
+ popupContentDiv.appendChild(tipContainerDiv);
+ infoDiv.appendChild(popupContentDiv);
+ }
+
let close = window.document.createElement('div');
close.className = 'cesium-popup-close-button';
close.addEventListener('click', () => self.hide());
@@ -163,7 +179,7 @@ export default class PopupLayer {
bindEvent() {
let self = this;
- this.handler.setInputAction(this.movement, Cesium.ScreenSpaceEventType.LEFT_CLICK);
+ this.handler.setInputAction(this.movement, this.Cesium.ScreenSpaceEventType.LEFT_CLICK);
if (!this.map) {
return;
}
@@ -172,8 +188,8 @@ export default class PopupLayer {
this.map.scene.postRender.addEventListener(() => self.update());
} else {
this.map.camera.changed.addEventListener(() => self.update());
- this.handler.setInputAction(this.moveStart, Cesium.ScreenSpaceEventType.LEFT_DOWN);
- this.handler.setInputAction(this.moveEnd, Cesium.ScreenSpaceEventType.LEFT_UP);
+ this.handler.setInputAction(this.moveStart, this.Cesium.ScreenSpaceEventType.LEFT_DOWN);
+ this.handler.setInputAction(this.moveEnd, this.Cesium.ScreenSpaceEventType.LEFT_UP);
this.map.scene.camera.moveEnd.addEventListener(() => self.update());
}
}
@@ -195,8 +211,8 @@ export default class PopupLayer {
movement(movement) {
var pickedPrimitive = this.map.scene.pick(movement.position);
- var pickedEntity = Cesium.defined(pickedPrimitive) ? pickedPrimitive.id : undefined;
- if (Cesium.defined(pickedEntity) /* && Cesium.defined(pickedEntity.billboard) */) {
+ var pickedEntity = this.Cesium.defined(pickedPrimitive) ? pickedPrimitive.id : undefined;
+ if (this.Cesium.defined(pickedEntity) /* && Cesium.defined(pickedEntity.billboard) */) {
if (this.position && this.position.entity) {
pickedPrimitive.id === this.position.entity.id;
this.show();
diff --git a/src/cesiumjs/overlay/popup/popup.js b/src/cesiumjs/overlay/popup/popup.js
index a95127408..0fc8388fa 100644
--- a/src/cesiumjs/overlay/popup/popup.js
+++ b/src/cesiumjs/overlay/popup/popup.js
@@ -1,5 +1,3 @@
-import Cesium from '../../../../node_modules/cesium/Source/Cesium';
-
/**
* @description 用来调整相机视角的时候设置对应的
* @param {Viewer} viewer Cesium的viewer对象
@@ -10,56 +8,57 @@ import Cesium from '../../../../node_modules/cesium/Source/Cesium';
* @param {Object} [options.latitude] 传入的纬度,内部换算笛卡尔积
*/
export function updataPopupPosition(viewer, cartesian, popupId, popupContentId, options) {
- if(!cartesian) return ;
+ if (!cartesian) return;
let scene = viewer.scene;
let camera = viewer.camera;
let rect = camera.computeViewRectangle();
- const south = Cesium.Math.toDegrees(rect.south)
- const north = Cesium.Math.toDegrees(rect.north)
- const east = Cesium.Math.toDegrees(rect.east)
- const west = Cesium.Math.toDegrees(rect.west)
+ let Cesium = options.Cesium || window['Cesium'];
+ const south = Cesium.Math.toDegrees(rect.south);
+ const north = Cesium.Math.toDegrees(rect.north);
+ const east = Cesium.Math.toDegrees(rect.east);
+ const west = Cesium.Math.toDegrees(rect.west);
let carto, longitude, latitude;
- if(options && options.longitude && options.latitude){
+ if (options && options.longitude && options.latitude) {
longitude = options.position.longitude;
latitude = options.position.latitude;
if (longitude < west || longitude > east || latitude > north || latitude < south) {
- popup.style.display = "none";
+ popup.style.display = 'none';
return;
}
} else {
- carto = Cesium.Ellipsoid.WGS84.cartesianToCartographic(cartesian);
+ carto = Cesium.Ellipsoid.WGS84.cartesianToCartographic(cartesian);
longitude = Cesium.Math.toDegrees(carto.longitude);
latitude = Cesium.Math.toDegrees(carto.latitude);
}
-
+
var px_position = Cesium.SceneTransforms.wgs84ToWindowCoordinates(scene, cartesian);
-
- if(!px_position) return;
+
+ if (!px_position) return;
var res = false;
var e = cartesian,
i = camera.position,
n = scene.globe.ellipsoid.cartesianToCartographic(i).height;
- if (!(n += 1 * scene.globe.ellipsoid.maximumRadius, Cesium.Cartesian3.distance(i, e) > n)) {
+ if (!((n += 1 * scene.globe.ellipsoid.maximumRadius), Cesium.Cartesian3.distance(i, e) > n)) {
res = true;
}
if (longitude < west || longitude > east || latitude > north || latitude < south) {
res = false;
}
-
+
let popup = window.document.getElementById(popupId);
- if(!popup) return;
+ if (!popup) return;
if (res) {
- popup.style.display = "block";
+ popup.style.display = 'block';
var trackPopUpContent = window.document.getElementById(popupContentId);
var popw = document.getElementById(popupContentId).offsetWidth;
var poph = document.getElementById(popupContentId).offsetHeight;
- trackPopUpContent.style.left = px_position.x - (popw / 2) + "px";
- trackPopUpContent.style.top = px_position.y - (poph - 10) + "px";
+ trackPopUpContent.style.left = px_position.x - popw / 2 + 'px';
+ trackPopUpContent.style.top = px_position.y - (poph - 10) + 'px';
} else {
- popup.style.display = "none";
+ popup.style.display = 'none';
}
-}
\ No newline at end of file
+}
diff --git a/src/cesiumjs/render/VectorTileLayer.js b/src/cesiumjs/render/VectorTileLayer.js
index 4e9779922..627539e07 100644
--- a/src/cesiumjs/render/VectorTileLayer.js
+++ b/src/cesiumjs/render/VectorTileLayer.js
@@ -4,7 +4,6 @@ import { getLayers, getFonts, getVectorTileSource, getSpritePng } from './vector
import VectorTileProvider from './vectortile/VectorTileProvider';
import VectorTileStyle from './vectortile/MapgisVectorTileStyle';
import axios from 'axios';
-import { find } from 'ol/array';
/**
* @author 基础平台/创新中心 潘卓然 ParnDeedlit
@@ -138,6 +137,10 @@ export class VectorTileLayer {
);
}
+ getLayer() {
+ return self.provider ? self.provider : undefined;
+ }
+
/**
* 首先构造矢量瓦片样式,再添加图层
* @function module:客户端渲染.VectorTileLayer.prototype.addLayer
diff --git a/src/leaflet/core/Base.js b/src/leaflet/core/Base.js
index 4eb0b10ea..a5df7f68e 100644
--- a/src/leaflet/core/Base.js
+++ b/src/leaflet/core/Base.js
@@ -8,9 +8,13 @@ import L from "leaflet";
L.zondy = L.zondy || {};
L.zondy.control = L.zondy.control || {};
+L.mapgis = L.mapgis || {};
+
/**
* @module 客户端可视化
*/
L.zondy.Clientview = L.zondy.Clientview || {};
L.CRS = L.CRS || {};
+
+export {L};
diff --git a/src/leaflet/layer/MapLayer.js b/src/leaflet/layer/MapLayer.js
new file mode 100644
index 000000000..ebd85ba4e
--- /dev/null
+++ b/src/leaflet/layer/MapLayer.js
@@ -0,0 +1,148 @@
+import { newGuid } from '../../service/common/Util';
+import { L } from '../core/Base.js';
+
+/**
+ * @class L.mapgis.MapLayer
+ * @classdesc 新版igserver地图服务加载类
+ * @extends L.TileLayer
+ * @example
+ //地图容器
+ var map = L.map('leaf_map', {
+ //添加缩放控件
+ zoomControl: true,
+ //投影坐标系
+ crs: L.CRS.EPSG4326,
+ //中心点[y,x]
+ center: [(30.86431739220 + 30.3383275329) / 2, (114.57307983700002 + 113.97889584400014)/ 2],//武汉建筑
+ //最大级数
+ maxZoom: 10,
+ //最小级数
+ minZoom: 7,
+ //显示级数
+ zoom: 8
+ });
+
+ //创建地图图层
+ var mapLayer = new L.mapgis.MapLayer("http://192.168.199.71:8089/igs/rest/services/layertest/武汉建筑/MapServer", {
+ layers:'show:0',
+ imageFormat: 'jpg',
+ filters:{"0":{"where":"Floor>10"}},
+ styles: {"0":{"displayRegionBorder":true}},
+ imageTransparent:false,
+ //只显示一个图层,不平铺显示
+ noWrap: true
+ }).addTo(map);
+ */
+
+var MapLayer = L.TileLayer.extend({
+ options: {
+ imageFormat: null,
+ imageHeight: 512,
+ imageWidth: 512,
+ guid: null,
+ imageTransparent: null,
+ filters: null,
+ styles: null,
+ layers: null,
+ crs: null,
+ isAntialiasing: null
+ },
+ /**
+ *
+ * @param url - {String} 必选,地图服务的基地址。例如"http://192.168.199.71:8089/igs/rest/services/layertest/武汉建筑/MapServer".
+ * @param options - {Object} 属性键值对,地图属性字段。
+ * @param {String} [options.imageFormat = 'png'] 可选,图片的格式,支持png|jpg|gif。
+ * @param {Object} [options.filters = null] 可选,图层的过滤信息。例如,{"0":{"where":"Floor>10"}}。
+ * @param {Object} [options.styles = null] 可选,图层的样式。例如,{"0":{"displayRegionBorder":true}}。
+ * @param {String} [options.layers = null] 可选,指定需要被取图的图层序列号。格式:show/hide/include/exclude: layerid1,layerid2。
+ 1 show:仅仅显示指定了图层序号的图层
+ 2 hide :显示除hide参数指定图层外所有的图层
+ 3 include:除显示默认图层(地图文档内图层状态为可见的图层)外,另追加这些被指定的图 层显示,追加的这些图层必须为地图中包含的图层。
+ 4 exclude: 从默认图层列表里删除这些被指定的图层后,进行显示
+ * @param {String} [options.crs = null] 可选,投影空间参照系,支持mapgis参照系名称和epsg编号。
+ * @param {Number} [options.imageHeight = 512] 可选,图片的高度。
+ * @param {Number} [options.imageWidth = 512] 可选,图片的宽度。
+ * @param {Boolean} [options.isAntialiasing = false] 可选,返回的图片是否抗锯齿。
+ * @param {Boolean} [options.imageTransparent = true] 可选,返回的图片是否透明。
+ * @param {String} [options.guid = newGuid()] 可选。唯一ID,用户标识地图文档。
+ *
+ */
+ initialize: function (url, options) {
+ this.url = encodeURI(url + '/image');
+ var imageHeight = options.imageHeight || 512;
+ var imageWidth = options.imageWidth || 512;
+ options.tileSize = window.L.point(imageWidth, imageHeight);
+ // console.log('maplayer_initialize', options);
+ L.TileLayer.prototype.initialize.apply(this, arguments);
+ L.setOptions(this, options);
+ L.stamp(this);
+ },
+
+ onAdd: function (map) {
+ this._crs = map.options.crs;
+ this._initLayerUrl();
+ L.TileLayer.prototype.onAdd.call(this, map);
+ },
+
+ getTileUrl: function (coords) {
+ var tileBounds = this._tileCoordsToBounds(coords);
+ var nw = this._crs.project(tileBounds.getNorthWest());
+ var se = this._crs.project(tileBounds.getSouthEast());
+ var params = '&bbox=' + nw.x + ',' + se.y + ',' + se.x + ',' + nw.y;
+ return this._layerUrl + encodeURI(params);
+ },
+
+ _initLayerUrl: function () {
+ var vm = this;
+ var layerUrl = vm.url + '?';
+ layerUrl += encodeURI(vm._initAllRequestParams().join('&'));
+ this._layerUrl = layerUrl;
+ // console.log('maplayer__initLayerUrl', layerUrl);
+ },
+
+ _initAllRequestParams: function () {
+ var vm = this,
+ options = vm.options || {},
+ params = [];
+
+ // console.log('maplayer_initAllRequestParams', options);
+ var imageHeight = options.imageHeight || 512;
+ var imageWidth = options.imageWidth || 512;
+ params.push('size=' + imageWidth + ',' + imageHeight);
+
+ var guid = options.guid || newGuid();
+ params.push('clientId=' + guid);
+
+ if (options.imageFormat) {
+ params.push('format=' + options.imageFormat);
+ }
+ if (options.layers) {
+ params.push('layers=' + options.layers);
+ }
+ if (options.filters) {
+ params.push('layerFilters=' + JSON.stringify(options.filters));
+ }
+ if (options.styles) {
+ params.push('layerStyles=' + JSON.stringify(options.styles));
+ }
+ if (options.imageTransparent !== undefined && options.imageTransparent !== null) {
+ params.push('transparent=' + options.imageTransparent);
+ }
+
+ if (options.crs) {
+ params.push('projectionSrs=' + options.crs);
+ }
+
+ if (options.isAntialiasing !== undefined && options.isAntialiasing !== null) {
+ params.push('isAntialiasing=' + options.isAntialiasing);
+ }
+
+ params.push('f=image');
+
+ return params;
+ }
+});
+
+export { MapLayer };
+L.mapgis.MapLayer = MapLayer;
+export { L };
diff --git a/src/leaflet/layer/TileLayer.js b/src/leaflet/layer/TileLayer.js
new file mode 100644
index 000000000..d30f0ad20
--- /dev/null
+++ b/src/leaflet/layer/TileLayer.js
@@ -0,0 +1,62 @@
+import {L} from '../core/Base.js';
+
+/**
+ * @class L.mapgis.TileLayer
+ * @classdesc 新版igserver瓦片服务加载类
+ * @extends L.TileLayer
+ * @example
+ //地图容器
+ var map = L.map("leaf_map", {
+ //添加缩放控件
+ zoomControl: true,
+ //投影坐标系
+ crs: L.CRS.EPSG4326,
+ center: [(29.969811000000004 + 31.363327503204342) / 2, (113.69534616 + 115.07704496383667) / 2],
+ //最大级数
+ maxZoom: 17,
+ //最小级数
+ minZoom: 7,
+ //显示级数
+ zoom: 8,
+ });
+
+ //瓦片地图
+ var layer = new L.mapgis.TileLayer(
+ "http://192.168.199.71:8089/igs/rest/services/layertest/栅格瓦片/TileServer",
+ {
+ noWrap: true
+ }
+ ).addTo(map);
+ */
+
+var TileLayer = L.TileLayer.extend({
+ options: {
+ // blankTile:null
+ },
+
+ initialize: function(url,options){
+ this.url = encodeURI(url + "/tileImage");
+ L.TileLayer.prototype.initialize.apply(this, arguments);
+ L.setOptions(this,options);
+ L.stamp(this);
+ },
+
+ onAdd:function(map) {
+ L.TileLayer.prototype.onAdd.call(this,map);
+ },
+
+ getTileUrl: function (coords) {
+ // var vm = this,
+ // options = vm.options || {};
+ var tileUrl = this.url + '/{z}/{y}/{x}?f=image';
+ // if(options.blankTile !== undefined && options.blankTile !== null){
+ // tileUrl = tileUrl + '&blankTile=' + options.blankTile;
+ // }
+ tileUrl = tileUrl.replace('{x}', coords.x.toString()).replace('{y}', coords.y.toString()).replace('{z}', coords.z.toString());
+ return tileUrl;
+ }
+});
+
+export {TileLayer};
+L.mapgis.TileLayer = TileLayer;
+export {L};
diff --git a/src/leaflet/layer/index.js b/src/leaflet/layer/index.js
index ddab5ac91..3ed60a57f 100644
--- a/src/leaflet/layer/index.js
+++ b/src/leaflet/layer/index.js
@@ -1,5 +1,7 @@
import {MapDocLayer} from './mapDocLayer';
import {MapTileLayer} from './mapTileLayer';
+import {MapLayer} from './MapLayer';
+import {TileLayer} from './TileLayer';
import {MapWMTSLayer} from './mapWmtsLayer';
import {GeneralWMTSLayer} from './generalWmtsLayer';
import {MapVectorLayer} from './mapVectorLayer';
@@ -20,6 +22,8 @@ import {
export {MapDocLayer};
export {MapTileLayer};
+export {MapLayer};
+export {TileLayer};
export {MapWMTSLayer};
export {GeneralWMTSLayer};
export {MapVectorLayer};
diff --git a/src/leaflet/layer/mapWmtsLayer.js b/src/leaflet/layer/mapWmtsLayer.js
index b2d0b0135..752b99d4f 100644
--- a/src/leaflet/layer/mapWmtsLayer.js
+++ b/src/leaflet/layer/mapWmtsLayer.js
@@ -1,5 +1,5 @@
-import {Zondy} from '../../service/common/Base';
-import {L} from 'leaflet';
+import { Zondy } from '../../service/common/Base';
+import { L } from 'leaflet';
/**
* @author 基础平台/产品2部 龚跃健
@@ -19,6 +19,8 @@ import {L} from 'leaflet';
* @param {String} [option.format = image/png ] 可选。图块输出格式。image/png或image/jpeg
* @param {String} [option.tileSize = 256] 可选。瓦片大小
* @param {String} [option.version = 1.0.0] 可选。WMTS版本
+ * @param {String} [option.tokenKey = ""] 可选。token的key值(token/tk)
+ * @param {String} [option.token = ""] 可选。token值
* @example
new Zondy.Map.MapWMTSLayer({
//IGServer所在ip地址
@@ -34,116 +36,123 @@ import {L} from 'leaflet';
})
*/
var MapWMTSLayer = window.L.TileLayer.extend({
- options: {
- version: '1.0.0',
- style: '',
- serverName: '',//服务名
- tilematrixSet: '', //矩阵集名称
- layer: '', //图层名
- format: 'image/png',
- tileSize: 256,
- attribution: "Zondy WMTS Data",
- noWrap: true
- },
- //var layer3 = new ZondyMapWMTSLayer("http://localhost:6163/igs/rest/ogc/WMTSServer", { tilematrixSet: "EPSG:4326_世界地图经纬度LEVEL7_028mm_GB", layer: 'World_level7_WMTS' }).addTo(mymap);
- //
- initialize: function (options) { // (String, Object)
- if (options.url) {
- if (options.url.indexOf("?") > -1) {
- this._url = options.url.split("?")[0]
- } else {
- this._url = options.url
- }
- } else {
- var partUrl = '/igs/rest/ogc/WMTSServer'
- if (options.serverName && options.serverName !== '') {
- partUrl = '/igs/rest/ogc/' + options.serverName + '/WMTSServer'
- }
- var domain = options && options.domain ? options.domain : '';
- if (domain === '') {
- this.networkProtocol = options.networkProtocol !== undefined ? options.networkProtocol : location.protocol.split(":")[0] || "http";
- var ip = options && options.ip ? options.ip : 'localhost';
- var port = options && options.port ? options.port : '6163';
- this._url = encodeURI(this.networkProtocol + '://' + ip + ':' + port + partUrl);
- } else {
- this._url = encodeURI(domain + partUrl);
- }
- }
- if (this._url.toLowerCase().indexOf("ime-cloud") > -1) {//吉威的数据
- this._url += '?service=WMTS&REQUEST=GetTile'
- } else {
- this._url += '?service=WMTS&request=GetTile'
- }
- this.options.origin = options.origin ? options.origin : null;
- window.L.setOptions(this, options);
- },
- onAdd: function (map) {
- this._crs = this.options.crs || map.options.crs;
- let bounds = this._crs.projection.bounds;
- let northWest = [bounds.min.x, bounds.max.y]
- this._origin = this.options.origin ? this.options.origin : northWest
- window.L.TileLayer.prototype.onAdd.call(this, map);
- },
- /**
- * @private
- * @function Zondy.Map.MapWMTSLayer.prototype.getTileUrl
- * @description 根据行列号获取瓦片地址。考虑发布的wmts的瓦片不按左上角为原点的情况,需另外处理
- * @param coords - {Object} 行列号
- * @return {string} 瓦片地址
- */
- getTileUrl: function (coords) { // (Point, Number) -> String
- // var tileBounds = this._tileCoordsToBounds(coords);
- // var ne = this._crs.project(tileBounds.getNorthEast());
- // var sw = this._crs.project(tileBounds.getSouthWest());
- // var tileSize = this.options.tileSize;
- // var resolution = Math.max(Math.abs(ne.x - sw.x) / tileSize, Math.abs(ne.y - sw.y) / tileSize);
- //
- // var centerPnt = [(ne.x + sw.x) / 2, (ne.y + sw.y) / 2];
- // var dx = centerPnt[0] - (this._origin)[0];
- // var dy = centerPnt[1] - (this._origin)[1];
- //
- // var xGrid = -1e8;
- // var yGrid = -1e8;
- //
- // xGrid = Math.floor(dx / (tileSize * resolution));
- // if (this.options.yAxis === 'down') {
- // yGrid = Math.floor(-dy / (tileSize * resolution));
- // } else {
- // yGrid = Math.floor(dy / (tileSize * resolution));
- // }
+ options: {
+ version: '1.0.0',
+ style: '',
+ serverName: '', //服务名
+ tilematrixSet: '', //矩阵集名称
+ layer: '', //图层名
+ format: 'image/png',
+ tileSize: 256,
+ attribution: 'Zondy WMTS Data',
+ noWrap: true
+ },
+ //var layer3 = new ZondyMapWMTSLayer("http://localhost:6163/igs/rest/ogc/WMTSServer", { tilematrixSet: "EPSG:4326_世界地图经纬度LEVEL7_028mm_GB", layer: 'World_level7_WMTS' }).addTo(mymap);
+ //
+ initialize: function (options) {
+ // (String, Object)
+ if (options.url) {
+ if (options.url.indexOf('?') > -1) {
+ this._url = options.url.split('?')[0];
+ } else {
+ this._url = options.url;
+ }
+ } else {
+ var partUrl = '/igs/rest/ogc/WMTSServer';
+ if (options.serverName && options.serverName !== '') {
+ partUrl = '/igs/rest/ogc/' + options.serverName + '/WMTSServer';
+ }
+ var domain = options && options.domain ? options.domain : '';
+ if (domain === '') {
+ this.networkProtocol = options.networkProtocol !== undefined ? options.networkProtocol : location.protocol.split(':')[0] || 'http';
+ var ip = options && options.ip ? options.ip : 'localhost';
+ var port = options && options.port ? options.port : '6163';
+ this._url = encodeURI(this.networkProtocol + '://' + ip + ':' + port + partUrl);
+ } else {
+ this._url = encodeURI(domain + partUrl);
+ }
+ }
+ if (this._url.toLowerCase().indexOf('ime-cloud') > -1) {
+ //吉威的数据
+ this._url += '?service=WMTS&REQUEST=GetTile';
+ } else {
+ this._url += '?service=WMTS&request=GetTile';
+ }
+ this.options.origin = options.origin ? options.origin : null;
+ window.L.setOptions(this, options);
+ },
+ onAdd: function (map) {
+ this._crs = this.options.crs || map.options.crs;
+ let bounds = this._crs.projection.bounds;
+ let northWest = [bounds.min.x, bounds.max.y];
+ this._origin = this.options.origin ? this.options.origin : northWest;
+ window.L.TileLayer.prototype.onAdd.call(this, map);
+ },
+ /**
+ * @private
+ * @function Zondy.Map.MapWMTSLayer.prototype.getTileUrl
+ * @description 根据行列号获取瓦片地址。考虑发布的wmts的瓦片不按左上角为原点的情况,需另外处理
+ * @param coords - {Object} 行列号
+ * @return {string} 瓦片地址
+ */
+ getTileUrl: function (coords) {
+ // (Point, Number) -> String
+ // var tileBounds = this._tileCoordsToBounds(coords);
+ // var ne = this._crs.project(tileBounds.getNorthEast());
+ // var sw = this._crs.project(tileBounds.getSouthWest());
+ // var tileSize = this.options.tileSize;
+ // var resolution = Math.max(Math.abs(ne.x - sw.x) / tileSize, Math.abs(ne.y - sw.y) / tileSize);
+ //
+ // var centerPnt = [(ne.x + sw.x) / 2, (ne.y + sw.y) / 2];
+ // var dx = centerPnt[0] - (this._origin)[0];
+ // var dy = centerPnt[1] - (this._origin)[1];
+ //
+ // var xGrid = -1e8;
+ // var yGrid = -1e8;
+ //
+ // xGrid = Math.floor(dx / (tileSize * resolution));
+ // if (this.options.yAxis === 'down') {
+ // yGrid = Math.floor(-dy / (tileSize * resolution));
+ // } else {
+ // yGrid = Math.floor(dy / (tileSize * resolution));
+ // }
- var zoom = this._getZoomForUrl();
- var url = window.L.Util.template(this._url, {s: this._getSubdomain(coords)});
+ var zoom = this._getZoomForUrl();
+ var url = window.L.Util.template(this._url, { s: this._getSubdomain(coords) });
- var obj = {
- version: this.options.version,
- style: this.options.style,
- tilematrixSet: this.options.tilematrixSet,
- format: this.options.format,
- layer: this.options.layer,
- tilematrix: zoom,
- tilerow: coords.y,
- tilecol: coords.x
- };
+ var obj = {
+ version: this.options.version,
+ style: this.options.style,
+ tilematrixSet: this.options.tilematrixSet,
+ format: this.options.format,
+ layer: this.options.layer,
+ tilematrix: zoom,
+ tilerow: coords.y,
+ tilecol: coords.x
+ };
- //根据地图的不同,拼装不同的url参数
- if(url.indexOf('tianditu') > -1){
- obj.tilematrixSet = 'c';
- }else if(url.indexOf('geoserver') > -1){
- obj.tilematrix = this.options.tilematrixSet+ ':'+zoom;
- }
+ //根据地图的不同,拼装不同的url参数
+ if (url.indexOf('tianditu') > -1) {
+ obj.tilematrixSet = 'c';
+ } else if (url.indexOf('geoserver') > -1) {
+ obj.tilematrix = this.options.tilematrixSet + ':' + zoom;
+ }
- if (this.options.token) {
- if(url.indexOf('tianditu') > -1){
- obj.tk = this.options.token
- }else {
- obj.token = this.options.token
- }
- }
+ if (this.options.token) {
+ if (this.options.tokenKey) {
+ obj[this.options.tokenKey] = this.options.token;
+ } else {
+ if (url.indexOf('tianditu') > -1) {
+ obj.tk = this.options.token;
+ } else {
+ obj.token = this.options.token;
+ }
+ }
+ }
- return url + window.L.Util.getParamString(obj, url);
- }
+ return url + window.L.Util.getParamString(obj, url);
+ }
});
-export {MapWMTSLayer};
+export { MapWMTSLayer };
Zondy.Map.MapWMTSLayer = MapWMTSLayer;
diff --git a/src/leaflet/overlay/stream/MapvStreamLayer.js b/src/leaflet/overlay/stream/MapvStreamLayer.js
index e74d6b434..97c6f6925 100644
--- a/src/leaflet/overlay/stream/MapvStreamLayer.js
+++ b/src/leaflet/overlay/stream/MapvStreamLayer.js
@@ -1,5 +1,5 @@
-import L from "leaflet";
-import { MapvLayer } from "../MapvLayer";
+import L from 'leaflet';
+import { MapvLayer } from '../MapvLayer';
/**
* @class MapvStreamLayer
@@ -12,70 +12,69 @@ import { MapvLayer } from "../MapvLayer";
* @param {Object} options.field - geojson的唯一标识字段,请确保该字段的唯一性。
*/
export var MapvStreamLayer = MapvLayer.extend({
- initialize: function(map, url, options) {
- options = options || {};
+ initialize: function (map, url, options) {
+ options = options || {};
- L.Util.setOptions(this, options);
-
- this.mapvOption = options.mapvOption || {};
- this.data = [];
- this.lastDate = new Date();
- this.url = url;
- this.fieldHash = {};
+ L.Util.setOptions(this, options);
- this.fieldDeg = options.fieldDeg;
- this.iconUrl = options.iconUrl;
- this.timeSpeed = options.timeSpeed || 100;
- this.createIcon();
-
- MapvLayer.prototype.initialize.call(this, map, new window.mapv.DataSet([]), this.mapvOption, options)
- },
+ this.mapvOption = options.mapvOption || {};
+ this.data = [];
+ this.lastDate = new Date();
+ this.url = url;
+ this.fieldHash = {};
- onMessage: function(msg) {
- const feature = msg.feature;
- const field = msg.feature.properties[this.options.field];
+ this.fieldDeg = options.fieldDeg;
+ this.iconUrl = options.iconUrl;
+ this.timeSpeed = options.timeSpeed || 100;
+ this.createIcon();
- let layer = this.parasIcon(feature);
+ MapvLayer.prototype.initialize.call(this, map, new window.mapv.DataSet([]), this.mapvOption, options);
+ },
- if (field !== undefined && this.fieldHash[field]) {
- this.data[this.fieldHash[field]] = layer;
- } else {
- if (field !== undefined) {
- this.data.push(layer);
- this.fieldHash[field] = this.data.length - 1;
- }
- }
+ onMessage: function (msg) {
+ const feature = msg.feature;
+ const field = msg.feature.properties[this.options.field];
+
+ let layer = this.parasIcon(feature);
- this.updateLayer();
- },
+ if (field !== undefined && this.fieldHash[field]) {
+ this.data[this.fieldHash[field]] = layer;
+ } else {
+ if (field !== undefined) {
+ this.data.push(layer);
+ this.fieldHash[field] = this.data.length - 1;
+ }
+ }
- createIcon: function() {
- var iconUrl =
- this.iconUrl || "http://client.snanyun.com:8899/img/leaflet/marker/bike.png";
- this.icon = new Image();
- this.icon.src = iconUrl;
- },
+ this.updateLayer();
+ },
- parasIcon: function(feature) {
- this.mapvOption = {
- draw: "icon"
- };
- var deg = feature.properties[this.fieldDeg] || 0;
- var icon = {
- geometry: {
- type: "Point",
- coordinates: feature.geometry.coordinates
- },
- deg: deg,
- icon: this.icon
- };
- return icon;
- },
+ createIcon: function () {
+ var iconUrl = this.iconUrl || 'http://client.snanyun.com:8899/img/leaflet/marker/bike.png';
+ this.icon = new Image();
+ this.icon.src = iconUrl;
+ },
- updateLayer: function() {
- var currentDate = new Date();
- if (currentDate - this.lastDate < this.timeSpeed) return;
- this.updateData(this.data, this.mapvOption);
- this.lastDate = currentDate;
- }
+ parasIcon: function (feature) {
+ this.mapvOption = {
+ draw: 'icon'
+ };
+ var deg = feature.properties[this.fieldDeg] || 0;
+ var icon = {
+ geometry: {
+ type: 'Point',
+ coordinates: feature.geometry.coordinates
+ },
+ deg: deg,
+ icon: this.icon
+ };
+ return icon;
+ },
+
+ updateLayer: function () {
+ var currentDate = new Date();
+ if (currentDate - this.lastDate < this.timeSpeed) return;
+ this.updateData(this.data, this.mapvOption);
+ this.lastDate = currentDate;
+ }
});
diff --git a/src/leaflet/overlay/view/MarkerClusterLayer.js b/src/leaflet/overlay/view/MarkerClusterLayer.js
index 321d0ce9f..86fe3429f 100644
--- a/src/leaflet/overlay/view/MarkerClusterLayer.js
+++ b/src/leaflet/overlay/view/MarkerClusterLayer.js
@@ -11,7 +11,7 @@ import '../../core/Base';
* @param options - {Object} mapv.options
* @param options.zoom - {Number} 最大的`聚类级别`
* @param options.title - {Number} 单个聚类点的`标题` 内容
- * @param options.field - {String} 选择对应的字段,该字段必须是`数字型`的字段,用来计算大小和颜色
+ * @param options.field - {String} 选择对应的字段,该字段必须是`数字型`的字段,用来计算大小和颜色
*
* @example
* $.get('./static/data/geojson/point.json', function (json) {
@@ -38,7 +38,7 @@ export var MarkerClusterLayer = L.Layer.extend({
initialize: function (map, geojson, options) {
this.map = map;
- let { field } = options;
+ let {field} = options;
this.field = field;
this.options = options;
@@ -95,9 +95,9 @@ export var MarkerClusterLayer = L.Layer.extend({
var label = point.properties[title];
var marker = L.marker(
L.latLng(point.geometry.coordinates[1], point.geometry.coordinates[0]),
- { title: label }
+ {title: label}
);
- marker.bindPopup(count);
+ marker.bindPopup(String(count)).openPopup();
this.layer.addLayer(marker);
}
map.addLayer(this.layer)
diff --git a/src/mapboxgl/.eslintrc.json b/src/mapboxgl/.eslintrc.json
new file mode 100644
index 000000000..5befb95ce
--- /dev/null
+++ b/src/mapboxgl/.eslintrc.json
@@ -0,0 +1,83 @@
+// Use this file as a starting point for your project's .eslintrc.
+// Copy this file, and add rule overrides as needed.
+//
+// Window 安装方法 eslit-aribnb安装地址https://www.npmjs.com/package/eslint-config-airbnb
+//
+// Mac 安装方法 转载地址 https://blog.csdn.net/m0_37068028/article/details/78548148
+// (
+// export PKG=eslint-config-airbnb;
+// npm info "$PKG@latest" peerDependencies --json | command sed 's/[\{\},]//g ; s/: /@/g' | xargs npm install --save-dev "$PKG@latest"
+// )
+// eslint + airbnb + prettier 维护代码风格
+// npm i eslint eslint-config-airbnb eslint-config-prettier eslint-plugin-import eslint-plugin-jsx-a11y eslint-plugin-prettier babel-eslint babel-plugin-import --save-dev
+// 'extends': ['airbnb', 'plugin:prettier/recommended'],
+
+{
+ /* "extends": ["airbnb", "plugin:prettier/recommended"], */
+ // 默认情况下,ESLint 会在所有父级目录里寻找配置文件,一直到根目录。如果你想要你所有项目都遵循一个特定的约定时,这将会很有用,
+ // 但有时候会导致意想不到的结果。为了将 ESLint 限制到一个特定的项目,在你项目根目录下的 package.json 文件或者 .eslintrc.* 文件里的
+ // eslintConfig 字段下设置 "root": true。ESLint 一旦发现配置文件中有 "root": true,它就会停止在父级目录中寻找。
+ "root": true,
+ // 脚本在执行期间访问的额外的全局变量
+ // 当访问未定义的变量时,no-undef 规则将发出警告。如果你想在一个文件里使用全局变量,推荐你定义这些全局变量,这样 ESLint 就不会发出警告了。你可以使用注释或在配置文件中定义全局变量。
+ "globals": {
+ "window": true,
+ "document": true,
+ "$": true,
+
+ // 可从外部导入
+ "Cesium": "readonly"
+ },
+ // 设置插件
+ // "plugins": [
+ // 'html'
+ // ],
+
+ // 设置解析器选项(必须设置这个属性)
+ "parserOptions": {
+ "ecmaVersion": 7,
+ "sourceType": "module",
+ "parser": "babel-eslint", //配置解析es6
+ "ecmaFeatures": {
+ "jsx": true
+ // "arrowFunctions": true,
+ // "experimentalObjectRestSpread": true,
+ // "classes": true,
+ // "modules": true,
+ // "defaultParams": true
+ }
+ },
+ // 启用的规则及各自的错误级别
+ "rules": {
+ // 禁止用console
+ "no-console": 1,
+ // 禁止用分号
+ // "semi": [2, "never"],
+ // "prettier/prettier": ["error", {}, { "usePrettierrc": true , "singleQuote": true, "parser": "flow" } ],
+ // 在同一个作用域中禁止多次重复定义
+ "no-redeclare": 1,
+
+ // 暂时去掉私有变量下划线的问题
+ "no-underscore-dangle": 0,
+
+ // 针对 MapGIS 67 的要素修改规则 将参数的修改放开 先不搞 工作量实在太大了
+ // 百度echarts 关键字 mapModel seriesModel
+ "no-param-reassign": ["error", {
+ "props": true,
+ "ignorePropertyModificationsForRegex": ["^mapModel", "^seriesModel"]
+ }],
+ // 针对百度echarts原型链的处理
+ "no-unused-vars": ["error", {
+ "varsIgnorePattern": "[iI]gnored",
+ "argsIgnorePattern": "^_"
+ }]
+ // 百度mapv源代码需要设置原型链条件,看情况放开
+ // "no-proto" : true
+ },
+ // 指定你想启用的环境
+ "env": {
+ "browser": true,
+ "es6": true,
+ "node": true
+ }
+}
\ No newline at end of file
diff --git a/src/mapboxgl/core/Base.js b/src/mapboxgl/core/Base.js
index d490a985e..6f80ed36c 100644
--- a/src/mapboxgl/core/Base.js
+++ b/src/mapboxgl/core/Base.js
@@ -4,12 +4,14 @@
*/
import mapboxgl from '@mapgis/mapbox-gl';
-export var Zondy = (window.Zondy = window.Zondy || {})
+window.mapboxgl = mapboxgl;
+mapboxgl.zondy = window.mapboxgl.zondy || {};
+var Zondy = window.mapboxgl.zondy || {};
+Zondy.Map = Zondy.Map || {};
+Zondy.Util = Zondy.Util || {};
+Zondy.Network = Zondy.Network || {};
+Zondy.Event = Zondy.Event || {};
+Zondy.Socket = Zondy.Socket || {};
-Zondy.Util = Zondy.Util || {}
-Zondy.Network = Zondy.Network || {}
-
-Zondy.Event = Zondy.Event || {}
-Zondy.Socket = Zondy.Socket || {}
-
-mapboxgl.zondy = mapboxgl.zondy || {}
+export { Zondy };
+export { mapboxgl };
diff --git a/src/mapboxgl/index.js b/src/mapboxgl/index.js
index a1fa10603..2dc6fe0a1 100644
--- a/src/mapboxgl/index.js
+++ b/src/mapboxgl/index.js
@@ -36,13 +36,15 @@ export {
import {
EchartsLayer,
MapvLayer,
- DeckglLayer
+ DeckglLayer,
+ FabricLayer
/* StreamLayer */
} from './overlay/index.js';
export {
EchartsLayer,
MapvLayer,
- DeckglLayer
+ DeckglLayer,
+ FabricLayer
/* StreamLayer */
};
diff --git a/src/mapboxgl/layer/ArcGISLayer.js b/src/mapboxgl/layer/ArcGISLayer.js
index 45004f9a1..087adb024 100644
--- a/src/mapboxgl/layer/ArcGISLayer.js
+++ b/src/mapboxgl/layer/ArcGISLayer.js
@@ -1,9 +1,6 @@
import {Zondy} from './mapboxBase';
//import {Zondy} from '../../service/common/Base';
-import {
- newGuid,
- extend
-} from '../../service/common/Util';
+import { newGuid, extend } from '../util/Util';
/**
* @author 基础平台/产品2部 龚跃健
diff --git a/src/mapboxgl/layer/TDTLayer.js b/src/mapboxgl/layer/TDTLayer.js
index 4ecd6e8ef..f2dfb54f3 100644
--- a/src/mapboxgl/layer/TDTLayer.js
+++ b/src/mapboxgl/layer/TDTLayer.js
@@ -1,9 +1,6 @@
import {Zondy} from './mapboxBase';
//import {Zondy} from '../../service/common/Base';
-import {
- newGuid,
- extend
-} from '../../service/common/Util';
+import { newGuid, extend } from '../util/Util';
/**
* @author 基础平台/产品2部 龚跃健
@@ -102,8 +99,7 @@ var TDTLayer = function (option) {
};
-TDTLayer.prototype.initialize = function (options) {
- options = options || {};
+TDTLayer.prototype.initialize = function () {
if (this.options.baseURL) {
var str = this.options.baseURL.split("gov.cn/")[1];
if (this.options.baseURL.indexOf("?") > 0) {
@@ -172,7 +168,7 @@ TDTLayer.prototype.addToMap = function (map) {
};
TDTLayer.prototype._initLayerUrl = function () {
- this._crs = this.options.crs || map.crs.epsgCode;
+ this._crs = this.options.crs || this.map.crs.epsgCode;
this.options.tilematrixSet = this._crs === "EPSG:4326" ? "c" : "w";
let params = [];
if (this.options.layerType.indexOf("igs") > 0) {
diff --git a/src/mapboxgl/layer/mapDocLayer.js b/src/mapboxgl/layer/mapDocLayer.js
index 9c8d1f0f9..84768815d 100644
--- a/src/mapboxgl/layer/mapDocLayer.js
+++ b/src/mapboxgl/layer/mapDocLayer.js
@@ -1,9 +1,6 @@
import {Zondy} from './mapboxBase';
//import {Zondy} from '../../service/common/Base';
-import {
- newGuid,
- extend
-} from '../../service/common/Util';
+import { newGuid, extend } from '../util/Util';
/**
* @author 基础平台/产品2部 龚跃健
diff --git a/src/mapboxgl/layer/mapTileLayer.js b/src/mapboxgl/layer/mapTileLayer.js
index 415b9d2dd..b7f983d52 100644
--- a/src/mapboxgl/layer/mapTileLayer.js
+++ b/src/mapboxgl/layer/mapTileLayer.js
@@ -3,10 +3,7 @@
//那么在0级的时候就有4张瓦片,不能一一对应
import {Zondy} from './mapboxBase';
//import {Zondy} from '../../service/common/Base';
-import {
- newGuid,
- extend
-} from '../../service/common/Util';
+import { newGuid, extend } from '../util/Util';
/**
* @author 基础平台/产品2部 龚跃健
@@ -74,28 +71,31 @@ MapTileLayer.prototype.addToMap = function (map) {
this.map = map;
this._initLayerUrl();
var zoomOffset = this.options.zoomOffset;
+ //已将下列逻辑下沉到了@mapgis/mapbox-gl中
//重写mapbox中CanonicalTileID的url类,以支持非标准裁剪的瓦片(这里的非标准不是指任意裁剪瓦片,而是当前瓦片的0级不是mapbox定义的瓦片的0级,中间相差zoomOffset级)
- mapboxgl.CanonicalTileID.prototype.url = function (urls, scheme) {
- const bbox = this.getTileBBox();
- if (zoomOffset > this.z) {
- zoomOffset = 0;
- }
- const quadkey = getQuadkey(this.z - zoomOffset, this.x, this.y);
+ // let mapboxgl = window.mapboxgl;
+ // mapboxgl.CanonicalTileID.prototype.url = function (urls, scheme) {
+ // const bbox = this.getTileBBox();
+ // if (zoomOffset > this.z) {
+ // zoomOffset = 0;
+ // }
+ // const quadkey = getQuadkey(this.z - zoomOffset, this.x, this.y);
- return urls[(this.x + this.y) % urls.length]
- .replace('{prefix}', (this.x % 16).toString(16) + (this.y % 16).toString(16))
- .replace('{z}', String(this.z - zoomOffset))
- .replace('{x}', String(this.x))
- .replace('{y}', String(scheme === 'tms' ? (Math.pow(2, this.z) - this.y - 1) : this.y))
- .replace('{quadkey}', quadkey)
- .replace('{bbox-epsg-3857}', bbox);
- };
+ // return urls[(this.x + this.y) % urls.length]
+ // .replace('{prefix}', (this.x % 16).toString(16) + (this.y % 16).toString(16))
+ // .replace('{z}', String(this.z - zoomOffset))
+ // .replace('{x}', String(this.x))
+ // .replace('{y}', String(scheme === 'tms' ? (Math.pow(2, this.z) - this.y - 1) : this.y))
+ // .replace('{quadkey}', quadkey)
+ // .replace('{bbox-epsg-3857}', bbox);
+ // };
var sourceID = this.sourceID || "source_" + newGuid();
var layerID = this.layerID || "layer_" + newGuid();
var tile_source = {
'type': 'raster',//数据源类型,因为wms返回图片数据,因此为该类型
'tiles': [this._layerUrl],
- 'tileSize': this.options.tileSize || 512 //图片显示的大小,最好和上面大小保持一致
+ 'tileSize': this.options.tileSize || 512, //图片显示的大小,最好和上面大小保持一致
+ mapgisOffset: zoomOffset
};
var mLayer = {
'id': layerID,//图层ID
@@ -135,15 +135,15 @@ MapTileLayer.prototype._initLayerUrl = function () {
this._layerUrl = layerUrl;
};
-function getQuadkey(z, x, y) {
- let quadkey = '',
- mask;
- for (let i = z; i > 0; i--) {
- mask = 1 << (i - 1);
- quadkey += ((x & mask ? 1 : 0) + (y & mask ? 2 : 0));
- }
- return quadkey;
-}
+// function getQuadkey(z, x, y) {
+// let quadkey = '',
+// mask;
+// for (let i = z; i > 0; i--) {
+// mask = 1 << (i - 1);
+// quadkey += ((x & mask ? 1 : 0) + (y & mask ? 2 : 0));
+// }
+// return quadkey;
+// }
export {MapTileLayer};
Zondy.Map.MapTileLayer = MapTileLayer;
diff --git a/src/mapboxgl/layer/mapVectorLayer.js b/src/mapboxgl/layer/mapVectorLayer.js
index a75737340..b7a6946b2 100644
--- a/src/mapboxgl/layer/mapVectorLayer.js
+++ b/src/mapboxgl/layer/mapVectorLayer.js
@@ -1,9 +1,6 @@
import {Zondy} from './mapboxBase';
//import {Zondy} from '../../service/common/Base';
-import {
- newGuid,
- extend
-} from '../../service/common/Util';
+import { newGuid, extend } from '../util/Util';
/**
* @author 基础平台/产品2部 龚跃健
diff --git a/src/mapboxgl/layer/mapWmsLayer.js b/src/mapboxgl/layer/mapWmsLayer.js
index 7a0f21866..93e765800 100644
--- a/src/mapboxgl/layer/mapWmsLayer.js
+++ b/src/mapboxgl/layer/mapWmsLayer.js
@@ -1,9 +1,6 @@
import {Zondy} from './mapboxBase';
//import {Zondy} from '../../service/common/Base';
-import {
- newGuid,
- extend
-} from '../../service/common/Util';
+import { newGuid, extend } from '../util/Util';
/**
* @author 基础平台/产品2部 龚跃健
diff --git a/src/mapboxgl/layer/mapWmtsLayer.js b/src/mapboxgl/layer/mapWmtsLayer.js
index 8dfdb8fe2..7b684b18e 100644
--- a/src/mapboxgl/layer/mapWmtsLayer.js
+++ b/src/mapboxgl/layer/mapWmtsLayer.js
@@ -1,9 +1,6 @@
import {Zondy} from './mapboxBase';
//import {Zondy} from '../../service/common/Base';
-import {
- newGuid,
- extend
-} from '../../service/common/Util';
+import { newGuid, extend } from '../util/Util';
/**
* @author 基础平台/产品2部 龚跃健
diff --git a/src/mapboxgl/layer/mapboxBase.js b/src/mapboxgl/layer/mapboxBase.js
index b0fd94ffc..b76500e04 100644
--- a/src/mapboxgl/layer/mapboxBase.js
+++ b/src/mapboxgl/layer/mapboxBase.js
@@ -1,6 +1,14 @@
-var mapboxgl = window.mapboxgl = window.mapboxgl || {};
+/* var mapboxgl = window.mapboxgl = window.mapboxgl || {};
mapboxgl.Zondy = mapboxgl.Zondy || {};
var Zondy = mapboxgl.Zondy || {};
Zondy.Map = Zondy.Map || {};
export {Zondy};
-export {mapboxgl}
+export {mapboxgl} */
+
+import mapboxgl from '@mapgis/mapbox-gl';
+window.mapboxgl = mapboxgl;
+mapboxgl.Zondy = window.mapboxgl.Zondy || {};
+var Zondy = window.mapboxgl.Zondy || {};
+Zondy.Map = Zondy.Map || {};
+export { Zondy };
+export { mapboxgl };
diff --git a/src/mapboxgl/overlay/index.js b/src/mapboxgl/overlay/index.js
index 36f40a198..35bbd31b5 100644
--- a/src/mapboxgl/overlay/index.js
+++ b/src/mapboxgl/overlay/index.js
@@ -1,3 +1,10 @@
+/*
+ * @Description:
+ * @Author: zk
+ * @Date: 2022-04-25 11:32:23
+ * @LastEditors: Do not edit
+ * @LastEditTime: 2022-04-25 20:11:41
+ */
/**
* @module 客户端可视化
*/
diff --git a/src/mapboxgl/package.json b/src/mapboxgl/package.json
index 49a126567..de9083102 100644
--- a/src/mapboxgl/package.json
+++ b/src/mapboxgl/package.json
@@ -1,23 +1,39 @@
{
- "name": "@mapgis/webclient-es6-mapboxgl",
- "version": "10.5.4",
- "description": "",
- "module": "index.js",
- "scripts": {
- "test": "echo \"Error: no test specified\" && exit 1"
- },
- "keywords": [
- "zondy",
- "service",
- "&",
- "mapboxgl"
- ],
- "author": "zondy",
- "license": "ISC",
- "dependencies": {
- "@mapgis/webclient-es6-service": "^10.5.4",
- "@mapgis/mapbox-gl": "^1.9.4",
- "echarts": "^4.8.0",
- "mapv": "^2.0.56"
- }
+ "name": "@mapgis/webclient-es6-mapboxgl",
+ "version": "15.6.1",
+ "description": "",
+ "main1": "dist-libs/webclient-mapboxgl-plugin.min.js",
+ "module": "index.js",
+ "scripts": {
+ "build": "npm run build-debug && npm run build-release",
+ "build-debug": "webpack --config webpack/mapbox-es6-debug-config.js",
+ "build-release": "webpack --config webpack/mapbox-es6-release-config.js"
+ },
+ "keywords": [
+ "zondy",
+ "service",
+ "&",
+ "mapboxgl"
+ ],
+ "author": "Wuhan Zondy Cyber Science&Technology Co.Ltd.",
+ "license": "Apache-2.0",
+ "dependencies": {
+ "@mapgis/mapbox-gl": "^1.9.9",
+ "@mapgis/webclient-es6-service": "^10.5.7",
+ "core-js": "^3.21.1",
+ "echarts": "^4.8.0",
+ "mapv": "^2.0.56"
+ },
+ "devDependencies": {
+ "@babel/core": "^7.16.0",
+ "@babel/preset-env": "^7.16.4",
+ "babel-loader": "^8.2.3",
+ "babel-plugin-add-module-exports": "^1.0.4",
+ "css-loader": "^6.5.1",
+ "html-webpack-plugin": "^5.5.0",
+ "sass-loader": "^12.4.0",
+ "style-loader": "^3.3.1",
+ "ts-loader": "^9.2.6",
+ "webpack": "^5.65.0"
+ }
}
diff --git a/src/mapboxgl/theme/GeoFeatureThemeLayer.js b/src/mapboxgl/theme/GeoFeatureThemeLayer.js
index 2b09ee5af..fa42ba566 100644
--- a/src/mapboxgl/theme/GeoFeatureThemeLayer.js
+++ b/src/mapboxgl/theme/GeoFeatureThemeLayer.js
@@ -1,12 +1,11 @@
import mapboxgl from '@mapgis/mapbox-gl';
-import { Zondy } from '../../service/common/Base';
+import { Common } from '@mapgis/webclient-es6-service';
+
import { ThemeLayer } from './ThemeLayer';
-import { extend } from '../../service/common/Util';
-import { copyAttributesWithClip } from '../../service/common/Util';
+import { ShapeFactory } from './common/overlay/feature/ShapeFactory';
+import { ThemeVector } from './common/overlay/ThemeVector';
-import { ShapeFactory } from '../../common/overlay/feature/ShapeFactory';
-import { ThemeVector } from '../../common/overlay/ThemeVector';
-import { FeatureSet } from '../../service/common/FeatureSet';
+const { extend, copyAttributesWithClip, FeatureSet, Zondy } = Common;
/**
* @class Zondy.Map.GeoFeatureThemeLayer
diff --git a/src/mapboxgl/theme/GraphThemeLayer.js b/src/mapboxgl/theme/GraphThemeLayer.js
index 7b20b6576..c8b209a55 100644
--- a/src/mapboxgl/theme/GraphThemeLayer.js
+++ b/src/mapboxgl/theme/GraphThemeLayer.js
@@ -1,9 +1,10 @@
-import mapboxgl from "@mapgis/mapbox-gl";
-import { Zondy } from "../../service/common/Base";
-import { ThemeLayer } from "./ThemeLayer";
-import { Theme as FeatureTheme } from "../../common/overlay/feature/Theme";
-import { Point2D } from "../../service/common/Point2D";
-import { FeatureSet } from "../../service/common/FeatureSet";
+import mapboxgl from '@mapgis/mapbox-gl';
+import { Common } from '@mapgis/webclient-es6-service';
+
+import { ThemeLayer } from './ThemeLayer';
+import { Theme as FeatureTheme } from './common/overlay/feature/Theme';
+
+const { FeatureSet, Zondy, Point2D } = Common;
/**
* @class Zondy.Map.graphThemeLayer
@@ -32,498 +33,450 @@ import { FeatureSet } from "../../service/common/FeatureSet";
* @fires Zondy.Map.graphThemeLayer#beforefeaturesadded
*/
class GraphThemeLayer extends ThemeLayer {
- constructor(name, chartsType, options) {
- super(name, options);
- this.chartsSetting = options.chartsSetting || {};
- this.themeFields = options.themeFields || null;
- this.overlayWeightField = options.overlayWeightField || null;
- this.isOverLay = options.isOverLay || true;
- this.charts = options.charts || [];
- this.cache = options.cache || {};
- this.chartsType = chartsType;
- this.options = {
- calGravity: options.calGravity || true
- };
- }
+ constructor(name, chartsType, options) {
+ super(name, options);
+ this.chartsSetting = options.chartsSetting || {};
+ this.themeFields = options.themeFields || null;
+ this.overlayWeightField = options.overlayWeightField || null;
+ this.isOverLay = options.isOverLay || true;
+ this.charts = options.charts || [];
+ this.cache = options.cache || {};
+ this.chartsType = chartsType;
+ this.options = {
+ calGravity: options.calGravity || true
+ };
+ }
- /**
- * @function Zondy.Map.graphThemeLayer.prototype.setChartsType
- * @description 设置图表类型,此函数可动态改变图表类型。在调用此函数前请通过 chartsSetting 为新类型的图表做相关配置。
- * @param {string} [chartsType] - 图表类型。目前可用:"Bar", "Line", "Pie"。
- */
- setChartsType(chartsType) {
- this.chartsType = chartsType;
- this.redraw();
- }
+ /**
+ * @function Zondy.Map.graphThemeLayer.prototype.setChartsType
+ * @description 设置图表类型,此函数可动态改变图表类型。在调用此函数前请通过 chartsSetting 为新类型的图表做相关配置。
+ * @param {string} [chartsType] - 图表类型。目前可用:"Bar", "Line", "Pie"。
+ */
+ setChartsType(chartsType) {
+ this.chartsType = chartsType;
+ this.redraw();
+ }
- /**
- * @function Zondy.Map.graphThemeLayer.prototype.addFeatures
- * @description 向专题图图层中添加数据,支持的 feature 类型为:iServer 返回的 feature JSON 对象。
- * @param {Object} features - 待添加的要素。
- */
- addFeatures(features) {
- var me = this;
- mapboxgl.Evented.prototype.fire("beforefeaturesadded", {
- features: features
- });
+ /**
+ * @function Zondy.Map.graphThemeLayer.prototype.addFeatures
+ * @description 向专题图图层中添加数据,支持的 feature 类型为:iServer 返回的 feature JSON 对象。
+ * @param {Object} features - 待添加的要素。
+ */
+ addFeatures(features) {
+ var me = this;
+ mapboxgl.Evented.prototype.fire('beforefeaturesadded', {
+ features: features
+ });
- if (features && (true || features instanceof FeatureSet)) {
- var attrs = null;
- var LabelDots = features.LabelDots;
- var attstruct = features.AttStruct;
- var feaArr = features.SFEleArray;
- if (feaArr != null && feaArr.length > 0) {
- for (var j = 0; j < feaArr.length; j++) {
- var feature = feaArr[j];
- if (feature.AttValue != null && feature.AttValue.length > 0) {
- var attrs = {};
- for (var i = 0; i < feature.AttValue.length; i++) {
- attrs[attstruct.FldName[i]] = feature.AttValue[i];
+ if (features && (true || features instanceof FeatureSet)) {
+ var attrs = null;
+ var LabelDots = features.LabelDots;
+ var attstruct = features.AttStruct;
+ var feaArr = features.SFEleArray;
+ if (feaArr != null && feaArr.length > 0) {
+ for (var j = 0; j < feaArr.length; j++) {
+ var feature = feaArr[j];
+ if (feature.AttValue != null && feature.AttValue.length > 0) {
+ var attrs = {};
+ for (var i = 0; i < feature.AttValue.length; i++) {
+ attrs[attstruct.FldName[i]] = feature.AttValue[i];
+ }
+ attrs['FID'] = feature.FID;
+ }
+ feature.attributes = attrs;
+ LabelDots && LabelDots[j] && (feature.LabelDot = LabelDots[j]);
+ me.features.push(feature);
+ }
}
- attrs["FID"] = feature.FID;
- }
- feature.attributes = attrs;
- LabelDots && LabelDots[j] && (feature.LabelDot = LabelDots[j]);
- me.features.push(feature);
}
- }
- }
- //绘制专题要素
- if (this.renderer) {
- this.redrawThematicFeatures(this.map.getBounds());
+ //绘制专题要素
+ if (this.renderer) {
+ this.redrawThematicFeatures(this.map.getBounds());
+ }
}
- }
- /**
- * @function Zondy.Map.graphThemeLayer.prototype.redrawThematicFeatures
- * @description 重绘所有专题要素。
- * 此方法包含绘制专题要素的所有步骤,包含用户数据到专题要素的转换,抽稀,缓存等步骤。
- * 地图漫游时调用此方法进行图层刷新。
- * @param {mapboxgl.LngLatBounds} extent - 重绘的范围。
- */
- redrawThematicFeatures(extent) {
- // eslint-disable-line no-unused-vars
- this.clearCache();
- //清除当前所有可视元素
- this.renderer.clearAll();
- var features = this.features;
- // var bounds = null;
- // if (extent && extent instanceof window.mapboxgl.LngLatBounds) {
- // var lb = extent.getSouthWest();
- // var rt = extent.getNorthEast();
- // var lbM = this.lonLat2WebMercator(lb.lng,lb.lat);
- // var rtM = this.lonLat2WebMercator(rt.lng,rt.lat);
- // bounds = new Rectangle(lbM.x,lbM.y,rtM.x,rtM.y);
- // }
+ /**
+ * @function Zondy.Map.graphThemeLayer.prototype.redrawThematicFeatures
+ * @description 重绘所有专题要素。
+ * 此方法包含绘制专题要素的所有步骤,包含用户数据到专题要素的转换,抽稀,缓存等步骤。
+ * 地图漫游时调用此方法进行图层刷新。
+ * @param {mapboxgl.LngLatBounds} extent - 重绘的范围。
+ */
+ redrawThematicFeatures(extent) {
+ // eslint-disable-line no-unused-vars
+ this.clearCache();
+ //清除当前所有可视元素
+ this.renderer.clearAll();
+ var features = this.features;
+ // var bounds = null;
+ // if (extent && extent instanceof window.mapboxgl.LngLatBounds) {
+ // var lb = extent.getSouthWest();
+ // var rt = extent.getNorthEast();
+ // var lbM = this.lonLat2WebMercator(lb.lng,lb.lat);
+ // var rtM = this.lonLat2WebMercator(rt.lng,rt.lat);
+ // bounds = new Rectangle(lbM.x,lbM.y,rtM.x,rtM.y);
+ // }
- for (var i = 0, len = features.length; i < len; i++) {
- var feature = features[i];
- // // 要素范围判断
- // var feaBounds = feature.bound;
- // //剔除当前视图(地理)范围以外的数据
- // if (bounds && !bounds.intersectsBounds(feaBounds)) {
- // continue;
- // }
- var cache = this.cache;
- // 用feature id 做缓存标识
- var cacheField = feature.FID;
- // 数据对应的图表是否已缓存,没缓存则重新创建图表
- if (cache[cacheField]) {
- continue;
- }
- cache[cacheField] = cacheField;
- var chart = this.createThematicFeature(feature);
- // 压盖处理权重值
- if (chart && this.overlayWeightField) {
- if (
- feature.attributes[this.overlayWeightField] &&
- !isNaN(feature.attributes[this.overlayWeightField])
- ) {
- chart["__overlayWeight"] =
- feature.attributes[this.overlayWeightField];
+ for (var i = 0, len = features.length; i < len; i++) {
+ var feature = features[i];
+ // // 要素范围判断
+ // var feaBounds = feature.bound;
+ // //剔除当前视图(地理)范围以外的数据
+ // if (bounds && !bounds.intersectsBounds(feaBounds)) {
+ // continue;
+ // }
+ var cache = this.cache;
+ // 用feature id 做缓存标识
+ var cacheField = feature.FID;
+ // 数据对应的图表是否已缓存,没缓存则重新创建图表
+ if (cache[cacheField]) {
+ continue;
+ }
+ cache[cacheField] = cacheField;
+ var chart = this.createThematicFeature(feature);
+ // 压盖处理权重值
+ if (chart && this.overlayWeightField) {
+ if (feature.attributes[this.overlayWeightField] && !isNaN(feature.attributes[this.overlayWeightField])) {
+ chart['__overlayWeight'] = feature.attributes[this.overlayWeightField];
+ }
+ }
+ if (chart) {
+ this.charts.push(chart);
+ }
}
- }
- if (chart) {
- this.charts.push(chart);
- }
+ this.drawCharts();
}
- this.drawCharts();
- }
- /**
- * @function Zondy.Map.graphThemeLayer.prototype.createThematicFeature
- * @description 向专题图图层中添加数据, 支持的 feature 类型为:iServer 返回的 feature json 对象。
- * @param {Object} feature - 待添加的要素。
- *
- */
- createThematicFeature(feature) {
- var thematicFeature;
- // 检查图表创建条件并创建图形
- if (
- FeatureTheme[this.chartsType] &&
- this.themeFields &&
- this.chartsSetting
- ) {
- thematicFeature = new FeatureTheme[this.chartsType](
- feature,
- this,
- this.themeFields,
- this.chartsSetting,
- null,
- this.options
- );
- }
- // thematicFeature 是否创建成功
- if (!thematicFeature) {
- return false;
+ /**
+ * @function Zondy.Map.graphThemeLayer.prototype.createThematicFeature
+ * @description 向专题图图层中添加数据, 支持的 feature 类型为:iServer 返回的 feature json 对象。
+ * @param {Object} feature - 待添加的要素。
+ *
+ */
+ createThematicFeature(feature) {
+ var thematicFeature;
+ // 检查图表创建条件并创建图形
+ if (FeatureTheme[this.chartsType] && this.themeFields && this.chartsSetting) {
+ thematicFeature = new FeatureTheme[this.chartsType](feature, this, this.themeFields, this.chartsSetting, null, this.options);
+ }
+ // thematicFeature 是否创建成功
+ if (!thematicFeature) {
+ return false;
+ }
+ // 对专题要素执行图形装载
+ thematicFeature.assembleShapes();
+ return thematicFeature;
}
- // 对专题要素执行图形装载
- thematicFeature.assembleShapes();
- return thematicFeature;
- }
- /**
- * @function Zondy.Map.graphThemeLayer.prototype.drawCharts
- * @description 绘制图表。包含压盖处理。
- *
- */
- drawCharts() {
- // 判断 rendere r就绪
- if (!this.renderer) {
- return;
- }
- var charts = this.charts;
- // 图表权重值处理des
- if (this.overlayWeightField) {
- charts.sort(function(cs, ce) {
- if (
- typeof cs["__overlayWeight"] == "undefined" &&
- typeof ce["__overlayWeight"] == "undefined"
- ) {
- return 0;
- } else if (
- typeof cs["__overlayWeight"] != "undefined" &&
- typeof ce["__overlayWeight"] == "undefined"
- ) {
- return -1;
- } else if (
- typeof cs["__overlayWeight"] == "undefined" &&
- typeof ce["__overlayWeight"] != "undefined"
- ) {
- return 1;
- } else if (
- typeof cs["__overlayWeight"] != "undefined" &&
- typeof ce["__overlayWeight"] != "undefined"
- ) {
- if (
- parseFloat(cs["__overlayWeight"]) <
- parseFloat(ce["__overlayWeight"])
- ) {
- return 1;
- } else {
- return -1;
- }
+ /**
+ * @function Zondy.Map.graphThemeLayer.prototype.drawCharts
+ * @description 绘制图表。包含压盖处理。
+ *
+ */
+ drawCharts() {
+ // 判断 rendere r就绪
+ if (!this.renderer) {
+ return;
}
- return 0;
- });
- }
- // 不进行避让
- if (!this.isOverLay) {
- for (var m = 0, len_m = charts.length; m < len_m; m++) {
- var chart_m = charts[m];
- // 图形参考位置 (reSetLocation 会更新 chartBounds)
- var shapeROP_m = chart_m.resetLocation();
- // 添加图形
- var shapes_m = chart_m.shapes;
- for (var n = 0, slen_n = shapes_m.length; n < slen_n; n++) {
- shapes_m[n].refOriginalPosition = shapeROP_m;
- this.renderer.addShape(shapes_m[n]);
+ var charts = this.charts;
+ // 图表权重值处理des
+ if (this.overlayWeightField) {
+ charts.sort(function (cs, ce) {
+ if (typeof cs['__overlayWeight'] == 'undefined' && typeof ce['__overlayWeight'] == 'undefined') {
+ return 0;
+ } else if (typeof cs['__overlayWeight'] != 'undefined' && typeof ce['__overlayWeight'] == 'undefined') {
+ return -1;
+ } else if (typeof cs['__overlayWeight'] == 'undefined' && typeof ce['__overlayWeight'] != 'undefined') {
+ return 1;
+ } else if (typeof cs['__overlayWeight'] != 'undefined' && typeof ce['__overlayWeight'] != 'undefined') {
+ if (parseFloat(cs['__overlayWeight']) < parseFloat(ce['__overlayWeight'])) {
+ return 1;
+ } else {
+ return -1;
+ }
+ }
+ return 0;
+ });
}
- }
- } else {
- // 压盖判断所需 chartsBounds 集合
- var chartsBounds = [];
- // 压盖处理 & 添加图形
- for (let i = 0, len = charts.length; i < len; i++) {
- var chart = charts[i];
- // 图形参考位置 (reSetLocation 会更新 chartBounds)
- var shapeROP = chart.resetLocation();
- // 图表框
- var cbs = chart.chartBounds;
- var cBounds = [
- {
- x: cbs.xmin,
- y: cbs.ymin
- },
- {
- x: cbs.xmin,
- y: cbs.ymax
- },
- {
- x: cbs.xmax,
- y: cbs.ymax
- },
- {
- x: cbs.xmax,
- y: cbs.ymin
- },
- {
- x: cbs.xmin,
- y: cbs.ymax
- }
- ];
- // // 地图范围外不绘制
- // if (mBounds) {
- // // if (!this.isChartInMap(mBounds, cBounds)) continue;
- // }
- // 是否压盖
- var isOL = false;
- if (i !== 0) {
- for (let j = 0; j < chartsBounds.length; j++) {
- //压盖判断
- if (this.isQuadrilateralOverLap(cBounds, chartsBounds[j])) {
- isOL = true;
- break;
+ // 不进行避让
+ if (!this.isOverLay) {
+ for (var m = 0, len_m = charts.length; m < len_m; m++) {
+ var chart_m = charts[m];
+ // 图形参考位置 (reSetLocation 会更新 chartBounds)
+ var shapeROP_m = chart_m.resetLocation();
+ // 添加图形
+ var shapes_m = chart_m.shapes;
+ for (var n = 0, slen_n = shapes_m.length; n < slen_n; n++) {
+ shapes_m[n].refOriginalPosition = shapeROP_m;
+ this.renderer.addShape(shapes_m[n]);
+ }
}
- }
- }
- if (isOL) {
- continue;
} else {
- chartsBounds.push(cBounds);
- }
- // 添加图形
- var shapes = chart.shapes;
- for (let j = 0, slen = shapes.length; j < slen; j++) {
- shapes[j].refOriginalPosition = shapeROP;
- this.renderer.addShape(shapes[j]);
+ // 压盖判断所需 chartsBounds 集合
+ var chartsBounds = [];
+ // 压盖处理 & 添加图形
+ for (let i = 0, len = charts.length; i < len; i++) {
+ var chart = charts[i];
+ // 图形参考位置 (reSetLocation 会更新 chartBounds)
+ var shapeROP = chart.resetLocation();
+ // 图表框
+ var cbs = chart.chartBounds;
+ var cBounds = [
+ {
+ x: cbs.xmin,
+ y: cbs.ymin
+ },
+ {
+ x: cbs.xmin,
+ y: cbs.ymax
+ },
+ {
+ x: cbs.xmax,
+ y: cbs.ymax
+ },
+ {
+ x: cbs.xmax,
+ y: cbs.ymin
+ },
+ {
+ x: cbs.xmin,
+ y: cbs.ymax
+ }
+ ];
+ // // 地图范围外不绘制
+ // if (mBounds) {
+ // // if (!this.isChartInMap(mBounds, cBounds)) continue;
+ // }
+ // 是否压盖
+ var isOL = false;
+ if (i !== 0) {
+ for (let j = 0; j < chartsBounds.length; j++) {
+ //压盖判断
+ if (this.isQuadrilateralOverLap(cBounds, chartsBounds[j])) {
+ isOL = true;
+ break;
+ }
+ }
+ }
+ if (isOL) {
+ continue;
+ } else {
+ chartsBounds.push(cBounds);
+ }
+ // 添加图形
+ var shapes = chart.shapes;
+ for (let j = 0, slen = shapes.length; j < slen; j++) {
+ shapes[j].refOriginalPosition = shapeROP;
+ this.renderer.addShape(shapes[j]);
+ }
+ }
}
- }
+ // 绘制图形
+ this.renderer.render();
}
- // 绘制图形
- this.renderer.render();
- }
- /**
- * @function Zondy.Map.graphThemeLayer.prototype.getShapesByFeatureID
- * @description 通过 FeatureID 获取 feature 关联的所有图形。如果不传入此参数,函数将返回所有图形。
- * @param {number} featureID - 要素 ID。
- */
- getShapesByFeatureID(featureID) {
- var list = [];
- var shapeList = this.renderer.getAllShapes();
- if (!featureID) {
- return shapeList;
- }
- for (var i = 0, len = shapeList.length; i < len; i++) {
- var si = shapeList[i];
- if (si.refDataID && featureID === si.refDataID) {
- list.push(si);
- }
+ /**
+ * @function Zondy.Map.graphThemeLayer.prototype.getShapesByFeatureID
+ * @description 通过 FeatureID 获取 feature 关联的所有图形。如果不传入此参数,函数将返回所有图形。
+ * @param {number} featureID - 要素 ID。
+ */
+ getShapesByFeatureID(featureID) {
+ var list = [];
+ var shapeList = this.renderer.getAllShapes();
+ if (!featureID) {
+ return shapeList;
+ }
+ for (var i = 0, len = shapeList.length; i < len; i++) {
+ var si = shapeList[i];
+ if (si.refDataID && featureID === si.refDataID) {
+ list.push(si);
+ }
+ }
+ return list;
}
- return list;
- }
- /**
- * @function Zondy.Map.graphThemeLayer.prototype.isQuadrilateralOverLap
- * @description 判断两个四边形是否有压盖。
- * @param {Array.