@styzy/vue-amap 1.2.1 → 1.3.0

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.
@@ -22,7 +22,7 @@ ___CSS_LOADER_EXPORT___.push([module.id, ".v-amap-ctn[data-v-0a8871e0],.v-amap-c
22
22
 
23
23
  /***/ }),
24
24
 
25
- /***/ 83:
25
+ /***/ 785:
26
26
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
27
27
 
28
28
  "use strict";
@@ -36,14 +36,14 @@ __webpack_require__.r(__webpack_exports__);
36
36
 
37
37
  var ___CSS_LOADER_EXPORT___ = _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1___default()((_node_modules_css_loader_dist_runtime_noSourceMaps_js__WEBPACK_IMPORTED_MODULE_0___default()));
38
38
  // Module
39
- ___CSS_LOADER_EXPORT___.push([module.id, ".v-amap-place-search-input input[data-v-01341cd6]{display:inline-block;box-sizing:border-box;padding:0 15px;width:100%;height:40px;outline:0;border:1px solid #dcdfe6;border-radius:4px;background-color:#fff;background-image:none;color:#606266;font-size:inherit;line-height:40px;transition:border-color .2s cubic-bezier(.645,.045,.355,1);-webkit-appearance:none}.v-amap-place-search-input input[data-v-01341cd6]::-webkit-input-placeholder{color:#c0c4cc}.v-amap-place-search-input input.is-disabled[data-v-01341cd6]{border-color:#e4e7ed;background-color:#f5f7fa;color:#c0c4cc;cursor:not-allowed}", ""]);
39
+ ___CSS_LOADER_EXPORT___.push([module.id, ".v-amap-place-search-input[data-v-0b77a6ce]{position:relative}.v-amap-place-search-input input[data-v-0b77a6ce]{display:inline-block;box-sizing:border-box;padding:0 15px;width:100%;height:40px;outline:0;border:1px solid #dcdfe6;border-radius:4px;background-color:#fff;background-image:none;color:#606266;font-size:inherit;line-height:40px;transition:border-color .2s cubic-bezier(.645,.045,.355,1);-webkit-appearance:none}.v-amap-place-search-input input[data-v-0b77a6ce]::-webkit-input-placeholder{color:#c0c4cc}.v-amap-place-search-input input.is-disabled[data-v-0b77a6ce]{border-color:#e4e7ed;background-color:#f5f7fa;color:#c0c4cc;cursor:not-allowed}.v-amap-place-search-input .option-ctn[data-v-0b77a6ce]{position:absolute;top:100%;right:0;left:0;z-index:1;box-sizing:border-box;border:1px solid #dcdfe6;background-color:#fff}.v-amap-place-search-input .option-ctn .option[data-v-0b77a6ce]{overflow:hidden;padding-right:5px;padding-left:15px;height:40px;text-overflow:ellipsis;white-space:nowrap;font-size:12px;line-height:40px;cursor:pointer}.v-amap-place-search-input .option-ctn .option[data-v-0b77a6ce]:hover{background-color:#f4f5f6}.v-amap-place-search-input .option-ctn .option .name[data-v-0b77a6ce]{color:#424242}.v-amap-place-search-input .option-ctn .option .city[data-v-0b77a6ce]{margin-left:10px;color:#aaa}", ""]);
40
40
  // Exports
41
41
  /* harmony default export */ __webpack_exports__["default"] = (___CSS_LOADER_EXPORT___);
42
42
 
43
43
 
44
44
  /***/ }),
45
45
 
46
- /***/ 820:
46
+ /***/ 192:
47
47
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
48
48
 
49
49
  "use strict";
@@ -184,35 +184,35 @@ var update = add("7ebf2e0a", content, true, {"sourceMap":false,"shadowMode":fals
184
184
 
185
185
  /***/ }),
186
186
 
187
- /***/ 427:
187
+ /***/ 985:
188
188
  /***/ (function(module, __unused_webpack_exports, __webpack_require__) {
189
189
 
190
190
  // style-loader: Adds some css to the DOM by adding a <style> tag
191
191
 
192
192
  // load the styles
193
- var content = __webpack_require__(83);
193
+ var content = __webpack_require__(785);
194
194
  if(content.__esModule) content = content.default;
195
195
  if(typeof content === 'string') content = [[module.id, content, '']];
196
196
  if(content.locals) module.exports = content.locals;
197
197
  // add the styles to the DOM
198
198
  var add = (__webpack_require__(402)/* ["default"] */ .Z)
199
- var update = add("a0517e8c", content, true, {"sourceMap":false,"shadowMode":false});
199
+ var update = add("f9ce54c6", content, true, {"sourceMap":false,"shadowMode":false});
200
200
 
201
201
  /***/ }),
