xy-map 1.0.18 → 1.0.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xy-map",
3
- "version": "1.0.18",
3
+ "version": "1.0.19",
4
4
  "description": "地图组件",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
package/src/index.js CHANGED
@@ -1,3 +1,4 @@
1
+ import Vue from 'vue'
1
2
  import mapSdk from './map.js'
2
3
 
3
4
  import {
@@ -110,11 +111,14 @@ const mapEvent = {
110
111
  mapHoverHtml
111
112
  }
112
113
 
114
+ // 地图组件
115
+ import mapMarker from '@/package/mapMarker.vue'
116
+ Vue.component('mapMarker', mapMarker)
113
117
 
114
118
  export {
115
119
  mapSdk,
116
120
  mapLayers,
117
121
  mapDraw,
118
122
  mapTools,
119
- mapEvent
123
+ mapEvent,
120
124
  }
@@ -94,11 +94,13 @@ export const addLayerModel = (option, layerId) => {
94
94
  scene = new THREE.Scene()
95
95
 
96
96
  // 创建灯光
97
- opt.directionalLight.forEach((item, index) => {
98
- const directionalLight = new THREE.DirectionalLight(item.color, item.opacity)
99
- directionalLight.position.set(item.position[0], item.position[1], item.position[2]).normalize()
100
- scene.add(directionalLight)
101
- })
97
+ if (opt.directionalLight && opt.directionalLight.length > 0) {
98
+ opt.directionalLight.forEach(item => {
99
+ const directionalLight = new THREE.DirectionalLight(item.color, item.opacity)
100
+ directionalLight.position.set(item.position[0], item.position[1], item.position[2]).normalize()
101
+ scene.add(directionalLight)
102
+ })
103
+ }
102
104
 
103
105
  if (opt.ambientLight) {
104
106
  const light = new THREE.AmbientLight(0xffffff, 0.8)
package/src/map.js CHANGED
@@ -9,6 +9,7 @@ var defaultOptions = {
9
9
  pitchWithRotate: true, // 禁止绕x轴旋转 false禁止
10
10
  attributionControl: true, // 隐藏地图所属信息
11
11
  projection: 'globe',
12
+ fog: true, // 雾
12
13
  style: 'mapbox://styles/mapbox-map-design/ckhqrf2tz0dt119ny6azh975y',
13
14
  defaultLanguage: 'zh'
14
15
  // style: 'mapbox://styles/mapbox/streets-v9',
@@ -96,8 +97,8 @@ class mapSdk {
96
97
  let map = this.map
97
98
  map.addSource('mapbox-dem', {
98
99
  'type': 'raster-dem',
99
- // 'url': 'mapbox://mapbox.mapbox-terrain-dem-v1',
100
- 'url': 'mapbox://mapbox.terrain-rgb',
100
+ 'url': 'mapbox://mapbox.mapbox-terrain-dem-v1',
101
+ // 'url': 'mapbox://mapbox.terrain-rgb',
101
102
  'tileSize': 512,
102
103
  'maxzoom': 14
103
104
  })
@@ -111,6 +112,7 @@ class mapSdk {
111
112
  * 添加雾
112
113
  */
113
114
  addFog(night = false) {
115
+ if (!this.options.fog) return
114
116
  let map = this.map
115
117
  if (night || this.options.night) {
116
118
  // 晚上
@@ -0,0 +1,44 @@
1
+ <template>
2
+ <div ref="dom">
3
+ <slot></slot>
4
+ </div>
5
+ </template>
6
+
7
+ <script>
8
+ import mapBoxGl from 'mapbox-gl'
9
+
10
+ export default {
11
+ props: {
12
+ map: {
13
+ type: Object,
14
+ default: () => { }
15
+ },
16
+ position: {
17
+ type: Array,
18
+ default: () => []
19
+ },
20
+ drag: {
21
+ type: Boolean,
22
+ default: false
23
+ }
24
+ },
25
+ data () {
26
+ return {}
27
+ },
28
+ watch: {
29
+ map () {
30
+ let el = this.$refs.dom
31
+ const marker = new mapBoxGl.Marker(el, { draggable: this.drag }).setLngLat(this.position).addTo(this.map)
32
+ if (this.drag) {
33
+ marker.on('dragend', () => {
34
+ const lngLat = marker.getLngLat()
35
+ this.$emit('dragEnd', lngLat)
36
+ })
37
+ }
38
+ }
39
+ }
40
+ }
41
+ </script>
42
+
43
+ <style lang="scss" scoped>
44
+ </style>