|
@@ -37,23 +37,25 @@
|
37
|
37
|
|
38
|
38
|
onMounted(() => {
|
39
|
39
|
const map = new BMap.Map(el.value);
|
40
|
|
- const point = new BMap.Point(116.404, 39.915); // 天安门
|
|
40
|
+ // const point = new BMap.Point(116.404, 39.915); // 天安门
|
|
41
|
+ const point = new BMap.Point(118.749731,32.04067);
|
41
|
42
|
map.centerAndZoom(point, 3);
|
42
|
43
|
mapRef.value = map;
|
43
|
44
|
|
44
|
45
|
// 绑定事件
|
45
|
46
|
map.addEventListener('click', (e) => {
|
46
|
|
- console.log('-----start-----')
|
47
|
|
- loading.value = true;
|
48
|
|
- const { point } = e;
|
49
|
|
- getCountry(point.lng, point.lat).then(x => {
|
50
|
|
- emit('click', x);
|
51
|
|
- loading.value = false;
|
52
|
|
- console.log('-----end-----')
|
53
|
|
- }).catch((err) => {
|
54
|
|
- console.error(err);
|
55
|
|
- loading.value = false;
|
56
|
|
- });
|
|
47
|
+ // console.log('-----start-----')
|
|
48
|
+ // loading.value = true;
|
|
49
|
+ // const { point } = e;
|
|
50
|
+ // getCountry(point.lng, point.lat).then(x => {
|
|
51
|
+ // emit('click', x);
|
|
52
|
+ // loading.value = false;
|
|
53
|
+ // console.log('-----end-----')
|
|
54
|
+ // }).catch((err) => {
|
|
55
|
+ // console.error(err);
|
|
56
|
+ // loading.value = false;
|
|
57
|
+ // });
|
|
58
|
+ emit('click', '中国');
|
57
|
59
|
});
|
58
|
60
|
|
59
|
61
|
// 显示 marker
|
|
@@ -67,8 +69,15 @@
|
67
|
69
|
|
68
|
70
|
const point = new BMap.Point(target[0], target[1]);
|
69
|
71
|
const marker = new BMap.Marker(point, { icon });
|
|
72
|
+
|
|
73
|
+ //
|
|
74
|
+ marker.addEventListener('click', (e) => {
|
|
75
|
+ console.log('------marker----->', e)
|
|
76
|
+ emit('click', '中国');
|
|
77
|
+ });
|
|
78
|
+
|
70
|
79
|
map.addOverlay(marker);
|
71
|
|
- marker.setAnimation(BMAP_ANIMATION_BOUNCE);
|
|
80
|
+ // marker.setAnimation(BMAP_ANIMATION_BOUNCE);
|
72
|
81
|
|
73
|
82
|
// map.getOverlays().forEach((overlay) => {
|
74
|
83
|
// console.log('------overlay-------', overlay)
|