xy-map 1.0.39 → 1.0.41

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.39",
3
+ "version": "1.0.41",
4
4
  "description": "地图组件",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -19,7 +19,10 @@ const defaultOptions = {
19
19
  data: [],
20
20
  text: {
21
21
  show: true,
22
- layout: {},
22
+ layout: {
23
+ 'text-size': 10,
24
+ 'text-offset': [0, 1],
25
+ },
23
26
  paint: {}
24
27
  },
25
28
  image: {
@@ -98,6 +101,24 @@ export const addLayerPoint = (option, layerId) => { // 点
98
101
  if (opt.text && opt.text.show) {
99
102
  addLayerText('point', opt)
100
103
  }
104
+
105
+ // 高亮样式
106
+ if (opt.high) {
107
+ let highPaint = opt.high.paint ? opt.high.paint : {
108
+ 'circle-color': '#f00'
109
+ }
110
+ let highPaintOpt = Object.assign({
111
+ ...paintOpt,
112
+ }, highPaint)
113
+
114
+ map.addLayer({
115
+ id: id + '-high',
116
+ type: 'circle',
117
+ source: id,
118
+ paint: highPaintOpt,
119
+ filter: ['==', ['boolean', ['get', 'high']], true]
120
+ }, layerId)
121
+ }
101
122
  }
102
123
 
103
124
  /**
@@ -188,7 +209,7 @@ export const addLayerImagePoint = async (option, layerId) => { // 点
188
209
 
189
210
  let layout = opt.style ? opt.style.layout : {}
190
211
  let layoutOpt = Object.assign({
191
- 'icon-image': image.imageList && image.imageList.length > 0 ? ['get', 'imgId'] : `${id}-marker`,
212
+ 'icon-image': image.imageList && image.imageList.length > 0 ? ['get', opt.image.key || 'imgId'] : `${id}-marker`,
192
213
  'icon-size': 1,
193
214
  'text-field': ['get', 'name'],
194
215
  /* 使用text标签显示的值,Feature属性使用{域名}格式*/
@@ -92,7 +92,7 @@ export default {
92
92
 
93
93
  map.on('draw.create', this.drawEnd)
94
94
  map.on('draw.update', this.drawUpdate)
95
-
95
+ map.on('draw.selectionchange', this.select)
96
96
 
97
97
  // map.on('draw.modechange', (e) => {
98
98
  // const data = draw.getAll()
@@ -142,8 +142,11 @@ export default {
142
142
  this.$emit('clear')
143
143
  }
144
144
  },
145
- fullScreen () {
146
-
145
+ clear () {
146
+ this.drawDelete()
147
+ },
148
+ select (e) {
149
+ this.$emit('select', e.features)
147
150
  }
148
151
  }
149
152
  }
@@ -126,10 +126,8 @@ export default {
126
126
  this.edit()
127
127
  },
128
128
  edit () { // 开启编辑
129
- if (this.geoJson && this.geoJson.features.length > 0) {
130
- this.geoJson.features.forEach(item => {
131
- this.$refs.draw.drawEdit(item.geometry)
132
- })
129
+ if (this.geoJson) {
130
+ this.$refs.draw.drawEdit(this.geoJson)
133
131
  }
134
132
  },
135
133
  drawUpdate (data, autoZoom = false) {
@@ -126,10 +126,8 @@ export default {
126
126
  this.edit()
127
127
  },
128
128
  edit () { // 开启编辑
129
- if (this.geoJson && this.geoJson.features.length > 0) {
130
- this.geoJson.features.forEach(item => {
131
- this.$refs.draw.drawEdit(item.geometry)
132
- })
129
+ if (this.geoJson) {
130
+ this.$refs.draw.drawEdit(this.geoJson)
133
131
  }
134
132
  },
135
133
  drawUpdate (data, autoZoom = false) {
@@ -159,6 +157,7 @@ export default {
159
157
  this.position = ''
160
158
  },
161
159
  getShp (shp) {
160
+ console.log(shp)
162
161
  this.$refs.draw.drawDelete() // 先清空画布
163
162
  this.drawUpdate(shp, true)
164
163
  this.edit()