| @@ -45,6 +45,33 @@ import 'dvgis/dc-sdk/dist/dc.core.min.css' // Main Style Sheet | |||
| ## Setting | |||
| `Webpack` | |||
| ```js | |||
| // webpack.config.js | |||
| const path = require('path') | |||
| const CopywebpackPlugin = require('copy-webpack-plugin') | |||
| const dvgisDist = './node_modules/@dvgis' | |||
| module.exports = { | |||
| // other settings | |||
| resolve: { | |||
| alias: { | |||
| dvgis: path.resolve(__dirname, dvgisDist) | |||
| } | |||
| }, | |||
| plugins:[ | |||
| new CopyWebpackPlugin([ | |||
| { | |||
| from: path.join(dvgisDist, 'dc-sdk/dist/resources'), | |||
| to: 'libs/dc-sdk/resources' | |||
| } | |||
| ]) | |||
| ] | |||
| } | |||
| ``` | |||
| `Vue2.x` | |||
| ```js | |||
| @@ -45,6 +45,33 @@ import 'dvgis/dc-sdk/dist/dc.core.min.css' // 主要样式 | |||
| ## 配置 | |||
| `Webpack` | |||
| ```js | |||
| // webpack.config.js | |||
| const path = require('path') | |||
| const CopywebpackPlugin = require('copy-webpack-plugin') | |||
| const dvgisDist = './node_modules/@dvgis' | |||
| module.exports = { | |||
| // 其他配置 | |||
| resolve: { | |||
| alias: { | |||
| dvgis: path.resolve(__dirname, dvgisDist) | |||
| } | |||
| }, | |||
| plugins:[ | |||
| new CopyWebpackPlugin([ | |||
| { | |||
| from: path.join(dvgisDist, 'dc-sdk/dist/resources'), | |||
| to: 'libs/dc-sdk/resources' | |||
| } | |||
| ]) | |||
| ] | |||
| } | |||
| ``` | |||
| `Vue2.x` | |||
| ```js | |||
| @@ -16,6 +16,9 @@ class ContextMenu extends Widget { | |||
| this._ulEl = undefined | |||
| this._handler = undefined | |||
| this._overlay = undefined | |||
| this._position = undefined | |||
| this._surfacePosition = undefined | |||
| this._windowPosition = undefined | |||
| this._config = {} | |||
| this._defaultMenu = [ | |||
| { | |||
| @@ -126,9 +129,25 @@ class ContextMenu extends Widget { | |||
| * @private | |||
| */ | |||
| _onRightClick(movement) { | |||
| this._enable && this._updateWindowCoord(movement.position) | |||
| this._overlay = undefined | |||
| let target = this._viewer.scene.pick(movement.position) | |||
| if (!this._enable) { | |||
| return | |||
| } | |||
| let scene = this._viewer.scene | |||
| this._windowPosition = movement.position | |||
| this._updateWindowCoord(movement.position) | |||
| let target = scene.pick(movement.position) | |||
| if (scene.pickPositionSupported) { | |||
| this._position = scene.pickPosition(movement.position) | |||
| } | |||
| if (scene.mode === Cesium.SceneMode.SCENE3D) { | |||
| let ray = scene.camera.getPickRay(movement.position) | |||
| this._surfacePosition = scene.globe.pick(ray, scene) | |||
| } else { | |||
| this._surfacePosition = scene.camera.pickEllipsoid( | |||
| movement.position, | |||
| Cesium.Ellipsoid.WGS84 | |||
| ) | |||
| } | |||
| // for Entity | |||
| if (target && target.id && target.id instanceof Cesium.Entity) { | |||
| let layer = this._viewer | |||
| @@ -204,7 +223,12 @@ class ContextMenu extends Widget { | |||
| let self = this | |||
| if (method) { | |||
| a.onclick = () => { | |||
| method.call(context, self._viewer, self._overlay) | |||
| method.call(context, { | |||
| position: self._position, | |||
| windowPosition: self._windowPosition, | |||
| surfacePosition: self._surfacePosition, | |||
| overlay: self._overlay | |||
| }) | |||
| self.hide() | |||
| } | |||
| } | |||
| @@ -11,12 +11,8 @@ const cesiumBuild = 'node_modules/cesium/Build/Cesium' | |||
| let cesiumCopyPlugin = [ | |||
| new CopyWebpackPlugin([ | |||
| { from: path.join(cesiumBuild, 'Assets'), to: 'resources/Assets' } | |||
| ]), | |||
| new CopyWebpackPlugin([ | |||
| { from: path.join(cesiumBuild, 'Workers'), to: 'resources/Workers' } | |||
| ]), | |||
| new CopyWebpackPlugin([ | |||
| { from: path.join(cesiumBuild, 'Assets'), to: 'resources/Assets' }, | |||
| { from: path.join(cesiumBuild, 'Workers'), to: 'resources/Workers' }, | |||
| { from: path.join(cesiumBuild, 'ThirdParty'), to: 'resources/ThirdParty' } | |||
| ]) | |||
| ] | |||