202
202
 
203
- /***/ 641:
203
+ /***/ 427:
204
204
  /***/ (function(module, __unused_webpack_exports, __webpack_require__) {
205
205
 
206
206
  // style-loader: Adds some css to the DOM by adding a <style> tag
207
207
 
208
208
  // load the styles
209
- var content = __webpack_require__(820);
209
+ var content = __webpack_require__(192);
210
210
  if(content.__esModule) content = content.default;
211
211
  if(typeof content === 'string') content = [[module.id, content, '']];
212
212
  if(content.locals) module.exports = content.locals;
213
213
  // add the styles to the DOM
214
214
  var add = (__webpack_require__(402)/* ["default"] */ .Z)
215
- var update = add("1cb88330", content, true, {"sourceMap":false,"shadowMode":false});
215
+ var update = add("41bfd6da", content, true, {"sourceMap":false,"shadowMode":false});
216
216
 
217
217
  /***/ }),
218
218
 
@@ -1341,16 +1341,37 @@ var VAMapPolygon_component = normalizeComponent(
1341
1341
  )
1342
1342
 
1343
1343
  /* harmony default export */ var VAMapPolygon = (VAMapPolygon_component.exports);
1344
- ;// CONCATENATED MODULE: ./node_modules/@vue/vue-loader-v15/lib/loaders/templateLoader.js??ruleSet[1].rules[3]!./node_modules/pug-plain-loader/index.js!./node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./src/Components/VAMapPlaceSearchInput.vue?vue&type=template&id=01341cd6&scoped=true&lang=pug
1345
- var VAMapPlaceSearchInputvue_type_template_id_01341cd6_scoped_true_lang_pug_render = function render(){var _vm=this,_c=_vm._self._c;return _c('div',{staticClass:"v-amap-place-search-input"},[_c('input',{ref:"input",class:{ 'is-disabled': _vm.disabled },attrs:{"disabled":_vm.disabled,"placeholder":_vm.placeholder},domProps:{"value":_vm.value},on:{"blur":function($event){return _vm.handleBlur()},"input":_vm.handleInput}})])
1344
+ ;// CONCATENATED MODULE: ./node_modules/@vue/vue-loader-v15/lib/loaders/templateLoader.js??ruleSet[1].rules[3]!./node_modules/pug-plain-loader/index.js!./node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./src/Components/VAMapPlaceSearchInput.vue?vue&type=template&id=0b77a6ce&scoped=true&lang=pug
1345
+ var VAMapPlaceSearchInputvue_type_template_id_0b77a6ce_scoped_true_lang_pug_render = function render(){var _vm=this,_c=_vm._self._c;return _c('div',{staticClass:"v-amap-place-search-input"},[_c('input',{ref:"input",class:{ 'is-disabled': _vm.disabled },attrs:{"disabled":_vm.disabled,"placeholder":_vm.placeholder},domProps:{"value":_vm.value},on:{"blur":function($event){return _vm.handleBlur()},"focus":function($event){return _vm.handleFocus()},"input":function($event){return _vm.handleInput($event)}}}),(_vm.placeList.length)?_c('div',{staticClass:"option-ctn"},_vm._l((_vm.placeList),function(place){return _c('div',{staticClass:"option",attrs:{"title":place.name + place.cityname},on:{"click":function($event){return _vm.handlePlaceSelect(place)}}},[_c('span',{staticClass:"name"},[_vm._v(_vm._s(place.name))]),_c('span',{staticClass:"city"},[_vm._v(_vm._s(place.cityname))])])}),0):_vm._e()])
1346
1346
  }
1347
- var VAMapPlaceSearchInputvue_type_template_id_01341cd6_scoped_true_lang_pug_staticRenderFns = []
1348
-
1347
+ var VAMapPlaceSearchInputvue_type_template_id_0b77a6ce_scoped_true_lang_pug_staticRenderFns = []
1348
+
1349
+
1350
+ ;// CONCATENATED MODULE: ./src/utils/isParentNode.js
1351
+ // 是否是父节点
1352
+ const isParentNode = function (parentObj, obj) {
1353
+ if (parentObj === obj) return false
1354
+ while (
1355
+ obj != undefined &&
1356
+ obj != null &&
1357
+ obj.tagName &&
1358
+ obj.tagName.toUpperCase() != 'BODY'
1359
+ ) {
1360
+ if (obj == parentObj) {
1361
+ return true
1362
+ }
1363
+ obj = obj.parentNode
1364
+ }
1365
+ return false
1366
+ }
1367
+
1368
+ /* harmony default export */ var utils_isParentNode = (isParentNode);
1349
1369
 
1350
1370
  ;// CONCATENATED MODULE: ./node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./src/Components/VAMapPlaceSearchInput.vue?vue&type=script&lang=js
1351
1371
 
1352
1372
 
1353
1373
 
1374
+
1354
1375
  /* harmony default export */ var VAMapPlaceSearchInputvue_type_script_lang_js = ({
1355
1376
  name: 'VAMapPlaceSearchInput',
1356
1377
  model: {
@@ -1378,91 +1399,135 @@ var VAMapPlaceSearchInputvue_type_template_id_01341cd6_scoped_true_lang_pug_stat
1378
1399
  data() {
1379
1400
  return {
1380
1401
  AMap: null,
1381
- placeName: '',
1382
- autocompleteListener: null,
1383
- placeSearchListener: null
1402
+ placeSearch: null,
1403
+ placeList: [],
1404
+ place: null
1384
1405
  }
1385
1406
  },
1386
- async mounted() {
1387
- this.AMap = await loader.load()
1388
- this.addListener()
1407
+ watch: {
1408
+ place() {
1409
+ this.$emit('change', this.place ? this.place.name : '')
1410
+ this.$emit(
1411
+ 'locationChange',
1412
+ this.place
1413
+ ? [this.place.location.lng, this.place.location.lat]
1414
+ : null
1415
+ )
1416
+ this.$emit('placeChange', this.place)
1417
+ }
1389
1418
  },
1390
- destroyed() {
1391
- this.removeListener()
1419
+ mounted() {
1420
+ window.addEventListener('click', this.optionsHideListener, true)
1421
+ window.addEventListener('contextmenu', this.optionsHideListener, true)
1422
+ },
1423
+ beforeDestroy() {
1424
+ window.removeEventListener('click', this.optionsHideListener, true)
1425
+ window.removeEventListener(
1426
+ 'contextmenu',
1427
+ this.optionsHideListener,
1428
+ true
1429
+ )
1392
1430
  },
1393
1431
  methods: {
1394
- async addListener() {
1395
- const autocomplete = new this.AMap.Autocomplete({
1396
- input: this.$refs.input
1397
- }),
1398
- placeSearch = new this.AMap.PlaceSearch({})
1399
-
1400
- this.autocompleteListener = this.AMap.event.addListener(
1401
- autocomplete,
1402
- 'select',
1403
- event => {
1404
- this.placeName = event.poi.name
1405
- placeSearch.search(event.poi.name)
1406
- }
1407
- )
1408
-
1409
- this.placeSearchListener = this.AMap.event.addListener(
1410
- placeSearch,
1411
- 'complete',
1412
- event => {
1413
- var position = null
1414
- if (
1415
- event &&
1416
- event.poiList &&
1417
- event.poiList.pois &&
1418
- event.poiList.pois.length
1419
- ) {
1420
- position = [
1421
- event.poiList.pois[0].location.lng,
1422
- event.poiList.pois[0].location.lat
1423
- ]
1424
- }
1425
-
1426
- if (!position && !this.customEnable) {
1427
- this.clear()
1428
- } else {
1429
- this.$emit('change', this.placeName)
1430
- this.$emit('locationChange', position)
1431
- }
1432
+ async createPlaceSearch() {
1433
+ this.AMap = await loader.load()
1434
+ this.placeSearch = new this.AMap.PlaceSearch({
1435
+ extensions: 'all'
1436
+ })
1437
+ },
1438
+ async getPlaceList() {
1439
+ if (!this.placeSearch) {
1440
+ await this.createPlaceSearch()
1441
+ }
1442
+ this.placeSearch.search(this.value, (status, result) => {
1443
+ if (status === 'complete') {
1444
+ this.placeList = result?.poiList?.pois || []
1445
+ } else {
1446
+ this.placeList = []
1432
1447
  }
1433
- )
1448
+ })
1434
1449
  },
1435
- removeListener() {
1436
- this.AMap.event.removeListener(this.autocompleteListener)
1437
- this.AMap.event.removeListener(this.placeSearchListener)
1450
+ async handleInput(event) {
1451
+ this.$emit('change', event.target.value)
1452
+ await this.$nextTick()
1453
+ this.getPlaceList()
1438
1454
  },
1439
- clear() {
1440
- this.placeName = ''
1441
- this.$emit('change', '')
1442
- this.$emit('locationChange', null)
1455
+ handlePlaceSelect(place = null) {
1456
+ this.place = place
1457
+ this.placeList = []
1458
+ },
1459
+ handleFocus() {
1460
+ if (this.value?.trim()) {
1461
+ this.getPlaceList()
1462
+ }
1443
1463
  },
1444
1464
  handleBlur() {
1445
- if (this.value !== this.placeName) {
1446
- if (!this.customEnable) {
1447
- this.clear()
1448
- }
1465
+ if (this.customEnable) return
1466
+ if (this.value !== this.place?.name) {
1467
+ this.clear()
1449
1468
  }
1450
1469
  },
1451
- handleInput(event) {
1452
- this.$emit('change', event.target.value)
1470
+ optionsHideListener(event) {
1471
+ if (utils_isParentNode(this.$el, event.target)) return
1472
+ this.placeList = []
1473
+ },
1474
+ clear() {
1475
+ this.place = null
1476
+ this.$emit('change', '')
1453
1477
  }
1478
+ // async addListener() {
1479
+ // const autocomplete = new this.AMap.Autocomplete({
1480
+ // input: this.$refs.input
1481
+ // }),
1482
+ // placeSearch = new this.AMap.PlaceSearch({})
1483
+
1484
+ // this.autocompleteListener = this.AMap.event.addListener(
1485
+ // autocomplete,
1486
+ // 'select',
1487
+ // event => {
1488
+ // this.placeName = event.poi.name
1489
+ // placeSearch.search(event.poi.name)
1490
+ // }
1491
+ // )
1492
+
1493
+ // this.placeSearchListener = this.AMap.event.addListener(
1494
+ // placeSearch,
1495
+ // 'complete',
1496
+ // event => {
1497
+ // var position = null
1498
+ // if (
1499
+ // event &&
1500
+ // event.poiList &&
1501
+ // event.poiList.pois &&
1502
+ // event.poiList.pois.length
1503
+ // ) {
1504
+ // position = [
1505
+ // event.poiList.pois[0].location.lng,
1506
+ // event.poiList.pois[0].location.lat
1507
+ // ]
1508
+ // }
1509
+
1510
+ // if (!position && !this.customEnable) {
1511
+ // this.clear()
1512
+ // } else {
1513
+ // this.$emit('change', this.placeName)
1514
+ // this.$emit('locationChange', position)
1515
+ // }
1516
+ // }
1517
+ // )
1518
+ // },
1454
1519
  }
1455
1520
  });
1456
1521
 
1457
1522
  ;// CONCATENATED MODULE: ./src/Components/VAMapPlaceSearchInput.vue?vue&type=script&lang=js
1458
1523
  /* harmony default export */ var Components_VAMapPlaceSearchInputvue_type_script_lang_js = (VAMapPlaceSearchInputvue_type_script_lang_js);
1459
- // EXTERNAL MODULE: ./node_modules/vue-style-loader/index.js??clonedRuleSet-34.use[0]!./node_modules/css-loader/dist/cjs.js??clonedRuleSet-34.use[1]!./node_modules/@vue/vue-loader-v15/lib/loaders/stylePostLoader.js!./node_modules/postcss-loader/dist/cjs.js??clonedRuleSet-34.use[2]!./node_modules/postcss-loader/dist/cjs.js??clonedRuleSet-34.use[3]!./node_modules/stylus-loader/index.js??clonedRuleSet-34.use[4]!./node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./src/Components/VAMapPlaceSearchInput.vue?vue&type=style&index=0&id=01341cd6&prod&lang=stylus&scoped=true
1460
- var VAMapPlaceSearchInputvue_type_style_index_0_id_01341cd6_prod_lang_stylus_scoped_true = __webpack_require__(427);
1461
- ;// CONCATENATED MODULE: ./src/Components/VAMapPlaceSearchInput.vue?vue&type=style&index=0&id=01341cd6&prod&lang=stylus&scoped=true
1524
+ // EXTERNAL MODULE: ./node_modules/vue-style-loader/index.js??clonedRuleSet-34.use[0]!./node_modules/css-loader/dist/cjs.js??clonedRuleSet-34.use[1]!./node_modules/@vue/vue-loader-v15/lib/loaders/stylePostLoader.js!./node_modules/postcss-loader/dist/cjs.js??clonedRuleSet-34.use[2]!./node_modules/postcss-loader/dist/cjs.js??clonedRuleSet-34.use[3]!./node_modules/stylus-loader/index.js??clonedRuleSet-34.use[4]!./node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./src/Components/VAMapPlaceSearchInput.vue?vue&type=style&index=0&id=0b77a6ce&prod&lang=stylus&scoped=true
1525
+ var VAMapPlaceSearchInputvue_type_style_index_0_id_0b77a6ce_prod_lang_stylus_scoped_true = __webpack_require__(985);
1526
+ ;// CONCATENATED MODULE: ./src/Components/VAMapPlaceSearchInput.vue?vue&type=style&index=0&id=0b77a6ce&prod&lang=stylus&scoped=true
1462
1527
 
1463
- // EXTERNAL MODULE: ./node_modules/vue-style-loader/index.js??clonedRuleSet-34.use[0]!./node_modules/css-loader/dist/cjs.js??clonedRuleSet-34.use[1]!./node_modules/@vue/vue-loader-v15/lib/loaders/stylePostLoader.js!./node_modules/postcss-loader/dist/cjs.js??clonedRuleSet-34.use[2]!./node_modules/postcss-loader/dist/cjs.js??clonedRuleSet-34.use[3]!./node_modules/stylus-loader/index.js??clonedRuleSet-34.use[4]!./node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./src/Components/VAMapPlaceSearchInput.vue?vue&type=style&index=1&id=01341cd6&prod&lang=stylus
1464
- var VAMapPlaceSearchInputvue_type_style_index_1_id_01341cd6_prod_lang_stylus = __webpack_require__(641);
1465
- ;// CONCATENATED MODULE: ./src/Components/VAMapPlaceSearchInput.vue?vue&type=style&index=1&id=01341cd6&prod&lang=stylus
1528
+ // EXTERNAL MODULE: ./node_modules/vue-style-loader/index.js??clonedRuleSet-34.use[0]!./node_modules/css-loader/dist/cjs.js??clonedRuleSet-34.use[1]!./node_modules/@vue/vue-loader-v15/lib/loaders/stylePostLoader.js!./node_modules/postcss-loader/dist/cjs.js??clonedRuleSet-34.use[2]!./node_modules/postcss-loader/dist/cjs.js??clonedRuleSet-34.use[3]!./node_modules/stylus-loader/index.js??clonedRuleSet-34.use[4]!./node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./src/Components/VAMapPlaceSearchInput.vue?vue&type=style&index=1&id=0b77a6ce&prod&lang=stylus
1529
+ var VAMapPlaceSearchInputvue_type_style_index_1_id_0b77a6ce_prod_lang_stylus = __webpack_require__(427);
1530
+ ;// CONCATENATED MODULE: ./src/Components/VAMapPlaceSearchInput.vue?vue&type=style&index=1&id=0b77a6ce&prod&lang=stylus
1466
1531
 
1467
1532
  ;// CONCATENATED MODULE: ./src/Components/VAMapPlaceSearchInput.vue
1468
1533
 
@@ -1476,11 +1541,11 @@ var VAMapPlaceSearchInputvue_type_style_index_1_id_01341cd6_prod_lang_stylus = _
1476
1541
 
1477
1542
  var VAMapPlaceSearchInput_component = normalizeComponent(
1478
1543
  Components_VAMapPlaceSearchInputvue_type_script_lang_js,
1479
- VAMapPlaceSearchInputvue_type_template_id_01341cd6_scoped_true_lang_pug_render,
1480
- VAMapPlaceSearchInputvue_type_template_id_01341cd6_scoped_true_lang_pug_staticRenderFns,
1544
+ VAMapPlaceSearchInputvue_type_template_id_0b77a6ce_scoped_true_lang_pug_render,
1545
+ VAMapPlaceSearchInputvue_type_template_id_0b77a6ce_scoped_true_lang_pug_staticRenderFns,
1481
1546
  false,
1482
1547
  null,
1483
- "01341cd6",
1548
+ "0b77a6ce",
1484
1549
  null
1485
1550
 
1486
1551
  )
@@ -1502,7 +1567,7 @@ var VAMapPlaceSearchInput_component = normalizeComponent(
1502
1567
  ]);
1503
1568
 
1504
1569
  ;// CONCATENATED MODULE: ./package.json
1505
- var package_namespaceObject = {"i8":"1.2.1"};
1570
+ var package_namespaceObject = {"i8":"1.3.0"};
1506
1571
  ;// CONCATENATED MODULE: ./src/config/index.js
1507
1572
 
1508
1573