tdt-map-vue 1.0.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.
- package/README.md +243 -0
- package/dist/index.cjs.js +523 -0
- package/dist/index.cjs.js.map +1 -0
- package/dist/index.es.js +517 -0
- package/dist/index.es.js.map +1 -0
- package/dist/index.umd.js +527 -0
- package/dist/index.umd.js.map +1 -0
- package/package.json +56 -0
|
@@ -0,0 +1,527 @@
|
|
|
1
|
+
(function (global, factory) {
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('vue')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports', 'vue'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.VueTiandituComponent = {}, global.Vue));
|
|
5
|
+
})(this, (function (exports, vue) { 'use strict';
|
|
6
|
+
|
|
7
|
+
const DEFAULT_ICON = "https://api.tianditu.gov.cn/v4.0/image/marker-icon.png";
|
|
8
|
+
const SCRIPT_ID = "tianditu-map-script";
|
|
9
|
+
|
|
10
|
+
var script = {
|
|
11
|
+
name: "TiandiMap",
|
|
12
|
+
emits: [
|
|
13
|
+
"ready",
|
|
14
|
+
"error",
|
|
15
|
+
"marker-click",
|
|
16
|
+
"addsuccess",
|
|
17
|
+
"hidesuccess",
|
|
18
|
+
"search-success",
|
|
19
|
+
"search-error",
|
|
20
|
+
],
|
|
21
|
+
props: {
|
|
22
|
+
version: {
|
|
23
|
+
type: String,
|
|
24
|
+
default: "4.0",
|
|
25
|
+
},
|
|
26
|
+
tk: {
|
|
27
|
+
type: String,
|
|
28
|
+
default: "7e9c0399a2b7d8561e02ff7cf1bcaffe",
|
|
29
|
+
},
|
|
30
|
+
containerStyle: {
|
|
31
|
+
type: Object,
|
|
32
|
+
default: () => ({
|
|
33
|
+
width: "100%",
|
|
34
|
+
height: "100vh",
|
|
35
|
+
}),
|
|
36
|
+
},
|
|
37
|
+
center: {
|
|
38
|
+
type: Array,
|
|
39
|
+
default: () => [117.017362, 25.075884],
|
|
40
|
+
},
|
|
41
|
+
zoom: {
|
|
42
|
+
type: Number,
|
|
43
|
+
default: 10,
|
|
44
|
+
},
|
|
45
|
+
minZoom: {
|
|
46
|
+
type: Number,
|
|
47
|
+
default: 1,
|
|
48
|
+
},
|
|
49
|
+
maxZoom: {
|
|
50
|
+
type: Number,
|
|
51
|
+
default: 18,
|
|
52
|
+
},
|
|
53
|
+
markers: {
|
|
54
|
+
type: Array,
|
|
55
|
+
default: () => [],
|
|
56
|
+
},
|
|
57
|
+
showZoom: {
|
|
58
|
+
type: Boolean,
|
|
59
|
+
default: true,
|
|
60
|
+
},
|
|
61
|
+
dragEnable: {
|
|
62
|
+
type: Boolean,
|
|
63
|
+
default: true,
|
|
64
|
+
},
|
|
65
|
+
scrollWheelZoom: {
|
|
66
|
+
type: Boolean,
|
|
67
|
+
default: true,
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
|
|
71
|
+
data() {
|
|
72
|
+
return {
|
|
73
|
+
mapContainerId: `tianditu-map-${Math.random().toString(36).slice(2, 11)}`,
|
|
74
|
+
map: null,
|
|
75
|
+
overlays: [],
|
|
76
|
+
scriptLoaded: false,
|
|
77
|
+
geocoder: null,
|
|
78
|
+
newMarkers: [],
|
|
79
|
+
visibleMarkers: [],
|
|
80
|
+
markerMap: {},
|
|
81
|
+
labelMap: {},
|
|
82
|
+
searchInput: null,
|
|
83
|
+
searchClearBtn: null,
|
|
84
|
+
scriptEl: null,
|
|
85
|
+
currentLocation: null,
|
|
86
|
+
controlsAdded: false,
|
|
87
|
+
// 拾取坐标点
|
|
88
|
+
lnglat: null,
|
|
89
|
+
};
|
|
90
|
+
},
|
|
91
|
+
|
|
92
|
+
mounted() {
|
|
93
|
+
this.loadTiandituScript();
|
|
94
|
+
},
|
|
95
|
+
beforeDestroy() {
|
|
96
|
+
this.destroyMap();
|
|
97
|
+
},
|
|
98
|
+
beforeUnmount() {
|
|
99
|
+
this.destroyMap();
|
|
100
|
+
},
|
|
101
|
+
watch: {
|
|
102
|
+
markers: {
|
|
103
|
+
deep: true,
|
|
104
|
+
handler() {
|
|
105
|
+
if (!this.map) return;
|
|
106
|
+
this.clearAllMarkers();
|
|
107
|
+
this.renderMarkers();
|
|
108
|
+
},
|
|
109
|
+
},
|
|
110
|
+
containerStyle: {
|
|
111
|
+
deep: true,
|
|
112
|
+
handler() {
|
|
113
|
+
if (this.map) this.resizeMap();
|
|
114
|
+
},
|
|
115
|
+
},
|
|
116
|
+
},
|
|
117
|
+
|
|
118
|
+
methods: {
|
|
119
|
+
loadTiandituScript() {
|
|
120
|
+
if (typeof window === "undefined" || typeof document === "undefined")
|
|
121
|
+
return;
|
|
122
|
+
if (window.T) {
|
|
123
|
+
this.scriptLoaded = true;
|
|
124
|
+
this.initMap();
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
const existing = document.getElementById(SCRIPT_ID);
|
|
129
|
+
if (existing) {
|
|
130
|
+
this.scriptEl = existing;
|
|
131
|
+
existing.addEventListener(
|
|
132
|
+
"load",
|
|
133
|
+
() => {
|
|
134
|
+
this.scriptLoaded = true;
|
|
135
|
+
this.initMap();
|
|
136
|
+
},
|
|
137
|
+
{ once: true },
|
|
138
|
+
);
|
|
139
|
+
existing.addEventListener(
|
|
140
|
+
"error",
|
|
141
|
+
() => {
|
|
142
|
+
this.$emit("error", new Error("天地图API加载失败"));
|
|
143
|
+
},
|
|
144
|
+
{ once: true },
|
|
145
|
+
);
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
const script = document.createElement("script");
|
|
150
|
+
script.id = SCRIPT_ID;
|
|
151
|
+
script.type = "text/javascript";
|
|
152
|
+
script.async = true;
|
|
153
|
+
script.src = `https://api.tianditu.gov.cn/api?v=${this.version}&tk=${this.tk}`;
|
|
154
|
+
script.onload = () => {
|
|
155
|
+
this.scriptLoaded = true;
|
|
156
|
+
this.initMap();
|
|
157
|
+
};
|
|
158
|
+
script.onerror = () => {
|
|
159
|
+
this.$emit("error", new Error("天地图API加载失败"));
|
|
160
|
+
};
|
|
161
|
+
this.scriptEl = script;
|
|
162
|
+
document.head.appendChild(script);
|
|
163
|
+
},
|
|
164
|
+
// 获取拾取的坐标
|
|
165
|
+
getLngLat(lnglat) {
|
|
166
|
+
console.log(lnglat);
|
|
167
|
+
this.lnglat = lnglat;
|
|
168
|
+
},
|
|
169
|
+
// 获取拾取的坐标
|
|
170
|
+
getMapLngLat() {
|
|
171
|
+
return this.lnglat;
|
|
172
|
+
},
|
|
173
|
+
initMap() {
|
|
174
|
+
if (
|
|
175
|
+
typeof window === "undefined" ||
|
|
176
|
+
!this.scriptLoaded ||
|
|
177
|
+
!window.T ||
|
|
178
|
+
this.map
|
|
179
|
+
)
|
|
180
|
+
return;
|
|
181
|
+
try {
|
|
182
|
+
this.map = new window.T.Map(this.mapContainerId);
|
|
183
|
+
this.geocoder = new window.T.Geocoder();
|
|
184
|
+
this.setCenterAndZoom();
|
|
185
|
+
this.map.setMinZoom(this.minZoom);
|
|
186
|
+
this.map.setMaxZoom(this.maxZoom);
|
|
187
|
+
// 坐标拾取
|
|
188
|
+
var cp = new window.T.CoordinatePickup(this.map, {
|
|
189
|
+
callback: this.getLngLat,
|
|
190
|
+
});
|
|
191
|
+
cp.addEvent(function (lnglat) {
|
|
192
|
+
console.log(lnglat);
|
|
193
|
+
});
|
|
194
|
+
// 地图类型控件
|
|
195
|
+
if (!this.controlsAdded) {
|
|
196
|
+
if (window.T.Control && window.T.Control.MapType) {
|
|
197
|
+
const mapTypeControl = new window.T.Control.MapType({
|
|
198
|
+
position: window.T_ANCHOR_TOP_RIGHT,
|
|
199
|
+
});
|
|
200
|
+
this.map.addControl(mapTypeControl);
|
|
201
|
+
}
|
|
202
|
+
this.controlsAdded = true;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
if (
|
|
206
|
+
this.showZoom &&
|
|
207
|
+
this.map &&
|
|
208
|
+
typeof this.map.enableScrollWheelZoom === "function"
|
|
209
|
+
) {
|
|
210
|
+
this.map.enableScrollWheelZoom();
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
if (this.dragEnable) {
|
|
214
|
+
this.map.enableDrag();
|
|
215
|
+
} else {
|
|
216
|
+
this.map.disableDrag();
|
|
217
|
+
}
|
|
218
|
+
if (this.scrollWheelZoom) {
|
|
219
|
+
this.map.enableScrollWheelZoom();
|
|
220
|
+
} else {
|
|
221
|
+
this.map.disableScrollWheelZoom();
|
|
222
|
+
}
|
|
223
|
+
this.renderMarkers();
|
|
224
|
+
this.$emit("ready", this.map);
|
|
225
|
+
this.addSearchControl();
|
|
226
|
+
} catch (error) {
|
|
227
|
+
this.$emit("error", error);
|
|
228
|
+
}
|
|
229
|
+
},
|
|
230
|
+
|
|
231
|
+
openInfo(content, e) {
|
|
232
|
+
const point = e.lnglat;
|
|
233
|
+
const markerInfoWin = new window.T.InfoWindow(content, {
|
|
234
|
+
offset: new window.T.Point(0, -30),
|
|
235
|
+
});
|
|
236
|
+
this.map.openInfoWindow(markerInfoWin, point);
|
|
237
|
+
},
|
|
238
|
+
|
|
239
|
+
renderMarkers() {
|
|
240
|
+
if (!Array.isArray(this.markers) || !this.map) return;
|
|
241
|
+
this.markers.forEach((markerData) => {
|
|
242
|
+
this.createMarker(markerData);
|
|
243
|
+
});
|
|
244
|
+
},
|
|
245
|
+
|
|
246
|
+
createMarker(markerData) {
|
|
247
|
+
if (!this.map || typeof window === "undefined" || !window.T) return null;
|
|
248
|
+
const { lng, lat, option = {} } = markerData;
|
|
249
|
+
const markerId = markerData.id || this.generateId();
|
|
250
|
+
const { iconInfo = {}, content, textInfo } = option;
|
|
251
|
+
if (typeof lng !== "number" || typeof lat !== "number") {
|
|
252
|
+
return null;
|
|
253
|
+
}
|
|
254
|
+
const position = new window.T.LngLat(lng, lat);
|
|
255
|
+
let marker;
|
|
256
|
+
|
|
257
|
+
if (iconInfo) {
|
|
258
|
+
const { icon = DEFAULT_ICON, offsetX = 25, offsetY = 41 } = iconInfo;
|
|
259
|
+
const iconObj = new window.T.Icon({
|
|
260
|
+
iconUrl: icon,
|
|
261
|
+
iconSize: new window.T.Point(offsetX, offsetY),
|
|
262
|
+
iconAnchor: new window.T.Point(offsetX / 2, offsetY),
|
|
263
|
+
});
|
|
264
|
+
marker = new window.T.Marker(position, { icon: iconObj });
|
|
265
|
+
} else {
|
|
266
|
+
marker = new window.T.Marker(position);
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
marker.addEventListener("click", (e) => {
|
|
270
|
+
this.$emit("marker-click", { markerData, event: e });
|
|
271
|
+
|
|
272
|
+
if (content) {
|
|
273
|
+
this.openInfo(content, e);
|
|
274
|
+
}
|
|
275
|
+
});
|
|
276
|
+
|
|
277
|
+
if (textInfo && textInfo.text) {
|
|
278
|
+
const label = new window.T.Label({
|
|
279
|
+
text: textInfo.text,
|
|
280
|
+
position,
|
|
281
|
+
offset: new window.T.Point(
|
|
282
|
+
textInfo.offsetX || 3,
|
|
283
|
+
textInfo.offsetY || -30,
|
|
284
|
+
),
|
|
285
|
+
});
|
|
286
|
+
this.map.addOverLay(label);
|
|
287
|
+
this.overlays.push(label);
|
|
288
|
+
this.labelMap[markerId] = label;
|
|
289
|
+
}
|
|
290
|
+
this.map.addOverLay(marker);
|
|
291
|
+
this.overlays.push(marker);
|
|
292
|
+
this.markerMap[markerId] = marker;
|
|
293
|
+
return marker;
|
|
294
|
+
},
|
|
295
|
+
|
|
296
|
+
addMarkers(newMarkers) {
|
|
297
|
+
if (!Array.isArray(newMarkers) || !newMarkers.length) return;
|
|
298
|
+
const newAddMarkers = [];
|
|
299
|
+
newMarkers.forEach((marker) => {
|
|
300
|
+
const nextMarker = { ...marker, id: marker.id || this.generateId() };
|
|
301
|
+
this.newMarkers.push(nextMarker);
|
|
302
|
+
newAddMarkers.push(nextMarker);
|
|
303
|
+
this.createMarker(nextMarker);
|
|
304
|
+
});
|
|
305
|
+
this.$emit("addsuccess", newAddMarkers);
|
|
306
|
+
},
|
|
307
|
+
|
|
308
|
+
addSearchControl() {
|
|
309
|
+
if (!window.T || !this.map) return;
|
|
310
|
+
const searchControl = new window.T.Control({
|
|
311
|
+
position: window.T_ANCHOR_TOP_LEFT,
|
|
312
|
+
});
|
|
313
|
+
|
|
314
|
+
searchControl.onAdd = () => {
|
|
315
|
+
const container = document.createElement("div");
|
|
316
|
+
container.className = "tianditu-search-container";
|
|
317
|
+
|
|
318
|
+
container.ondblclick = function (event) {
|
|
319
|
+
event.stopPropagation();
|
|
320
|
+
event.preventDefault();
|
|
321
|
+
};
|
|
322
|
+
|
|
323
|
+
const input = document.createElement("input");
|
|
324
|
+
input.type = "text";
|
|
325
|
+
input.placeholder = "搜索位置";
|
|
326
|
+
input.style.cssText =
|
|
327
|
+
"width: 200px; height: 32px; padding: 0 10px; border: 1px solid #ccc; border-radius: 4px 0 0 4px; font-size: 12px; outline: none; box-sizing: border-box;";
|
|
328
|
+
|
|
329
|
+
const searchBtn = document.createElement("button");
|
|
330
|
+
searchBtn.innerHTML = "搜索";
|
|
331
|
+
searchBtn.style.cssText =
|
|
332
|
+
"height: 32px; width: 40px; border: none; background: #007bff; color: white; cursor: pointer; border-radius: 0 4px 4px 0; font-size: 12px;";
|
|
333
|
+
|
|
334
|
+
const clearBtn = document.createElement("button");
|
|
335
|
+
clearBtn.innerHTML = "×";
|
|
336
|
+
clearBtn.style.cssText =
|
|
337
|
+
"position: absolute; right: 45px; top: 50%; transform: translateY(-50%); background: none; border: none; color: #999; font-size: 18px; cursor: pointer; padding: 0 5px; display: none;";
|
|
338
|
+
|
|
339
|
+
container.style.cssText =
|
|
340
|
+
"position: relative; display: flex; margin: 10px; z-index: 1000;";
|
|
341
|
+
|
|
342
|
+
container.appendChild(input);
|
|
343
|
+
container.appendChild(searchBtn);
|
|
344
|
+
container.appendChild(clearBtn);
|
|
345
|
+
|
|
346
|
+
searchBtn.onclick = () => {
|
|
347
|
+
this.geocodeSearch(input.value);
|
|
348
|
+
};
|
|
349
|
+
|
|
350
|
+
input.onkeyup = (e) => {
|
|
351
|
+
clearBtn.style.display = input.value ? "block" : "none";
|
|
352
|
+
if (e.keyCode === 13) {
|
|
353
|
+
this.geocodeSearch(input.value);
|
|
354
|
+
}
|
|
355
|
+
};
|
|
356
|
+
clearBtn.onclick = () => {
|
|
357
|
+
input.value = "";
|
|
358
|
+
clearBtn.style.display = "none";
|
|
359
|
+
};
|
|
360
|
+
|
|
361
|
+
this.searchInput = input;
|
|
362
|
+
this.searchClearBtn = clearBtn;
|
|
363
|
+
|
|
364
|
+
return container;
|
|
365
|
+
};
|
|
366
|
+
|
|
367
|
+
searchControl.onRemove = function () {};
|
|
368
|
+
|
|
369
|
+
this.map.addControl(searchControl);
|
|
370
|
+
},
|
|
371
|
+
// 设置中心点方法
|
|
372
|
+
setCenterAndZoom(center = null, zoom = null) {
|
|
373
|
+
const [propLng, propLat] = Array.isArray(this.center) ? this.center : [];
|
|
374
|
+
const [lng, lat] = Array.isArray(center) ? center : [propLng, propLat];
|
|
375
|
+
const nextZoom = typeof zoom === "number" ? zoom : this.zoom;
|
|
376
|
+
const nextCenter = new window.T.LngLat(lng, lat);
|
|
377
|
+
this.map.centerAndZoom(nextCenter, nextZoom);
|
|
378
|
+
},
|
|
379
|
+
geocodeSearch(keyword) {
|
|
380
|
+
if (typeof window === "undefined") return;
|
|
381
|
+
const text = (keyword || "").trim();
|
|
382
|
+
if (!text) {
|
|
383
|
+
this.$emit("error", new Error("请输入要搜索的地址"));
|
|
384
|
+
return;
|
|
385
|
+
}
|
|
386
|
+
if (!this.geocoder || !this.map) return;
|
|
387
|
+
|
|
388
|
+
this.geocoder.getPoint(text, (result) => {
|
|
389
|
+
if (result && result.getStatus && result.getStatus() === 0) {
|
|
390
|
+
const locationPoint = result.getLocationPoint();
|
|
391
|
+
this.currentLocation = {
|
|
392
|
+
lng: locationPoint.getLng(),
|
|
393
|
+
lat: locationPoint.getLat(),
|
|
394
|
+
};
|
|
395
|
+
this.map.panTo(locationPoint, 16);
|
|
396
|
+
this.$emit("search-success", this.currentLocation);
|
|
397
|
+
} else {
|
|
398
|
+
const message =
|
|
399
|
+
result && result.getMsg ? result.getMsg() : "未知错误";
|
|
400
|
+
this.currentLocation = { lng: null, lat: null };
|
|
401
|
+
this.$emit(
|
|
402
|
+
"search-error",
|
|
403
|
+
new Error(`未找到该地址,原因:${message}`),
|
|
404
|
+
);
|
|
405
|
+
}
|
|
406
|
+
});
|
|
407
|
+
},
|
|
408
|
+
|
|
409
|
+
clearSearch() {
|
|
410
|
+
if (this.searchInput) {
|
|
411
|
+
this.searchInput.value = "";
|
|
412
|
+
}
|
|
413
|
+
if (this.searchClearBtn) {
|
|
414
|
+
this.searchClearBtn.style.display = "none";
|
|
415
|
+
}
|
|
416
|
+
},
|
|
417
|
+
|
|
418
|
+
generateId() {
|
|
419
|
+
return Date.now().toString(36) + Math.random().toString(36).slice(2, 11);
|
|
420
|
+
},
|
|
421
|
+
|
|
422
|
+
hideMarkers(value) {
|
|
423
|
+
if (!Array.isArray(value)) return;
|
|
424
|
+
this.visibleMarkers.push(...value);
|
|
425
|
+
value.forEach((item) => {
|
|
426
|
+
const marker = this.markerMap[item.id];
|
|
427
|
+
const label = this.labelMap[item.id];
|
|
428
|
+
if (label) {
|
|
429
|
+
label.hide();
|
|
430
|
+
}
|
|
431
|
+
if (marker) {
|
|
432
|
+
marker.hide();
|
|
433
|
+
}
|
|
434
|
+
});
|
|
435
|
+
this.$emit("hidesuccess");
|
|
436
|
+
},
|
|
437
|
+
|
|
438
|
+
clearAllMarkers() {
|
|
439
|
+
if (!this.map) return;
|
|
440
|
+
Object.values(this.markerMap).forEach((marker) => {
|
|
441
|
+
if (marker && this.map.removeOverLay) {
|
|
442
|
+
this.map.removeOverLay(marker);
|
|
443
|
+
}
|
|
444
|
+
});
|
|
445
|
+
Object.values(this.labelMap).forEach((label) => {
|
|
446
|
+
if (label && this.map.removeOverLay) {
|
|
447
|
+
this.map.removeOverLay(label);
|
|
448
|
+
}
|
|
449
|
+
});
|
|
450
|
+
this.overlays = [];
|
|
451
|
+
this.markerMap = {};
|
|
452
|
+
this.labelMap = {};
|
|
453
|
+
this.visibleMarkers = [];
|
|
454
|
+
this.newMarkers = [];
|
|
455
|
+
},
|
|
456
|
+
|
|
457
|
+
getAllMarkers() {
|
|
458
|
+
const visibleMarkers = this.markers.filter(
|
|
459
|
+
(m) => !this.visibleMarkers.some((v) => v.id === m.id),
|
|
460
|
+
);
|
|
461
|
+
return [...visibleMarkers, ...this.newMarkers];
|
|
462
|
+
},
|
|
463
|
+
|
|
464
|
+
resizeMap() {
|
|
465
|
+
if (this.map && this.map.checkResize) {
|
|
466
|
+
this.map.checkResize();
|
|
467
|
+
}
|
|
468
|
+
},
|
|
469
|
+
|
|
470
|
+
destroyMap() {
|
|
471
|
+
this.clearAllMarkers();
|
|
472
|
+
if (this.searchInput) {
|
|
473
|
+
this.searchInput = null;
|
|
474
|
+
}
|
|
475
|
+
if (this.searchClearBtn) {
|
|
476
|
+
this.searchClearBtn = null;
|
|
477
|
+
}
|
|
478
|
+
if (this.scriptEl && this.scriptEl.parentNode) {
|
|
479
|
+
this.scriptEl.parentNode.removeChild(this.scriptEl);
|
|
480
|
+
}
|
|
481
|
+
this.controlsAdded = false;
|
|
482
|
+
if (!this.map) return;
|
|
483
|
+
const container = document.getElementById(this.mapContainerId);
|
|
484
|
+
if (container) {
|
|
485
|
+
container.innerHTML = "";
|
|
486
|
+
}
|
|
487
|
+
this.map = null;
|
|
488
|
+
},
|
|
489
|
+
},
|
|
490
|
+
};
|
|
491
|
+
|
|
492
|
+
const _hoisted_1 = ["id"];
|
|
493
|
+
|
|
494
|
+
function render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
495
|
+
return (vue.openBlock(), vue.createElementBlock("div", {
|
|
496
|
+
class: "tianditu-container",
|
|
497
|
+
id: $data.mapContainerId,
|
|
498
|
+
style: vue.normalizeStyle($props.containerStyle)
|
|
499
|
+
}, null, 12 /* STYLE, PROPS */, _hoisted_1))
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
script.render = render;
|
|
503
|
+
script.__file = "src/TiandiMap.vue";
|
|
504
|
+
|
|
505
|
+
const componentName = 'TiandiMap';
|
|
506
|
+
|
|
507
|
+
const install = (app) => {
|
|
508
|
+
if (!app) return
|
|
509
|
+
if (install.installed) return
|
|
510
|
+
install.installed = true;
|
|
511
|
+
|
|
512
|
+
if (typeof app.component === 'function') {
|
|
513
|
+
app.component(componentName, script);
|
|
514
|
+
return
|
|
515
|
+
}
|
|
516
|
+
};
|
|
517
|
+
|
|
518
|
+
script.install = install;
|
|
519
|
+
|
|
520
|
+
exports.TiandiMap = script;
|
|
521
|
+
exports["default"] = script;
|
|
522
|
+
exports.install = install;
|
|
523
|
+
|
|
524
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
525
|
+
|
|
526
|
+
}));
|
|
527
|
+
//# sourceMappingURL=index.umd.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.umd.js","sources":["../src/TiandiMap.vue","../src/TiandiMap.vue?vue&type=template&id=2e14b44c&lang.js","../src/index.js"],"sourcesContent":["<template>\r\n <div\r\n class=\"tianditu-container\"\r\n :id=\"mapContainerId\"\r\n :style=\"containerStyle\"\r\n ></div>\r\n</template>\r\n\r\n<script>\r\nconst DEFAULT_ICON = \"https://api.tianditu.gov.cn/v4.0/image/marker-icon.png\";\r\nconst SCRIPT_ID = \"tianditu-map-script\";\r\n\r\nexport default {\r\n name: \"TiandiMap\",\r\n emits: [\r\n \"ready\",\r\n \"error\",\r\n \"marker-click\",\r\n \"addsuccess\",\r\n \"hidesuccess\",\r\n \"search-success\",\r\n \"search-error\",\r\n ],\r\n props: {\r\n version: {\r\n type: String,\r\n default: \"4.0\",\r\n },\r\n tk: {\r\n type: String,\r\n default: \"7e9c0399a2b7d8561e02ff7cf1bcaffe\",\r\n },\r\n containerStyle: {\r\n type: Object,\r\n default: () => ({\r\n width: \"100%\",\r\n height: \"100vh\",\r\n }),\r\n },\r\n center: {\r\n type: Array,\r\n default: () => [117.017362, 25.075884],\r\n },\r\n zoom: {\r\n type: Number,\r\n default: 10,\r\n },\r\n minZoom: {\r\n type: Number,\r\n default: 1,\r\n },\r\n maxZoom: {\r\n type: Number,\r\n default: 18,\r\n },\r\n markers: {\r\n type: Array,\r\n default: () => [],\r\n },\r\n showZoom: {\r\n type: Boolean,\r\n default: true,\r\n },\r\n dragEnable: {\r\n type: Boolean,\r\n default: true,\r\n },\r\n scrollWheelZoom: {\r\n type: Boolean,\r\n default: true,\r\n },\r\n },\r\n\r\n data() {\r\n return {\r\n mapContainerId: `tianditu-map-${Math.random().toString(36).slice(2, 11)}`,\r\n map: null,\r\n overlays: [],\r\n scriptLoaded: false,\r\n geocoder: null,\r\n newMarkers: [],\r\n visibleMarkers: [],\r\n markerMap: {},\r\n labelMap: {},\r\n searchInput: null,\r\n searchClearBtn: null,\r\n scriptEl: null,\r\n currentLocation: null,\r\n controlsAdded: false,\r\n // 拾取坐标点\r\n lnglat: null,\r\n };\r\n },\r\n\r\n mounted() {\r\n this.loadTiandituScript();\r\n },\r\n beforeDestroy() {\r\n this.destroyMap();\r\n },\r\n beforeUnmount() {\r\n this.destroyMap();\r\n },\r\n watch: {\r\n markers: {\r\n deep: true,\r\n handler() {\r\n if (!this.map) return;\r\n this.clearAllMarkers();\r\n this.renderMarkers();\r\n },\r\n },\r\n containerStyle: {\r\n deep: true,\r\n handler() {\r\n if (this.map) this.resizeMap();\r\n },\r\n },\r\n },\r\n\r\n methods: {\r\n loadTiandituScript() {\r\n if (typeof window === \"undefined\" || typeof document === \"undefined\")\r\n return;\r\n if (window.T) {\r\n this.scriptLoaded = true;\r\n this.initMap();\r\n return;\r\n }\r\n\r\n const existing = document.getElementById(SCRIPT_ID);\r\n if (existing) {\r\n this.scriptEl = existing;\r\n existing.addEventListener(\r\n \"load\",\r\n () => {\r\n this.scriptLoaded = true;\r\n this.initMap();\r\n },\r\n { once: true },\r\n );\r\n existing.addEventListener(\r\n \"error\",\r\n () => {\r\n this.$emit(\"error\", new Error(\"天地图API加载失败\"));\r\n },\r\n { once: true },\r\n );\r\n return;\r\n }\r\n\r\n const script = document.createElement(\"script\");\r\n script.id = SCRIPT_ID;\r\n script.type = \"text/javascript\";\r\n script.async = true;\r\n script.src = `https://api.tianditu.gov.cn/api?v=${this.version}&tk=${this.tk}`;\r\n script.onload = () => {\r\n this.scriptLoaded = true;\r\n this.initMap();\r\n };\r\n script.onerror = () => {\r\n this.$emit(\"error\", new Error(\"天地图API加载失败\"));\r\n };\r\n this.scriptEl = script;\r\n document.head.appendChild(script);\r\n },\r\n // 获取拾取的坐标\r\n getLngLat(lnglat) {\r\n console.log(lnglat);\r\n this.lnglat = lnglat;\r\n },\r\n // 获取拾取的坐标\r\n getMapLngLat() {\r\n return this.lnglat;\r\n },\r\n initMap() {\r\n if (\r\n typeof window === \"undefined\" ||\r\n !this.scriptLoaded ||\r\n !window.T ||\r\n this.map\r\n )\r\n return;\r\n try {\r\n this.map = new window.T.Map(this.mapContainerId);\r\n this.geocoder = new window.T.Geocoder();\r\n this.setCenterAndZoom();\r\n this.map.setMinZoom(this.minZoom);\r\n this.map.setMaxZoom(this.maxZoom);\r\n // 坐标拾取\r\n var cp = new window.T.CoordinatePickup(this.map, {\r\n callback: this.getLngLat,\r\n });\r\n cp.addEvent(function (lnglat) {\r\n console.log(lnglat);\r\n });\r\n // 地图类型控件\r\n if (!this.controlsAdded) {\r\n if (window.T.Control && window.T.Control.MapType) {\r\n const mapTypeControl = new window.T.Control.MapType({\r\n position: window.T_ANCHOR_TOP_RIGHT,\r\n });\r\n this.map.addControl(mapTypeControl);\r\n }\r\n this.controlsAdded = true;\r\n }\r\n\r\n if (\r\n this.showZoom &&\r\n this.map &&\r\n typeof this.map.enableScrollWheelZoom === \"function\"\r\n ) {\r\n this.map.enableScrollWheelZoom();\r\n }\r\n\r\n if (this.dragEnable) {\r\n this.map.enableDrag();\r\n } else {\r\n this.map.disableDrag();\r\n }\r\n if (this.scrollWheelZoom) {\r\n this.map.enableScrollWheelZoom();\r\n } else {\r\n this.map.disableScrollWheelZoom();\r\n }\r\n this.renderMarkers();\r\n this.$emit(\"ready\", this.map);\r\n this.addSearchControl();\r\n } catch (error) {\r\n this.$emit(\"error\", error);\r\n }\r\n },\r\n\r\n openInfo(content, e) {\r\n const point = e.lnglat;\r\n const markerInfoWin = new window.T.InfoWindow(content, {\r\n offset: new window.T.Point(0, -30),\r\n });\r\n this.map.openInfoWindow(markerInfoWin, point);\r\n },\r\n\r\n renderMarkers() {\r\n if (!Array.isArray(this.markers) || !this.map) return;\r\n this.markers.forEach((markerData) => {\r\n this.createMarker(markerData);\r\n });\r\n },\r\n\r\n createMarker(markerData) {\r\n if (!this.map || typeof window === \"undefined\" || !window.T) return null;\r\n const { lng, lat, option = {} } = markerData;\r\n const markerId = markerData.id || this.generateId();\r\n const { iconInfo = {}, content, textInfo } = option;\r\n if (typeof lng !== \"number\" || typeof lat !== \"number\") {\r\n return null;\r\n }\r\n const position = new window.T.LngLat(lng, lat);\r\n let marker;\r\n\r\n if (iconInfo) {\r\n const { icon = DEFAULT_ICON, offsetX = 25, offsetY = 41 } = iconInfo;\r\n const iconObj = new window.T.Icon({\r\n iconUrl: icon,\r\n iconSize: new window.T.Point(offsetX, offsetY),\r\n iconAnchor: new window.T.Point(offsetX / 2, offsetY),\r\n });\r\n marker = new window.T.Marker(position, { icon: iconObj });\r\n } else {\r\n marker = new window.T.Marker(position);\r\n }\r\n\r\n marker.addEventListener(\"click\", (e) => {\r\n this.$emit(\"marker-click\", { markerData, event: e });\r\n\r\n if (content) {\r\n this.openInfo(content, e);\r\n }\r\n });\r\n\r\n if (textInfo && textInfo.text) {\r\n const label = new window.T.Label({\r\n text: textInfo.text,\r\n position,\r\n offset: new window.T.Point(\r\n textInfo.offsetX || 3,\r\n textInfo.offsetY || -30,\r\n ),\r\n });\r\n this.map.addOverLay(label);\r\n this.overlays.push(label);\r\n this.labelMap[markerId] = label;\r\n }\r\n this.map.addOverLay(marker);\r\n this.overlays.push(marker);\r\n this.markerMap[markerId] = marker;\r\n return marker;\r\n },\r\n\r\n addMarkers(newMarkers) {\r\n if (!Array.isArray(newMarkers) || !newMarkers.length) return;\r\n const newAddMarkers = [];\r\n newMarkers.forEach((marker) => {\r\n const nextMarker = { ...marker, id: marker.id || this.generateId() };\r\n this.newMarkers.push(nextMarker);\r\n newAddMarkers.push(nextMarker);\r\n this.createMarker(nextMarker);\r\n });\r\n this.$emit(\"addsuccess\", newAddMarkers);\r\n },\r\n\r\n addSearchControl() {\r\n if (!window.T || !this.map) return;\r\n const searchControl = new window.T.Control({\r\n position: window.T_ANCHOR_TOP_LEFT,\r\n });\r\n\r\n searchControl.onAdd = () => {\r\n const container = document.createElement(\"div\");\r\n container.className = \"tianditu-search-container\";\r\n\r\n container.ondblclick = function (event) {\r\n event.stopPropagation();\r\n event.preventDefault();\r\n };\r\n\r\n const input = document.createElement(\"input\");\r\n input.type = \"text\";\r\n input.placeholder = \"搜索位置\";\r\n input.style.cssText =\r\n \"width: 200px; height: 32px; padding: 0 10px; border: 1px solid #ccc; border-radius: 4px 0 0 4px; font-size: 12px; outline: none; box-sizing: border-box;\";\r\n\r\n const searchBtn = document.createElement(\"button\");\r\n searchBtn.innerHTML = \"搜索\";\r\n searchBtn.style.cssText =\r\n \"height: 32px; width: 40px; border: none; background: #007bff; color: white; cursor: pointer; border-radius: 0 4px 4px 0; font-size: 12px;\";\r\n\r\n const clearBtn = document.createElement(\"button\");\r\n clearBtn.innerHTML = \"×\";\r\n clearBtn.style.cssText =\r\n \"position: absolute; right: 45px; top: 50%; transform: translateY(-50%); background: none; border: none; color: #999; font-size: 18px; cursor: pointer; padding: 0 5px; display: none;\";\r\n\r\n container.style.cssText =\r\n \"position: relative; display: flex; margin: 10px; z-index: 1000;\";\r\n\r\n container.appendChild(input);\r\n container.appendChild(searchBtn);\r\n container.appendChild(clearBtn);\r\n\r\n searchBtn.onclick = () => {\r\n this.geocodeSearch(input.value);\r\n };\r\n\r\n input.onkeyup = (e) => {\r\n clearBtn.style.display = input.value ? \"block\" : \"none\";\r\n if (e.keyCode === 13) {\r\n this.geocodeSearch(input.value);\r\n }\r\n };\r\n clearBtn.onclick = () => {\r\n input.value = \"\";\r\n clearBtn.style.display = \"none\";\r\n };\r\n\r\n this.searchInput = input;\r\n this.searchClearBtn = clearBtn;\r\n\r\n return container;\r\n };\r\n\r\n searchControl.onRemove = function () {};\r\n\r\n this.map.addControl(searchControl);\r\n },\r\n // 设置中心点方法\r\n setCenterAndZoom(center = null, zoom = null) {\r\n const [propLng, propLat] = Array.isArray(this.center) ? this.center : [];\r\n const [lng, lat] = Array.isArray(center) ? center : [propLng, propLat];\r\n const nextZoom = typeof zoom === \"number\" ? zoom : this.zoom;\r\n const nextCenter = new window.T.LngLat(lng, lat);\r\n this.map.centerAndZoom(nextCenter, nextZoom);\r\n },\r\n geocodeSearch(keyword) {\r\n if (typeof window === \"undefined\") return;\r\n const text = (keyword || \"\").trim();\r\n if (!text) {\r\n this.$emit(\"error\", new Error(\"请输入要搜索的地址\"));\r\n return;\r\n }\r\n if (!this.geocoder || !this.map) return;\r\n\r\n this.geocoder.getPoint(text, (result) => {\r\n if (result && result.getStatus && result.getStatus() === 0) {\r\n const locationPoint = result.getLocationPoint();\r\n this.currentLocation = {\r\n lng: locationPoint.getLng(),\r\n lat: locationPoint.getLat(),\r\n };\r\n this.map.panTo(locationPoint, 16);\r\n this.$emit(\"search-success\", this.currentLocation);\r\n } else {\r\n const message =\r\n result && result.getMsg ? result.getMsg() : \"未知错误\";\r\n this.currentLocation = { lng: null, lat: null };\r\n this.$emit(\r\n \"search-error\",\r\n new Error(`未找到该地址,原因:${message}`),\r\n );\r\n }\r\n });\r\n },\r\n\r\n clearSearch() {\r\n if (this.searchInput) {\r\n this.searchInput.value = \"\";\r\n }\r\n if (this.searchClearBtn) {\r\n this.searchClearBtn.style.display = \"none\";\r\n }\r\n },\r\n\r\n generateId() {\r\n return Date.now().toString(36) + Math.random().toString(36).slice(2, 11);\r\n },\r\n\r\n hideMarkers(value) {\r\n if (!Array.isArray(value)) return;\r\n this.visibleMarkers.push(...value);\r\n value.forEach((item) => {\r\n const marker = this.markerMap[item.id];\r\n const label = this.labelMap[item.id];\r\n if (label) {\r\n label.hide();\r\n }\r\n if (marker) {\r\n marker.hide();\r\n }\r\n });\r\n this.$emit(\"hidesuccess\");\r\n },\r\n\r\n clearAllMarkers() {\r\n if (!this.map) return;\r\n Object.values(this.markerMap).forEach((marker) => {\r\n if (marker && this.map.removeOverLay) {\r\n this.map.removeOverLay(marker);\r\n }\r\n });\r\n Object.values(this.labelMap).forEach((label) => {\r\n if (label && this.map.removeOverLay) {\r\n this.map.removeOverLay(label);\r\n }\r\n });\r\n this.overlays = [];\r\n this.markerMap = {};\r\n this.labelMap = {};\r\n this.visibleMarkers = [];\r\n this.newMarkers = [];\r\n },\r\n\r\n getAllMarkers() {\r\n const visibleMarkers = this.markers.filter(\r\n (m) => !this.visibleMarkers.some((v) => v.id === m.id),\r\n );\r\n return [...visibleMarkers, ...this.newMarkers];\r\n },\r\n\r\n resizeMap() {\r\n if (this.map && this.map.checkResize) {\r\n this.map.checkResize();\r\n }\r\n },\r\n\r\n destroyMap() {\r\n this.clearAllMarkers();\r\n if (this.searchInput) {\r\n this.searchInput = null;\r\n }\r\n if (this.searchClearBtn) {\r\n this.searchClearBtn = null;\r\n }\r\n if (this.scriptEl && this.scriptEl.parentNode) {\r\n this.scriptEl.parentNode.removeChild(this.scriptEl);\r\n }\r\n this.controlsAdded = false;\r\n if (!this.map) return;\r\n const container = document.getElementById(this.mapContainerId);\r\n if (container) {\r\n container.innerHTML = \"\";\r\n }\r\n this.map = null;\r\n },\r\n },\r\n};\r\n</script>\r\n","<template>\r\n <div\r\n class=\"tianditu-container\"\r\n :id=\"mapContainerId\"\r\n :style=\"containerStyle\"\r\n ></div>\r\n</template>\r\n\r\n<script>\r\nconst DEFAULT_ICON = \"https://api.tianditu.gov.cn/v4.0/image/marker-icon.png\";\r\nconst SCRIPT_ID = \"tianditu-map-script\";\r\n\r\nexport default {\r\n name: \"TiandiMap\",\r\n emits: [\r\n \"ready\",\r\n \"error\",\r\n \"marker-click\",\r\n \"addsuccess\",\r\n \"hidesuccess\",\r\n \"search-success\",\r\n \"search-error\",\r\n ],\r\n props: {\r\n version: {\r\n type: String,\r\n default: \"4.0\",\r\n },\r\n tk: {\r\n type: String,\r\n default: \"7e9c0399a2b7d8561e02ff7cf1bcaffe\",\r\n },\r\n containerStyle: {\r\n type: Object,\r\n default: () => ({\r\n width: \"100%\",\r\n height: \"100vh\",\r\n }),\r\n },\r\n center: {\r\n type: Array,\r\n default: () => [117.017362, 25.075884],\r\n },\r\n zoom: {\r\n type: Number,\r\n default: 10,\r\n },\r\n minZoom: {\r\n type: Number,\r\n default: 1,\r\n },\r\n maxZoom: {\r\n type: Number,\r\n default: 18,\r\n },\r\n markers: {\r\n type: Array,\r\n default: () => [],\r\n },\r\n showZoom: {\r\n type: Boolean,\r\n default: true,\r\n },\r\n dragEnable: {\r\n type: Boolean,\r\n default: true,\r\n },\r\n scrollWheelZoom: {\r\n type: Boolean,\r\n default: true,\r\n },\r\n },\r\n\r\n data() {\r\n return {\r\n mapContainerId: `tianditu-map-${Math.random().toString(36).slice(2, 11)}`,\r\n map: null,\r\n overlays: [],\r\n scriptLoaded: false,\r\n geocoder: null,\r\n newMarkers: [],\r\n visibleMarkers: [],\r\n markerMap: {},\r\n labelMap: {},\r\n searchInput: null,\r\n searchClearBtn: null,\r\n scriptEl: null,\r\n currentLocation: null,\r\n controlsAdded: false,\r\n // 拾取坐标点\r\n lnglat: null,\r\n };\r\n },\r\n\r\n mounted() {\r\n this.loadTiandituScript();\r\n },\r\n beforeDestroy() {\r\n this.destroyMap();\r\n },\r\n beforeUnmount() {\r\n this.destroyMap();\r\n },\r\n watch: {\r\n markers: {\r\n deep: true,\r\n handler() {\r\n if (!this.map) return;\r\n this.clearAllMarkers();\r\n this.renderMarkers();\r\n },\r\n },\r\n containerStyle: {\r\n deep: true,\r\n handler() {\r\n if (this.map) this.resizeMap();\r\n },\r\n },\r\n },\r\n\r\n methods: {\r\n loadTiandituScript() {\r\n if (typeof window === \"undefined\" || typeof document === \"undefined\")\r\n return;\r\n if (window.T) {\r\n this.scriptLoaded = true;\r\n this.initMap();\r\n return;\r\n }\r\n\r\n const existing = document.getElementById(SCRIPT_ID);\r\n if (existing) {\r\n this.scriptEl = existing;\r\n existing.addEventListener(\r\n \"load\",\r\n () => {\r\n this.scriptLoaded = true;\r\n this.initMap();\r\n },\r\n { once: true },\r\n );\r\n existing.addEventListener(\r\n \"error\",\r\n () => {\r\n this.$emit(\"error\", new Error(\"天地图API加载失败\"));\r\n },\r\n { once: true },\r\n );\r\n return;\r\n }\r\n\r\n const script = document.createElement(\"script\");\r\n script.id = SCRIPT_ID;\r\n script.type = \"text/javascript\";\r\n script.async = true;\r\n script.src = `https://api.tianditu.gov.cn/api?v=${this.version}&tk=${this.tk}`;\r\n script.onload = () => {\r\n this.scriptLoaded = true;\r\n this.initMap();\r\n };\r\n script.onerror = () => {\r\n this.$emit(\"error\", new Error(\"天地图API加载失败\"));\r\n };\r\n this.scriptEl = script;\r\n document.head.appendChild(script);\r\n },\r\n // 获取拾取的坐标\r\n getLngLat(lnglat) {\r\n console.log(lnglat);\r\n this.lnglat = lnglat;\r\n },\r\n // 获取拾取的坐标\r\n getMapLngLat() {\r\n return this.lnglat;\r\n },\r\n initMap() {\r\n if (\r\n typeof window === \"undefined\" ||\r\n !this.scriptLoaded ||\r\n !window.T ||\r\n this.map\r\n )\r\n return;\r\n try {\r\n this.map = new window.T.Map(this.mapContainerId);\r\n this.geocoder = new window.T.Geocoder();\r\n this.setCenterAndZoom();\r\n this.map.setMinZoom(this.minZoom);\r\n this.map.setMaxZoom(this.maxZoom);\r\n // 坐标拾取\r\n var cp = new window.T.CoordinatePickup(this.map, {\r\n callback: this.getLngLat,\r\n });\r\n cp.addEvent(function (lnglat) {\r\n console.log(lnglat);\r\n });\r\n // 地图类型控件\r\n if (!this.controlsAdded) {\r\n if (window.T.Control && window.T.Control.MapType) {\r\n const mapTypeControl = new window.T.Control.MapType({\r\n position: window.T_ANCHOR_TOP_RIGHT,\r\n });\r\n this.map.addControl(mapTypeControl);\r\n }\r\n this.controlsAdded = true;\r\n }\r\n\r\n if (\r\n this.showZoom &&\r\n this.map &&\r\n typeof this.map.enableScrollWheelZoom === \"function\"\r\n ) {\r\n this.map.enableScrollWheelZoom();\r\n }\r\n\r\n if (this.dragEnable) {\r\n this.map.enableDrag();\r\n } else {\r\n this.map.disableDrag();\r\n }\r\n if (this.scrollWheelZoom) {\r\n this.map.enableScrollWheelZoom();\r\n } else {\r\n this.map.disableScrollWheelZoom();\r\n }\r\n this.renderMarkers();\r\n this.$emit(\"ready\", this.map);\r\n this.addSearchControl();\r\n } catch (error) {\r\n this.$emit(\"error\", error);\r\n }\r\n },\r\n\r\n openInfo(content, e) {\r\n const point = e.lnglat;\r\n const markerInfoWin = new window.T.InfoWindow(content, {\r\n offset: new window.T.Point(0, -30),\r\n });\r\n this.map.openInfoWindow(markerInfoWin, point);\r\n },\r\n\r\n renderMarkers() {\r\n if (!Array.isArray(this.markers) || !this.map) return;\r\n this.markers.forEach((markerData) => {\r\n this.createMarker(markerData);\r\n });\r\n },\r\n\r\n createMarker(markerData) {\r\n if (!this.map || typeof window === \"undefined\" || !window.T) return null;\r\n const { lng, lat, option = {} } = markerData;\r\n const markerId = markerData.id || this.generateId();\r\n const { iconInfo = {}, content, textInfo } = option;\r\n if (typeof lng !== \"number\" || typeof lat !== \"number\") {\r\n return null;\r\n }\r\n const position = new window.T.LngLat(lng, lat);\r\n let marker;\r\n\r\n if (iconInfo) {\r\n const { icon = DEFAULT_ICON, offsetX = 25, offsetY = 41 } = iconInfo;\r\n const iconObj = new window.T.Icon({\r\n iconUrl: icon,\r\n iconSize: new window.T.Point(offsetX, offsetY),\r\n iconAnchor: new window.T.Point(offsetX / 2, offsetY),\r\n });\r\n marker = new window.T.Marker(position, { icon: iconObj });\r\n } else {\r\n marker = new window.T.Marker(position);\r\n }\r\n\r\n marker.addEventListener(\"click\", (e) => {\r\n this.$emit(\"marker-click\", { markerData, event: e });\r\n\r\n if (content) {\r\n this.openInfo(content, e);\r\n }\r\n });\r\n\r\n if (textInfo && textInfo.text) {\r\n const label = new window.T.Label({\r\n text: textInfo.text,\r\n position,\r\n offset: new window.T.Point(\r\n textInfo.offsetX || 3,\r\n textInfo.offsetY || -30,\r\n ),\r\n });\r\n this.map.addOverLay(label);\r\n this.overlays.push(label);\r\n this.labelMap[markerId] = label;\r\n }\r\n this.map.addOverLay(marker);\r\n this.overlays.push(marker);\r\n this.markerMap[markerId] = marker;\r\n return marker;\r\n },\r\n\r\n addMarkers(newMarkers) {\r\n if (!Array.isArray(newMarkers) || !newMarkers.length) return;\r\n const newAddMarkers = [];\r\n newMarkers.forEach((marker) => {\r\n const nextMarker = { ...marker, id: marker.id || this.generateId() };\r\n this.newMarkers.push(nextMarker);\r\n newAddMarkers.push(nextMarker);\r\n this.createMarker(nextMarker);\r\n });\r\n this.$emit(\"addsuccess\", newAddMarkers);\r\n },\r\n\r\n addSearchControl() {\r\n if (!window.T || !this.map) return;\r\n const searchControl = new window.T.Control({\r\n position: window.T_ANCHOR_TOP_LEFT,\r\n });\r\n\r\n searchControl.onAdd = () => {\r\n const container = document.createElement(\"div\");\r\n container.className = \"tianditu-search-container\";\r\n\r\n container.ondblclick = function (event) {\r\n event.stopPropagation();\r\n event.preventDefault();\r\n };\r\n\r\n const input = document.createElement(\"input\");\r\n input.type = \"text\";\r\n input.placeholder = \"搜索位置\";\r\n input.style.cssText =\r\n \"width: 200px; height: 32px; padding: 0 10px; border: 1px solid #ccc; border-radius: 4px 0 0 4px; font-size: 12px; outline: none; box-sizing: border-box;\";\r\n\r\n const searchBtn = document.createElement(\"button\");\r\n searchBtn.innerHTML = \"搜索\";\r\n searchBtn.style.cssText =\r\n \"height: 32px; width: 40px; border: none; background: #007bff; color: white; cursor: pointer; border-radius: 0 4px 4px 0; font-size: 12px;\";\r\n\r\n const clearBtn = document.createElement(\"button\");\r\n clearBtn.innerHTML = \"×\";\r\n clearBtn.style.cssText =\r\n \"position: absolute; right: 45px; top: 50%; transform: translateY(-50%); background: none; border: none; color: #999; font-size: 18px; cursor: pointer; padding: 0 5px; display: none;\";\r\n\r\n container.style.cssText =\r\n \"position: relative; display: flex; margin: 10px; z-index: 1000;\";\r\n\r\n container.appendChild(input);\r\n container.appendChild(searchBtn);\r\n container.appendChild(clearBtn);\r\n\r\n searchBtn.onclick = () => {\r\n this.geocodeSearch(input.value);\r\n };\r\n\r\n input.onkeyup = (e) => {\r\n clearBtn.style.display = input.value ? \"block\" : \"none\";\r\n if (e.keyCode === 13) {\r\n this.geocodeSearch(input.value);\r\n }\r\n };\r\n clearBtn.onclick = () => {\r\n input.value = \"\";\r\n clearBtn.style.display = \"none\";\r\n };\r\n\r\n this.searchInput = input;\r\n this.searchClearBtn = clearBtn;\r\n\r\n return container;\r\n };\r\n\r\n searchControl.onRemove = function () {};\r\n\r\n this.map.addControl(searchControl);\r\n },\r\n // 设置中心点方法\r\n setCenterAndZoom(center = null, zoom = null) {\r\n const [propLng, propLat] = Array.isArray(this.center) ? this.center : [];\r\n const [lng, lat] = Array.isArray(center) ? center : [propLng, propLat];\r\n const nextZoom = typeof zoom === \"number\" ? zoom : this.zoom;\r\n const nextCenter = new window.T.LngLat(lng, lat);\r\n this.map.centerAndZoom(nextCenter, nextZoom);\r\n },\r\n geocodeSearch(keyword) {\r\n if (typeof window === \"undefined\") return;\r\n const text = (keyword || \"\").trim();\r\n if (!text) {\r\n this.$emit(\"error\", new Error(\"请输入要搜索的地址\"));\r\n return;\r\n }\r\n if (!this.geocoder || !this.map) return;\r\n\r\n this.geocoder.getPoint(text, (result) => {\r\n if (result && result.getStatus && result.getStatus() === 0) {\r\n const locationPoint = result.getLocationPoint();\r\n this.currentLocation = {\r\n lng: locationPoint.getLng(),\r\n lat: locationPoint.getLat(),\r\n };\r\n this.map.panTo(locationPoint, 16);\r\n this.$emit(\"search-success\", this.currentLocation);\r\n } else {\r\n const message =\r\n result && result.getMsg ? result.getMsg() : \"未知错误\";\r\n this.currentLocation = { lng: null, lat: null };\r\n this.$emit(\r\n \"search-error\",\r\n new Error(`未找到该地址,原因:${message}`),\r\n );\r\n }\r\n });\r\n },\r\n\r\n clearSearch() {\r\n if (this.searchInput) {\r\n this.searchInput.value = \"\";\r\n }\r\n if (this.searchClearBtn) {\r\n this.searchClearBtn.style.display = \"none\";\r\n }\r\n },\r\n\r\n generateId() {\r\n return Date.now().toString(36) + Math.random().toString(36).slice(2, 11);\r\n },\r\n\r\n hideMarkers(value) {\r\n if (!Array.isArray(value)) return;\r\n this.visibleMarkers.push(...value);\r\n value.forEach((item) => {\r\n const marker = this.markerMap[item.id];\r\n const label = this.labelMap[item.id];\r\n if (label) {\r\n label.hide();\r\n }\r\n if (marker) {\r\n marker.hide();\r\n }\r\n });\r\n this.$emit(\"hidesuccess\");\r\n },\r\n\r\n clearAllMarkers() {\r\n if (!this.map) return;\r\n Object.values(this.markerMap).forEach((marker) => {\r\n if (marker && this.map.removeOverLay) {\r\n this.map.removeOverLay(marker);\r\n }\r\n });\r\n Object.values(this.labelMap).forEach((label) => {\r\n if (label && this.map.removeOverLay) {\r\n this.map.removeOverLay(label);\r\n }\r\n });\r\n this.overlays = [];\r\n this.markerMap = {};\r\n this.labelMap = {};\r\n this.visibleMarkers = [];\r\n this.newMarkers = [];\r\n },\r\n\r\n getAllMarkers() {\r\n const visibleMarkers = this.markers.filter(\r\n (m) => !this.visibleMarkers.some((v) => v.id === m.id),\r\n );\r\n return [...visibleMarkers, ...this.newMarkers];\r\n },\r\n\r\n resizeMap() {\r\n if (this.map && this.map.checkResize) {\r\n this.map.checkResize();\r\n }\r\n },\r\n\r\n destroyMap() {\r\n this.clearAllMarkers();\r\n if (this.searchInput) {\r\n this.searchInput = null;\r\n }\r\n if (this.searchClearBtn) {\r\n this.searchClearBtn = null;\r\n }\r\n if (this.scriptEl && this.scriptEl.parentNode) {\r\n this.scriptEl.parentNode.removeChild(this.scriptEl);\r\n }\r\n this.controlsAdded = false;\r\n if (!this.map) return;\r\n const container = document.getElementById(this.mapContainerId);\r\n if (container) {\r\n container.innerHTML = \"\";\r\n }\r\n this.map = null;\r\n },\r\n },\r\n};\r\n</script>\r\n","import TiandiMap from './TiandiMap.vue'\r\nimport { isVue2 } from 'vue-demi'\r\n\r\nconst componentName = 'TiandiMap'\r\n\r\nconst install = (app) => {\r\n if (!app) return\r\n if (install.installed) return\r\n install.installed = true\r\n\r\n if (typeof app.component === 'function') {\r\n app.component(componentName, TiandiMap)\r\n return\r\n }\r\n\r\n if (isVue2 && app && app.component) {\r\n app.component(componentName, TiandiMap)\r\n }\r\n}\r\n\r\nTiandiMap.install = install\r\n\r\nexport { TiandiMap, install }\r\nexport default TiandiMap\r\n"],"names":["_createElementBlock","TiandiMap"],"mappings":";;;;;;EASA,MAAM,YAAa,GAAE,wDAAwD,CAAA;EAC7E,MAAM,SAAU,GAAE,qBAAqB,CAAA;;AAEvC,eAAe;EACb,EAAA,IAAI,EAAE,WAAW;EACjB,EAAA,KAAK,EAAE;EACL,IAAA,OAAO;EACP,IAAA,OAAO;EACP,IAAA,cAAc;MACd,YAAY;MACZ,aAAa;EACb,IAAA,gBAAgB;EAChB,IAAA,cAAc;KACf;EACD,EAAA,KAAK,EAAE;EACL,IAAA,OAAO,EAAE;QACP,IAAI,EAAE,MAAM;QACZ,OAAO,EAAE,KAAK;OACf;EACD,IAAA,EAAE,EAAE;QACF,IAAI,EAAE,MAAM;EACZ,MAAA,OAAO,EAAE,kCAAkC;OAC5C;EACD,IAAA,cAAc,EAAE;QACd,IAAI,EAAE,MAAM;QACZ,OAAO,EAAE,OAAO;UACd,KAAK,EAAE,MAAM;EACb,QAAA,MAAM,EAAE,OAAO;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AY,IAAI,CAAC,QAAQ,CAAC,UAAU,EAAE;UAC7C,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,WAAW,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;EACrD,OAAA;QACA,IAAI,CAAC,aAAY,GAAI,KAAK,CAAA;EAC1B,MAAA,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,OAAM;QACrB,MAAM,SAAQ,GAAI,QAAQ,CAAC,cAAc,CAAC,IAAI,CAAC,cAAc,CAAC,CAAA;QAC9D,IAAI,SAAS,EAAE;UACb,SAAS,CAAC,SAAU,GAAE,EAAE,CAAA;EAC1B,OAAA;QACA,IAAI,CAAC,GAAE,GAAI,IAAI,CAAA;OAChB;KACF;EACH,CAAC;;;;;6BC3eCA,sBAIM,CAAA,KAAA,EAAA;EAHJ,IAAA,KAAK,EAAC,oBAAmB;EACxB,IAAA,EAAE,EAAE,KAAc,CAAA,cAAA;EAClB,IAAA,KAAK,qBAAE,MAAc,CAAA,cAAA,CAAA;;;;;;;ECD1B,MAAM,aAAa,GAAG,YAAW;AACjC;AACK,QAAC,OAAO,GAAG,CAAC,GAAG,KAAK;EACzB,EAAE,IAAI,CAAC,GAAG,EAAE,MAAM;EAClB,EAAE,IAAI,OAAO,CAAC,SAAS,EAAE,MAAM;EAC/B,EAAE,OAAO,CAAC,SAAS,GAAG,KAAI;AAC1B;EACA,EAAE,IAAI,OAAO,GAAG,CAAC,SAAS,KAAK,UAAU,EAAE;EAC3C,IAAI,GAAG,CAAC,SAAS,CAAC,aAAa,EAAEC,MAAS,EAAC;EAC3C,IAAI,MAAM;EACV,GAAG;EAKH,EAAC;AACD;AACAA,QAAS,CAAC,OAAO,GAAG;;;;;;;;;;;;"}
|
package/package.json
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "tdt-map-vue",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "基于 Vue 2/3 的天地图二次封装组件,提供地图初始化、标注管理、地理编码搜索和常用实例方法调用能力。",
|
|
5
|
+
"main": "dist/index.cjs.js",
|
|
6
|
+
"module": "dist/index.es.js",
|
|
7
|
+
"unpkg": "dist/index.umd.js",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"require": "./dist/index.cjs.js",
|
|
11
|
+
"import": "./dist/index.es.js",
|
|
12
|
+
"default": "./dist/index.cjs.js"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist",
|
|
17
|
+
"README.md",
|
|
18
|
+
"LICENSE"
|
|
19
|
+
],
|
|
20
|
+
"sideEffects": false,
|
|
21
|
+
"scripts": {
|
|
22
|
+
"build": "rollup -c rollup.config.cjs"
|
|
23
|
+
},
|
|
24
|
+
"dependencies": {
|
|
25
|
+
"vue-demi": "^0.14.10"
|
|
26
|
+
},
|
|
27
|
+
"keywords": [
|
|
28
|
+
"vue",
|
|
29
|
+
"vue2",
|
|
30
|
+
"vue3",
|
|
31
|
+
"tianditu",
|
|
32
|
+
"map",
|
|
33
|
+
"component"
|
|
34
|
+
],
|
|
35
|
+
"author": "",
|
|
36
|
+
"license": "MIT",
|
|
37
|
+
"repository": {
|
|
38
|
+
"type": "git",
|
|
39
|
+
"url": "https://github.com/your-name/tdt-map-vue.git"
|
|
40
|
+
},
|
|
41
|
+
"bugs": {
|
|
42
|
+
"url": "https://github.com/your-name/tdt-map-vue/issues"
|
|
43
|
+
},
|
|
44
|
+
"homepage": "https://github.com/your-name/tdt-map-vue#readme",
|
|
45
|
+
"peerDependencies": {
|
|
46
|
+
"vue": "^2.6.0 || ^3.2.0"
|
|
47
|
+
},
|
|
48
|
+
"devDependencies": {
|
|
49
|
+
"@rollup/plugin-commonjs": "^29.0.0",
|
|
50
|
+
"@rollup/plugin-node-resolve": "^16.0.1",
|
|
51
|
+
"@rollup/plugin-terser": "^0.4.4",
|
|
52
|
+
"rollup": "^2.79.2",
|
|
53
|
+
"rollup-plugin-vue": "^6.0.0",
|
|
54
|
+
"vue-template-compiler": "^2.7.16"
|
|
55
|
+
}
|
|
56
|
+
}
|