@vue-start/map 0.0.3 → 0.0.4
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/dist/index.d.ts +147 -2
- package/dist/index.es.js +34 -24
- package/dist/index.js +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as vue from 'vue';
|
|
2
|
-
import { ShallowRef, ExtractPropTypes, PropType, WatchSource, UnwrapNestedRefs, Ref, UnwrapRef } from 'vue';
|
|
2
|
+
import { ShallowRef, ExtractPropTypes, PropType, ToRef, DefineComponent, WatchSource, UnwrapNestedRefs, Ref, UnwrapRef } from 'vue';
|
|
3
3
|
|
|
4
4
|
declare type TEvents = {
|
|
5
5
|
type: AMap.EventType;
|
|
@@ -122,6 +122,151 @@ declare const MapPluginType: {
|
|
|
122
122
|
Weather: string;
|
|
123
123
|
};
|
|
124
124
|
|
|
125
|
+
/**
|
|
126
|
+
* 与地图绑定关系
|
|
127
|
+
* @param features
|
|
128
|
+
*/
|
|
129
|
+
declare const useMapConnect: (features: any) => void;
|
|
130
|
+
/**
|
|
131
|
+
* 与地图绑定关系2
|
|
132
|
+
* @param feature
|
|
133
|
+
*/
|
|
134
|
+
declare const useMapConnect2: (feature: any) => void;
|
|
135
|
+
declare const useMapControlConnect: (feature: any) => void;
|
|
136
|
+
/**
|
|
137
|
+
* show 处理
|
|
138
|
+
* @param feature
|
|
139
|
+
* @param showRef
|
|
140
|
+
*/
|
|
141
|
+
declare const useShowConnect: (feature: any, showRef: ToRef<boolean>) => void;
|
|
142
|
+
/**
|
|
143
|
+
* 根据 key 调用 `set${Key}`方法
|
|
144
|
+
* @param feature
|
|
145
|
+
* @param optsRef
|
|
146
|
+
*/
|
|
147
|
+
declare const useFeatureOptMethods: (feature: any, optsRef: ToRef<any>) => void;
|
|
148
|
+
declare type TFeature = {
|
|
149
|
+
/********************************* overlay ***********************************/
|
|
150
|
+
Marker: {
|
|
151
|
+
type: AMap.Marker;
|
|
152
|
+
opts: AMap.MarkerOptions;
|
|
153
|
+
};
|
|
154
|
+
Polygon: {
|
|
155
|
+
type: AMap.Polygon;
|
|
156
|
+
opts: AMap.PolygonOptions;
|
|
157
|
+
};
|
|
158
|
+
Polyline: {
|
|
159
|
+
type: AMap.Polyline;
|
|
160
|
+
opts: AMap.PolylineOptions;
|
|
161
|
+
};
|
|
162
|
+
Circle: {
|
|
163
|
+
type: AMap.Circle;
|
|
164
|
+
opts: AMap.CircleOptions;
|
|
165
|
+
};
|
|
166
|
+
Rectangle: {
|
|
167
|
+
type: AMap.Rectangle;
|
|
168
|
+
opts: AMap.RectangleOptions;
|
|
169
|
+
};
|
|
170
|
+
Ellipse: {
|
|
171
|
+
type: AMap.Ellipse;
|
|
172
|
+
opts: AMap.EllipseOptions;
|
|
173
|
+
};
|
|
174
|
+
BezierCurve: {
|
|
175
|
+
type: AMap.BezierCurve;
|
|
176
|
+
opts: AMap.BezierCurveOptions;
|
|
177
|
+
};
|
|
178
|
+
ElasticMarker: {
|
|
179
|
+
type: any;
|
|
180
|
+
opts: any;
|
|
181
|
+
};
|
|
182
|
+
CircleMarker: {
|
|
183
|
+
type: AMap.CircleMarker;
|
|
184
|
+
opts: AMap.CircleMarkerOptions;
|
|
185
|
+
};
|
|
186
|
+
LabelMarker: {
|
|
187
|
+
type: AMap.LabelMarker;
|
|
188
|
+
opts: AMap.LabelMarkerOptions;
|
|
189
|
+
};
|
|
190
|
+
Text: {
|
|
191
|
+
type: AMap.Text;
|
|
192
|
+
opts: AMap.TextOptions;
|
|
193
|
+
};
|
|
194
|
+
/********************************* layer ***********************************/
|
|
195
|
+
TileLayer: {
|
|
196
|
+
type: AMap.TileLayer;
|
|
197
|
+
opts: AMap.TileLayerOptions;
|
|
198
|
+
};
|
|
199
|
+
"TileLayer.Satellite": {
|
|
200
|
+
type: any;
|
|
201
|
+
opts: AMap.SatelliteLayerOptions;
|
|
202
|
+
};
|
|
203
|
+
"TileLayer.RoadNet": {
|
|
204
|
+
type: any;
|
|
205
|
+
opts: AMap.RoadnetLayerOptions;
|
|
206
|
+
};
|
|
207
|
+
"TileLayer.Traffic": {
|
|
208
|
+
type: any;
|
|
209
|
+
opts: AMap.TrafficLayerOptions;
|
|
210
|
+
};
|
|
211
|
+
Buildings: {
|
|
212
|
+
type: AMap.BuildingLayer;
|
|
213
|
+
opts: AMap.BuildingLayerOpts;
|
|
214
|
+
};
|
|
215
|
+
MassMarks: {
|
|
216
|
+
type: AMap.MassMarks;
|
|
217
|
+
opts: AMap.MassMarkersOptions & {
|
|
218
|
+
data?: AMap.MassData[];
|
|
219
|
+
};
|
|
220
|
+
};
|
|
221
|
+
"TileLayer.WMS": {
|
|
222
|
+
type: any;
|
|
223
|
+
opts: AMap.WMSLayerOptions;
|
|
224
|
+
};
|
|
225
|
+
"TileLayer.WMTS": {
|
|
226
|
+
type: any;
|
|
227
|
+
opts: AMap.WMTSLayerOptions;
|
|
228
|
+
};
|
|
229
|
+
"TileLayer.Flexible": {
|
|
230
|
+
type: any;
|
|
231
|
+
opts: AMap.FlexibleLayerOptions;
|
|
232
|
+
};
|
|
233
|
+
ImageLayer: {
|
|
234
|
+
type: AMap.ImageLayer;
|
|
235
|
+
opts: AMap.ImageLayerOptions;
|
|
236
|
+
};
|
|
237
|
+
CanvasLayer: {
|
|
238
|
+
type: AMap.CanvasLayer;
|
|
239
|
+
opts: AMap.CanvasLayerOptions;
|
|
240
|
+
};
|
|
241
|
+
CustomLayer: {
|
|
242
|
+
type: AMap.CustomLayer;
|
|
243
|
+
opts: AMap.CustomLayerOption & {
|
|
244
|
+
canvas: HTMLCanvasElement;
|
|
245
|
+
};
|
|
246
|
+
};
|
|
247
|
+
/********************************* DistrictLayer ***********************************/
|
|
248
|
+
"DistrictLayer.World": {
|
|
249
|
+
type: AMap.DistrictLayer;
|
|
250
|
+
opts: AMap.DistrictLayerOptions;
|
|
251
|
+
};
|
|
252
|
+
"DistrictLayer.Country": {
|
|
253
|
+
type: AMap.DistrictLayer;
|
|
254
|
+
opts: AMap.DistrictLayerOptions;
|
|
255
|
+
};
|
|
256
|
+
"DistrictLayer.Province": {
|
|
257
|
+
type: AMap.DistrictLayer;
|
|
258
|
+
opts: AMap.DistrictLayerOptions;
|
|
259
|
+
};
|
|
260
|
+
};
|
|
261
|
+
declare const createFeature: <T extends keyof TFeature>(name: T, { useMapConnect, createFeatureObj, needDom, }: {
|
|
262
|
+
useMapConnect: (feature: TFeature[T]["type"]) => void;
|
|
263
|
+
createFeatureObj?: ((opts: TFeature[T]["opts"]) => TFeature[T]["type"]) | undefined;
|
|
264
|
+
needDom?: boolean | undefined;
|
|
265
|
+
}) => DefineComponent<any, any, any>;
|
|
266
|
+
declare const createPluginFeature: (plugins: string[], Feature: any) => DefineComponent<any, () => JSX.Element, unknown, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, Record<string, any>, string, vue.VNodeProps & vue.AllowedComponentProps & vue.ComponentCustomProps, Readonly<any>, {} | {
|
|
267
|
+
[x: string]: any;
|
|
268
|
+
}>;
|
|
269
|
+
|
|
125
270
|
/**
|
|
126
271
|
* overlay 绑定快捷方式
|
|
127
272
|
* @param overlay
|
|
@@ -436,4 +581,4 @@ declare const ApiNames: {
|
|
|
436
581
|
StationSearch_searchById: string;
|
|
437
582
|
};
|
|
438
583
|
|
|
439
|
-
export { ApiNames, BezierCurve, Buildings, CanvasLayer, Circle, CircleMarker, ControlBar, CustomLayer, DistrictLayerCountry, DistrictLayerProvince, DistrictLayerWorld, ElasticMarker, Ellipse, HawkEye, HeatMap, IMapProvide, IUseMapApiOptions, IUseMapApiResult, ImageLayer, InfoWindow, LabelsLayer, LayerGroup, Map, MapPlugin, MapPluginType, MapProps, MapType, Marker, MassMarks, OverlayGroup, Polygon, Polyline, Rectangle, Scale, TLoadOpts, Text, TileLayer, TileLayerFlexible, TileLayerRoadNet, TileLayerSatellite, TileLayerTraffic, ToolBar, VideoLayer, provideMap, useMap, useMapApi, useMapLayerConnect, useMapOverlayConnect, useMapPlugin };
|
|
584
|
+
export { ApiNames, BezierCurve, Buildings, CanvasLayer, Circle, CircleMarker, ControlBar, CustomLayer, DistrictLayerCountry, DistrictLayerProvince, DistrictLayerWorld, ElasticMarker, Ellipse, HawkEye, HeatMap, IMapProvide, IUseMapApiOptions, IUseMapApiResult, ImageLayer, InfoWindow, LabelsLayer, LayerGroup, Map, MapPlugin, MapPluginType, MapProps, MapType, Marker, MassMarks, OverlayGroup, Polygon, Polyline, Rectangle, Scale, TLoadOpts, Text, TileLayer, TileLayerFlexible, TileLayerRoadNet, TileLayerSatellite, TileLayerTraffic, ToolBar, VideoLayer, createFeature, createPluginFeature, provideMap, useFeatureOptMethods, useMap, useMapApi, useMapConnect, useMapConnect2, useMapControlConnect, useMapLayerConnect, useMapOverlayConnect, useMapPlugin, useShowConnect };
|
package/dist/index.es.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { defineComponent as v, shallowRef as
|
|
2
|
-
import
|
|
3
|
-
import { useEffect as i, useWatch as R, createExposeObj as
|
|
4
|
-
import { forEach as B, size as x, upperFirst as
|
|
5
|
-
const
|
|
1
|
+
import { defineComponent as v, shallowRef as X, ref as g, createVNode as A, provide as Y, inject as Z, toRef as C, Teleport as $, mergeProps as ee } from "vue";
|
|
2
|
+
import ae from "@amap/amap-jsapi-loader";
|
|
3
|
+
import { useEffect as i, useWatch as R, createExposeObj as te, useState as re } from "@vue-start/hooks";
|
|
4
|
+
import { forEach as B, size as x, upperFirst as ne, isFunction as h, isNumber as J, debounce as z, isArray as _, map as oe, omit as V, isBoolean as ce, split as se, get as ue } from "lodash";
|
|
5
|
+
const q = (e, a) => {
|
|
6
6
|
i(() => (B(a, (r) => {
|
|
7
7
|
e.on(r.type, r.handler, void 0, r.once);
|
|
8
8
|
}), () => {
|
|
@@ -10,7 +10,7 @@ const V = (e, a) => {
|
|
|
10
10
|
e.off(r.type, r.handler);
|
|
11
11
|
});
|
|
12
12
|
}), []);
|
|
13
|
-
},
|
|
13
|
+
}, K = Symbol("amap-key"), j = (e) => Y(K, e), m = () => Z(K), ie = () => ({
|
|
14
14
|
securityJsCode: {
|
|
15
15
|
type: String
|
|
16
16
|
},
|
|
@@ -46,7 +46,7 @@ const V = (e, a) => {
|
|
|
46
46
|
const {
|
|
47
47
|
mapRef: a
|
|
48
48
|
} = m();
|
|
49
|
-
return
|
|
49
|
+
return q(a.value, e.events), () => null;
|
|
50
50
|
}
|
|
51
51
|
}), Le = v({
|
|
52
52
|
props: {
|
|
@@ -57,11 +57,11 @@ const V = (e, a) => {
|
|
|
57
57
|
expose: r
|
|
58
58
|
}) => {
|
|
59
59
|
le(e.securityJsCode);
|
|
60
|
-
const n =
|
|
60
|
+
const n = X(), t = g();
|
|
61
61
|
return r({
|
|
62
62
|
mapRef: n,
|
|
63
63
|
domRef: t
|
|
64
|
-
}), i(() => (
|
|
64
|
+
}), i(() => (ae.load({
|
|
65
65
|
version: "2.0",
|
|
66
66
|
...e.loadOpts
|
|
67
67
|
}).then((o) => {
|
|
@@ -86,7 +86,7 @@ const V = (e, a) => {
|
|
|
86
86
|
}, null), n.value && ((o = a.default) == null ? void 0 : o.call(a))]);
|
|
87
87
|
};
|
|
88
88
|
}
|
|
89
|
-
}),
|
|
89
|
+
}), Q = (e, a) => {
|
|
90
90
|
const { mapRef: r } = m();
|
|
91
91
|
i(() => {
|
|
92
92
|
if (!r.value) {
|
|
@@ -105,7 +105,7 @@ const V = (e, a) => {
|
|
|
105
105
|
},
|
|
106
106
|
setup: (e, { slots: a }) => {
|
|
107
107
|
const r = g(!1);
|
|
108
|
-
return
|
|
108
|
+
return Q(e.plugins, () => {
|
|
109
109
|
r.value = !0;
|
|
110
110
|
}), () => {
|
|
111
111
|
var n;
|
|
@@ -158,7 +158,7 @@ const V = (e, a) => {
|
|
|
158
158
|
console.error(r);
|
|
159
159
|
}
|
|
160
160
|
}), []);
|
|
161
|
-
},
|
|
161
|
+
}, U = (e) => {
|
|
162
162
|
const {
|
|
163
163
|
mapRef: a
|
|
164
164
|
} = m();
|
|
@@ -194,7 +194,7 @@ const V = (e, a) => {
|
|
|
194
194
|
}, k = (e, a) => {
|
|
195
195
|
i(() => {
|
|
196
196
|
B(a.value, (r, n) => {
|
|
197
|
-
const t = "set" +
|
|
197
|
+
const t = "set" + ne(n);
|
|
198
198
|
e[t] && h(e[t]) && e[t](r);
|
|
199
199
|
});
|
|
200
200
|
}, a);
|
|
@@ -227,7 +227,7 @@ const V = (e, a) => {
|
|
|
227
227
|
const p = C(t, "show");
|
|
228
228
|
P(s, p);
|
|
229
229
|
const d = C(t, "opts$");
|
|
230
|
-
k(s, d),
|
|
230
|
+
k(s, d), q(s, t.events), u({
|
|
231
231
|
getFeature: () => s
|
|
232
232
|
});
|
|
233
233
|
const M = g();
|
|
@@ -250,10 +250,10 @@ const V = (e, a) => {
|
|
|
250
250
|
expose: t
|
|
251
251
|
}) => {
|
|
252
252
|
const o = g();
|
|
253
|
-
return t(
|
|
253
|
+
return t(te(o, ["getFeature"])), () => A(de, {
|
|
254
254
|
plugins: e
|
|
255
255
|
}, {
|
|
256
|
-
default: () => [A(a,
|
|
256
|
+
default: () => [A(a, ee({
|
|
257
257
|
ref: o
|
|
258
258
|
}, r), n)]
|
|
259
259
|
});
|
|
@@ -464,7 +464,7 @@ const V = (e, a) => {
|
|
|
464
464
|
events: { type: Array }
|
|
465
465
|
},
|
|
466
466
|
setup: (e, { expose: a }) => {
|
|
467
|
-
const { mapRef: r } = m(), n = new window.AMap.LabelsLayer(e.opts), t = () =>
|
|
467
|
+
const { mapRef: r } = m(), n = new window.AMap.LabelsLayer(e.opts), t = () => oe(e.data, (s) => {
|
|
468
468
|
const p = new window.AMap.LabelMarker({
|
|
469
469
|
...e.itemOpts,
|
|
470
470
|
...s
|
|
@@ -498,12 +498,15 @@ const V = (e, a) => {
|
|
|
498
498
|
useMapConnect: y,
|
|
499
499
|
createFeatureObj: (e) => new window.AMap.TileLayer.Traffic(e)
|
|
500
500
|
}), Qe = c("Buildings", { useMapConnect: y }), Ue = c("MassMarks", {
|
|
501
|
-
useMapConnect:
|
|
502
|
-
createFeatureObj: (e) => new window.AMap.MassMarks((e == null ? void 0 : e.data) || [],
|
|
501
|
+
useMapConnect: U,
|
|
502
|
+
createFeatureObj: (e) => new window.AMap.MassMarks((e == null ? void 0 : e.data) || [], V(e, "data"))
|
|
503
503
|
}), Xe = c("TileLayer.Flexible", {
|
|
504
504
|
useMapConnect: y,
|
|
505
505
|
createFeatureObj: (e) => new window.AMap.TileLayer.Flexible(e)
|
|
506
|
-
}), Ye = c("ImageLayer", { useMapConnect: y }), Ze = c("VideoLayer", { useMapConnect: y }), ea = c("CanvasLayer", { useMapConnect: y }), aa = c("CustomLayer", {
|
|
506
|
+
}), Ye = c("ImageLayer", { useMapConnect: y }), Ze = c("VideoLayer", { useMapConnect: y }), ea = c("CanvasLayer", { useMapConnect: y }), aa = c("CustomLayer", {
|
|
507
|
+
useMapConnect: y,
|
|
508
|
+
createFeatureObj: (e) => new window.AMap.CustomLayer(e == null ? void 0 : e.canvas, V(e, "canvas"))
|
|
509
|
+
}), ta = c("DistrictLayer.World", {
|
|
507
510
|
useMapConnect: y,
|
|
508
511
|
createFeatureObj: (e) => new window.AMap.DistrictLayer.World(e)
|
|
509
512
|
}), ra = c("DistrictLayer.Country", {
|
|
@@ -513,11 +516,11 @@ const V = (e, a) => {
|
|
|
513
516
|
useMapConnect: y,
|
|
514
517
|
createFeatureObj: (e) => new window.AMap.DistrictLayer.Province(e)
|
|
515
518
|
}), he = c("HeatMap", {
|
|
516
|
-
useMapConnect:
|
|
519
|
+
useMapConnect: U,
|
|
517
520
|
createFeatureObj: (e) => new window.AMap.HeatMap(null, e)
|
|
518
521
|
}), oa = L([S.HeatMap], he), ca = (e, a) => {
|
|
519
522
|
let r = !1, n = null;
|
|
520
|
-
const [t, o] =
|
|
523
|
+
const [t, o] = re(), u = g(ce(a.initEmit) ? a.initEmit : !1), s = se(e, "_"), p = s[0], d = s[1], M = () => {
|
|
521
524
|
const f = ue(window, p);
|
|
522
525
|
return f ? new f({ ...a.opts, ...n == null ? void 0 : n.opts }) : null;
|
|
523
526
|
}, T = (f) => f || (h(a.params) ? a.params() : a.params || []), l = () => {
|
|
@@ -532,7 +535,7 @@ const V = (e, a) => {
|
|
|
532
535
|
o(b), (I = a.onComplete) == null || I.call(a, O, b), O === "complete" ? (N = a.onSuccess) == null || N.call(a, b) : O === "error" ? (H = a.onFail) == null || H.call(a, b) : O === "no_data" && ((W = a.onNoData) == null || W.call(a, b)), n = null, u.value = !1;
|
|
533
536
|
});
|
|
534
537
|
};
|
|
535
|
-
|
|
538
|
+
Q([p], () => {
|
|
536
539
|
r = !0, l();
|
|
537
540
|
});
|
|
538
541
|
const E = (f, D) => {
|
|
@@ -594,10 +597,17 @@ export {
|
|
|
594
597
|
Ke as TileLayerTraffic,
|
|
595
598
|
Ie as ToolBar,
|
|
596
599
|
Ze as VideoLayer,
|
|
600
|
+
c as createFeature,
|
|
601
|
+
L as createPluginFeature,
|
|
597
602
|
j as provideMap,
|
|
603
|
+
k as useFeatureOptMethods,
|
|
598
604
|
m as useMap,
|
|
599
605
|
ca as useMapApi,
|
|
606
|
+
G as useMapConnect,
|
|
607
|
+
U as useMapConnect2,
|
|
608
|
+
F as useMapControlConnect,
|
|
600
609
|
y as useMapLayerConnect,
|
|
601
610
|
w as useMapOverlayConnect,
|
|
602
|
-
|
|
611
|
+
Q as useMapPlugin,
|
|
612
|
+
P as useShowConnect
|
|
603
613
|
};
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const o=require("vue"),H=require("@amap/amap-jsapi-loader"),i=require("@vue-start/hooks"),u=require("lodash"),V=e=>e&&typeof e=="object"&&"default"in e?e:{default:e},$=V(H),j=(e,a)=>{i.useEffect(()=>(u.forEach(a,r=>{e.on(r.type,r.handler,void 0,r.once)}),()=>{u.forEach(a,r=>{e.off(r.type,r.handler)})}),[])},G=Symbol("amap-key"),b=e=>o.provide(G,e),C=()=>o.inject(G),x=()=>({securityJsCode:{type:String},loadOpts:{type:Object},opts:{type:Object},events:{type:Array}}),J=e=>{var a;if(!!e){if(!window._AMapSecurityConfig||!((a=window._AMapSecurityConfig)!=null&&a.securityJsCode)){window._AMapSecurityConfig={securityJsCode:e};return}window._AMapSecurityConfig.securityJsCode!==e&&(window._AMapSecurityConfig={securityJsCode:e},console.warn("\u5F53\u524Dwindow\u5BF9\u8C61\u5DF2\u7ECF\u6CE8\u5165\u8FC7securityJsCode\u503C\uFF0C\u53EF\u80FD\u9020\u6210\u95EE\u9898"))}},q=o.defineComponent({props:{events:{type:Array}},setup:e=>{const{mapRef:a}=C();return j(a.value,e.events),()=>null}}),z=o.defineComponent({props:{...x()},setup:(e,{slots:a,expose:r})=>{J(e.securityJsCode);const n=o.shallowRef(),t=o.ref();return r({mapRef:n,domRef:t}),i.useEffect(()=>($.default.load({version:"2.0",...e.loadOpts}).then(c=>{const p=new c.Map(t.value,{...e.opts});p.on("complete",()=>{n.value=p})}).catch(c=>{console.error("\u52A0\u8F7D\u5730\u56FE\u9519\u8BEF"),console.error(c)}),()=>{n.value&&n.value.destroy()}),[]),b({mapRef:n}),()=>{var c;return o.createVNode("div",{ref:t},[n.value&&o.createVNode(q,{events:e.events},null),n.value&&((c=a.default)==null?void 0:c.call(a))])}}}),k=(e,a)=>{const{mapRef:r}=C();i.useEffect(()=>{if(!r.value){console.warn("\u8BF7\u5728Map\u7EC4\u4EF6\u5185\u4F7F\u7528 useMapPlugin");return}if(!e||u.size(e)<=0){a();return}window.AMap.plugin(e,a)},[])},W=o.defineComponent({props:{plugins:Array},setup:(e,{slots:a})=>{const r=o.ref(!1);return k(e.plugins,()=>{r.value=!0}),()=>{var n;return r.value?(n=a.default)==null?void 0:n.call(a):null}}}),A={ElasticMarker:"AMap.ElasticMarker",ControlBar:"AMap.ControlBar",ToolBar:"AMap.ToolBar",Scale:"AMap.Scale",HawkEye:"AMap.HawkEye",MapType:"AMap.MapType",AdvancedInfoWindow:"AMap.AdvancedInfoWindow",DragRoute:"AMap.DragRoute",IndoorMap:"AMap.IndoorMap",MouseTool:"AMap.MouseTool",CircleEditor:"AMap.CircleEditor",PolygonEditor:"AMap.PolygonEditor",PolylineEditor:"AMap.PolylineEditor",MarkerCluster:"AMap.MarkerCluster",RangingTool:"AMap.RangingTool",Geolocation:"AMap.Geolocation",Geocoder:"AMap.Geocoder",AutoComplete:"AMap.AutoComplete",PlaceSearch:"AMap.PlaceSearch",LineSearch:"AMap.LineSearch",DistrictSearch:"AMap.DistrictSearch",StationSearch:"AMap.StationSearch",CitySearch:"AMap.CitySearch",CloudDataSearch:"AMap.CloudDataSearch",RoadInfoSearch:"AMap.RoadInfoSearch",Driving:"AMap.Driving",TruckDriving:"AMap.TruckDriving",Transfer:"AMap.Transfer",Walking:"AMap.Walking",Riding:"AMap.Riding",ArrivalRange:"AMap.ArrivalRange",GraspRoad:"AMap.GraspRoad",HeatMap:"AMap.HeatMap",Weather:"AMap.Weather"},B=e=>{const{mapRef:a}=C();i.useEffect(()=>(a.value.add(e),()=>{try{a.value.remove(e)}catch(r){console.error(r)}}),[])},I=e=>{const{mapRef:a}=C();i.useEffect(()=>(e.setMap(a.value),()=>{try{e.setMap(null)}catch(r){console.error(r)}}),[])},L=e=>{const{mapRef:a}=C();i.useEffect(()=>(a.value.addControl(e),()=>{try{a.value.removeControl(e)}catch(r){console.error(r)}}),[])},E=(e,a)=>{const r=()=>{e&&u.isFunction(e.show)&&e.show()},n=()=>{e&&u.isFunction(e.hide)&&e.hide()};i.useEffect(()=>{a.value||n()},[]),i.useWatch(()=>{a.value?r():n()},a)},R=(e,a)=>{i.useEffect(()=>{u.forEach(a.value,(r,n)=>{const t="set"+u.upperFirst(n);e[t]&&u.isFunction(e[t])&&e[t](r)})},a)},s=(e,{useMapConnect:a,createFeatureObj:r,needDom:n})=>o.defineComponent({props:{opts:{type:Object},opts$:{type:Object},show:{type:Boolean,default:!0},events:{type:Array}},setup:(t,{slots:c,expose:p})=>{const l=r?r(t.opts):new window.AMap[e](t.opts);a(l);const f=o.toRef(t,"show");E(l,f);const M=o.toRef(t,"opts$");R(l,M),j(l,t.events),p({getFeature:()=>l});const m=o.ref();return i.useEffect(()=>{m.value&&u.isFunction(l.setContent)&&l.setContent(m.value)},m),()=>n&&c.default?o.createVNode(o.Teleport,{to:"body"},{default:()=>[o.createVNode("div",{ref:m},[c.default()])]}):null}}),T=(e,a)=>o.defineComponent({props:{...a.props},setup:(r,{slots:n,expose:t})=>{const c=o.ref();return t(i.createExposeObj(c,["getFeature"])),()=>o.createVNode(W,{plugins:e},{default:()=>[o.createVNode(a,o.mergeProps({ref:c},r),n)]})}}),K=()=>{const{mapRef:e,overlayGroup:a}=C();return{addToMap:t=>{if(a){u.isArray(t)?a.addOverlays(t):a.addOverlay(t);return}e.value.add(t)},removeFromMap:t=>{if(a){u.isArray(t)?a.removeOverlays(t):a.removeOverlay(t);return}try{e.value.remove(t)}catch(c){console.error(c)}}}},h=e=>{const{addToMap:a,removeFromMap:r}=K();i.useEffect(()=>(a(e),()=>{r(e)}),[])},Q=o.defineComponent({props:{bind:{type:Boolean,default:!1},bindTime:{type:Number,default:void 0},opts$:{type:Object},show:{type:Boolean,default:!0},events:{type:Array}},setup:(e,{slots:a,expose:r})=>{const{mapRef:n}=C(),t=new window.AMap.OverlayGroup;let c=!1;const p=()=>{c||(n.value.add(t),c=!0)},l=()=>{try{n.value.remove(t)}catch(d){console.error(d)}c=!1},f=()=>t;i.useEffect(()=>()=>{l()},[]),i.useEffect(()=>{if(!u.isNumber(e.bindTime))return;const d=setTimeout(()=>{p()},e.bindTime);return()=>{d&&clearTimeout(d)}},[]);const M=u.debounce(()=>{p()},300);i.useWatch(()=>{e.bind&&M()},()=>e.bind);const m=o.toRef(e,"show");E(t,m);const w=o.toRef(e,"opts$");return R(t,w),r({getFeature:f,addToMap:p,removeFormMap:l}),b({mapRef:n,overlayGroup:t}),()=>{var d;return(d=a.default)==null?void 0:d.call(a)}}}),U=o.defineComponent({props:{opts:{type:Object},opts$:{type:Object},height:{type:Number,default:void 0}},setup:(e,{slots:a,emit:r})=>{const{mapRef:n}=C(),t=new window.AMap.InfoWindow({closeWhenClickMap:!0,isCustom:!!a.default,...e.opts}),c=o.toRef(e,"opts$");R(t,c);const p=()=>{r("close")};i.useEffect(()=>(t.on("close",p),()=>{t.off("close",p),t.close()}),[]),i.useEffect(()=>{var M,m;const f=((M=e.opts$)==null?void 0:M.position)||((m=e.opts)==null?void 0:m.position);!f||t.open(n.value,f,e.height)},()=>{var f;return(f=e.opts$)==null?void 0:f.position});const l=o.ref();return i.useEffect(()=>{l.value&&u.isFunction(t.setContent)&&t.setContent(l.value)},l),()=>a.default?o.createVNode(o.Teleport,{to:"body"},{default:()=>[o.createVNode("div",{ref:l},[a.default()])]}):null}}),X=s("CircleMarker",{useMapConnect:B}),Y=s("Text",{useMapConnect:B}),Z=s("ElasticMarker",{useMapConnect:B}),ee=s("Marker",{useMapConnect:h,needDom:!0}),ae=s("Polygon",{useMapConnect:h}),te=s("Polyline",{useMapConnect:h}),re=s("Circle",{useMapConnect:h}),ne=s("Rectangle",{useMapConnect:h}),oe=s("Ellipse",{useMapConnect:h}),ce=s("BezierCurve",{useMapConnect:h}),se=s("ToolBar",{useMapConnect:L}),ue=T([A.ToolBar],se),ie=s("Scale",{useMapConnect:L}),le=T([A.Scale],ie),pe=s("HawkEye",{useMapConnect:L}),de=T([A.HawkEye],pe),fe=s("MapType",{useMapConnect:L}),Me=T([A.MapType],fe),ye=s("ControlBar",{useMapConnect:L}),me=T([A.ControlBar],ye),Ce=()=>{const{mapRef:e,layerGroup:a}=C();return{addToMap:t=>{if(a){u.isArray(t)?a.addLayers(t):a.addLayer(t);return}e.value.add(t)},removeFromMap:t=>{if(a){u.isArray(t)?a.removeLayers(t):a.removeLayer(t);return}try{e.value.remove(t)}catch(c){console.error(c)}}}},y=e=>{const{addToMap:a,removeFromMap:r}=Ce();i.useEffect(()=>(a(e),()=>{r(e)}),[])},ve=o.defineComponent({props:{bind:{type:Boolean,default:!1},bindTime:{type:Number,default:void 0},opts$:{type:Object},show:{type:Boolean,default:!0},events:{type:Array}},setup:(e,{slots:a,expose:r})=>{const{mapRef:n}=C(),t=new window.AMap.LayerGroup;let c=!1;const p=()=>{c||(t.setMap(n.value),c=!0)},l=()=>{try{t.setMap(null)}catch(d){console.error(d)}c=!1},f=()=>t;i.useEffect(()=>()=>{l()},[]),i.useEffect(()=>{if(!u.isNumber(e.bindTime))return;const d=setTimeout(()=>{p()},e.bindTime);return()=>{d&&clearTimeout(d)}},[]);const M=u.debounce(()=>{p()},300);i.useWatch(()=>{e.bind&&M()},()=>e.bind);const m=o.toRef(e,"show");E(t,m);const w=o.toRef(e,"opts$");return R(t,w),r({getFeature:f,addToMap:p,removeFormMap:l}),b({mapRef:n,layerGroup:t}),()=>{var d;return(d=a.default)==null?void 0:d.call(a)}}}),he=o.defineComponent({props:{opts:{type:Object},itemOpts:{type:Object},data:{type:Array},show:{type:Boolean,default:!0},events:{type:Array}},setup:(e,{expose:a})=>{const{mapRef:r}=C(),n=new window.AMap.LabelsLayer(e.opts),t=()=>u.map(e.data,l=>{const f=new window.AMap.LabelMarker({...e.itemOpts,...l});return e.events&&u.forEach(e.events,M=>{f.on(M.type,M.handler,void 0,M.once)}),f}),c=()=>{n.clear();const l=t();n.add(l)};i.useEffect(()=>(u.size(e.data)>0&&c(),r.value.add(n),()=>{n.clear(),r.value.remove(n)}),[]),i.useWatch(()=>{c()},()=>e.data);const p=o.toRef(e,"show");return E(n,p),a({getFeature:()=>n}),()=>null}}),Ae=s("TileLayer",{useMapConnect:y}),we=s("TileLayer.Satellite",{useMapConnect:y,createFeatureObj:e=>new window.AMap.TileLayer.Satellite(e)}),Te=s("TileLayer.RoadNet",{useMapConnect:y,createFeatureObj:e=>new window.AMap.TileLayer.RoadNet(e)}),ge=s("TileLayer.Traffic",{useMapConnect:y,createFeatureObj:e=>new window.AMap.TileLayer.Traffic(e)}),Le=s("Buildings",{useMapConnect:y}),Se=s("MassMarks",{useMapConnect:I,createFeatureObj:e=>new window.AMap.MassMarks((e==null?void 0:e.data)||[],u.omit(e,"data"))}),be=s("TileLayer.Flexible",{useMapConnect:y,createFeatureObj:e=>new window.AMap.TileLayer.Flexible(e)}),Ee=s("ImageLayer",{useMapConnect:y}),Re=s("VideoLayer",{useMapConnect:y}),Fe=s("CanvasLayer",{useMapConnect:y}),Pe=s("CustomLayer",{useMapConnect:y}),ke=s("DistrictLayer.World",{useMapConnect:y,createFeatureObj:e=>new window.AMap.DistrictLayer.World(e)}),Be=s("DistrictLayer.Country",{useMapConnect:y,createFeatureObj:e=>new window.AMap.DistrictLayer.Country(e)}),Oe=s("DistrictLayer.Province",{useMapConnect:y,createFeatureObj:e=>new window.AMap.DistrictLayer.Province(e)}),_e=s("HeatMap",{useMapConnect:I,createFeatureObj:e=>new window.AMap.HeatMap(null,e)}),De=T([A.HeatMap],_e),Ne=(e,a)=>{let r=!1,n=null;const[t,c]=i.useState(),p=o.ref(u.isBoolean(a.initEmit)?a.initEmit:!1),l=u.split(e,"_"),f=l[0],M=l[1],m=()=>{const v=u.get(window,f);return v?new v({...a.opts,...n==null?void 0:n.opts}):null},w=v=>v||(u.isFunction(a.params)?a.params():a.params||[]),d=()=>{if(!n)return;const v=m();if(!v||!u.isFunction(v[M]))return;const P=w(n.params);p.value=!0,v[M](...P,(S,g)=>{var O,_,D,N;c(g),(O=a.onComplete)==null||O.call(a,S,g),S==="complete"?(_=a.onSuccess)==null||_.call(a,g):S==="error"?(D=a.onFail)==null||D.call(a,g):S==="no_data"&&((N=a.onNoData)==null||N.call(a,g)),n=null,p.value=!1})};k([f],()=>{r=!0,d()});const F=(v,P)=>{n={opts:v||a.opts,params:w(P)},r&&d()};return i.useEffect(()=>{a.initEmit&&F()},[]),i.useWatch(()=>F(),a.deps||[]),{data:t,request:F,requesting:p}},je={Geocoder_getLocation:"AMap.Geocoder_getLocation",Geocoder_getAddress:"AMap.Geocoder_getAddress",Autocomplete_search:"AMap.Autocomplete_search",PlaceSearch_search:"AMap.PlaceSearch_search",PlaceSearch_searchNearBy:"AMap.PlaceSearch_searchNearBy",PlaceSearch_searchInBounds:"AMap.PlaceSearch_searchInBounds",PlaceSearch_getDetails:"AMap.PlaceSearch_getDetails",DistrictSearch_search:"AMap.DistrictSearch_search",LineSearch_search:"AMap.LineSearch_search",LineSearch_searchById:"AMap.LineSearch_searchById",StationSearch_search:"AMap.StationSearch_search",StationSearch_searchById:"AMap.StationSearch_searchById"};exports.ApiNames=je;exports.BezierCurve=ce;exports.Buildings=Le;exports.CanvasLayer=Fe;exports.Circle=re;exports.CircleMarker=X;exports.ControlBar=me;exports.CustomLayer=Pe;exports.DistrictLayerCountry=Be;exports.DistrictLayerProvince=Oe;exports.DistrictLayerWorld=ke;exports.ElasticMarker=Z;exports.Ellipse=oe;exports.HawkEye=de;exports.HeatMap=De;exports.ImageLayer=Ee;exports.InfoWindow=U;exports.LabelsLayer=he;exports.LayerGroup=ve;exports.Map=z;exports.MapPlugin=W;exports.MapPluginType=A;exports.MapType=Me;exports.Marker=ee;exports.MassMarks=Se;exports.OverlayGroup=Q;exports.Polygon=ae;exports.Polyline=te;exports.Rectangle=ne;exports.Scale=le;exports.Text=Y;exports.TileLayer=Ae;exports.TileLayerFlexible=be;exports.TileLayerRoadNet=Te;exports.TileLayerSatellite=we;exports.TileLayerTraffic=ge;exports.ToolBar=ue;exports.VideoLayer=Re;exports.provideMap=b;exports.useMap=C;exports.useMapApi=Ne;exports.useMapLayerConnect=y;exports.useMapOverlayConnect=h;exports.useMapPlugin=k;
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const o=require("vue"),H=require("@amap/amap-jsapi-loader"),i=require("@vue-start/hooks"),u=require("lodash"),V=e=>e&&typeof e=="object"&&"default"in e?e:{default:e},$=V(H),G=(e,a)=>{i.useEffect(()=>(u.forEach(a,r=>{e.on(r.type,r.handler,void 0,r.once)}),()=>{u.forEach(a,r=>{e.off(r.type,r.handler)})}),[])},W=Symbol("amap-key"),R=e=>o.provide(W,e),m=()=>o.inject(W),x=()=>({securityJsCode:{type:String},loadOpts:{type:Object},opts:{type:Object},events:{type:Array}}),J=e=>{var a;if(!!e){if(!window._AMapSecurityConfig||!((a=window._AMapSecurityConfig)!=null&&a.securityJsCode)){window._AMapSecurityConfig={securityJsCode:e};return}window._AMapSecurityConfig.securityJsCode!==e&&(window._AMapSecurityConfig={securityJsCode:e},console.warn("\u5F53\u524Dwindow\u5BF9\u8C61\u5DF2\u7ECF\u6CE8\u5165\u8FC7securityJsCode\u503C\uFF0C\u53EF\u80FD\u9020\u6210\u95EE\u9898"))}},q=o.defineComponent({props:{events:{type:Array}},setup:e=>{const{mapRef:a}=m();return G(a.value,e.events),()=>null}}),z=o.defineComponent({props:{...x()},setup:(e,{slots:a,expose:r})=>{J(e.securityJsCode);const n=o.shallowRef(),t=o.ref();return r({mapRef:n,domRef:t}),i.useEffect(()=>($.default.load({version:"2.0",...e.loadOpts}).then(c=>{const p=new c.Map(t.value,{...e.opts});p.on("complete",()=>{n.value=p})}).catch(c=>{console.error("\u52A0\u8F7D\u5730\u56FE\u9519\u8BEF"),console.error(c)}),()=>{n.value&&n.value.destroy()}),[]),R({mapRef:n}),()=>{var c;return o.createVNode("div",{ref:t},[n.value&&o.createVNode(q,{events:e.events},null),n.value&&((c=a.default)==null?void 0:c.call(a))])}}}),k=(e,a)=>{const{mapRef:r}=m();i.useEffect(()=>{if(!r.value){console.warn("\u8BF7\u5728Map\u7EC4\u4EF6\u5185\u4F7F\u7528 useMapPlugin");return}if(!e||u.size(e)<=0){a();return}window.AMap.plugin(e,a)},[])},I=o.defineComponent({props:{plugins:Array},setup:(e,{slots:a})=>{const r=o.ref(!1);return k(e.plugins,()=>{r.value=!0}),()=>{var n;return r.value?(n=a.default)==null?void 0:n.call(a):null}}}),A={ElasticMarker:"AMap.ElasticMarker",ControlBar:"AMap.ControlBar",ToolBar:"AMap.ToolBar",Scale:"AMap.Scale",HawkEye:"AMap.HawkEye",MapType:"AMap.MapType",AdvancedInfoWindow:"AMap.AdvancedInfoWindow",DragRoute:"AMap.DragRoute",IndoorMap:"AMap.IndoorMap",MouseTool:"AMap.MouseTool",CircleEditor:"AMap.CircleEditor",PolygonEditor:"AMap.PolygonEditor",PolylineEditor:"AMap.PolylineEditor",MarkerCluster:"AMap.MarkerCluster",RangingTool:"AMap.RangingTool",Geolocation:"AMap.Geolocation",Geocoder:"AMap.Geocoder",AutoComplete:"AMap.AutoComplete",PlaceSearch:"AMap.PlaceSearch",LineSearch:"AMap.LineSearch",DistrictSearch:"AMap.DistrictSearch",StationSearch:"AMap.StationSearch",CitySearch:"AMap.CitySearch",CloudDataSearch:"AMap.CloudDataSearch",RoadInfoSearch:"AMap.RoadInfoSearch",Driving:"AMap.Driving",TruckDriving:"AMap.TruckDriving",Transfer:"AMap.Transfer",Walking:"AMap.Walking",Riding:"AMap.Riding",ArrivalRange:"AMap.ArrivalRange",GraspRoad:"AMap.GraspRoad",HeatMap:"AMap.HeatMap",Weather:"AMap.Weather"},F=e=>{const{mapRef:a}=m();i.useEffect(()=>(a.value.add(e),()=>{try{a.value.remove(e)}catch(r){console.error(r)}}),[])},B=e=>{const{mapRef:a}=m();i.useEffect(()=>(e.setMap(a.value),()=>{try{e.setMap(null)}catch(r){console.error(r)}}),[])},g=e=>{const{mapRef:a}=m();i.useEffect(()=>(a.value.addControl(e),()=>{try{a.value.removeControl(e)}catch(r){console.error(r)}}),[])},S=(e,a)=>{const r=()=>{e&&u.isFunction(e.show)&&e.show()},n=()=>{e&&u.isFunction(e.hide)&&e.hide()};i.useEffect(()=>{a.value||n()},[]),i.useWatch(()=>{a.value?r():n()},a)},b=(e,a)=>{i.useEffect(()=>{u.forEach(a.value,(r,n)=>{const t="set"+u.upperFirst(n);e[t]&&u.isFunction(e[t])&&e[t](r)})},a)},s=(e,{useMapConnect:a,createFeatureObj:r,needDom:n})=>o.defineComponent({props:{opts:{type:Object},opts$:{type:Object},show:{type:Boolean,default:!0},events:{type:Array}},setup:(t,{slots:c,expose:p})=>{const l=r?r(t.opts):new window.AMap[e](t.opts);a(l);const M=o.toRef(t,"show");S(l,M);const f=o.toRef(t,"opts$");b(l,f),G(l,t.events),p({getFeature:()=>l});const C=o.ref();return i.useEffect(()=>{C.value&&u.isFunction(l.setContent)&&l.setContent(C.value)},C),()=>n&&c.default?o.createVNode(o.Teleport,{to:"body"},{default:()=>[o.createVNode("div",{ref:C},[c.default()])]}):null}}),w=(e,a)=>o.defineComponent({props:{...a.props},setup:(r,{slots:n,expose:t})=>{const c=o.ref();return t(i.createExposeObj(c,["getFeature"])),()=>o.createVNode(I,{plugins:e},{default:()=>[o.createVNode(a,o.mergeProps({ref:c},r),n)]})}}),K=()=>{const{mapRef:e,overlayGroup:a}=m();return{addToMap:t=>{if(a){u.isArray(t)?a.addOverlays(t):a.addOverlay(t);return}e.value.add(t)},removeFromMap:t=>{if(a){u.isArray(t)?a.removeOverlays(t):a.removeOverlay(t);return}try{e.value.remove(t)}catch(c){console.error(c)}}}},h=e=>{const{addToMap:a,removeFromMap:r}=K();i.useEffect(()=>(a(e),()=>{r(e)}),[])},Q=o.defineComponent({props:{bind:{type:Boolean,default:!1},bindTime:{type:Number,default:void 0},opts$:{type:Object},show:{type:Boolean,default:!0},events:{type:Array}},setup:(e,{slots:a,expose:r})=>{const{mapRef:n}=m(),t=new window.AMap.OverlayGroup;let c=!1;const p=()=>{c||(n.value.add(t),c=!0)},l=()=>{try{n.value.remove(t)}catch(d){console.error(d)}c=!1},M=()=>t;i.useEffect(()=>()=>{l()},[]),i.useEffect(()=>{if(!u.isNumber(e.bindTime))return;const d=setTimeout(()=>{p()},e.bindTime);return()=>{d&&clearTimeout(d)}},[]);const f=u.debounce(()=>{p()},300);i.useWatch(()=>{e.bind&&f()},()=>e.bind);const C=o.toRef(e,"show");S(t,C);const T=o.toRef(e,"opts$");return b(t,T),r({getFeature:M,addToMap:p,removeFormMap:l}),R({mapRef:n,overlayGroup:t}),()=>{var d;return(d=a.default)==null?void 0:d.call(a)}}}),U=o.defineComponent({props:{opts:{type:Object},opts$:{type:Object},height:{type:Number,default:void 0}},setup:(e,{slots:a,emit:r})=>{const{mapRef:n}=m(),t=new window.AMap.InfoWindow({closeWhenClickMap:!0,isCustom:!!a.default,...e.opts}),c=o.toRef(e,"opts$");b(t,c);const p=()=>{r("close")};i.useEffect(()=>(t.on("close",p),()=>{t.off("close",p),t.close()}),[]),i.useEffect(()=>{var f,C;const M=((f=e.opts$)==null?void 0:f.position)||((C=e.opts)==null?void 0:C.position);!M||t.open(n.value,M,e.height)},()=>{var M;return(M=e.opts$)==null?void 0:M.position});const l=o.ref();return i.useEffect(()=>{l.value&&u.isFunction(t.setContent)&&t.setContent(l.value)},l),()=>a.default?o.createVNode(o.Teleport,{to:"body"},{default:()=>[o.createVNode("div",{ref:l},[a.default()])]}):null}}),X=s("CircleMarker",{useMapConnect:F}),Y=s("Text",{useMapConnect:F}),Z=s("ElasticMarker",{useMapConnect:F}),ee=s("Marker",{useMapConnect:h,needDom:!0}),ae=s("Polygon",{useMapConnect:h}),te=s("Polyline",{useMapConnect:h}),re=s("Circle",{useMapConnect:h}),ne=s("Rectangle",{useMapConnect:h}),oe=s("Ellipse",{useMapConnect:h}),ce=s("BezierCurve",{useMapConnect:h}),se=s("ToolBar",{useMapConnect:g}),ue=w([A.ToolBar],se),ie=s("Scale",{useMapConnect:g}),le=w([A.Scale],ie),pe=s("HawkEye",{useMapConnect:g}),de=w([A.HawkEye],pe),Me=s("MapType",{useMapConnect:g}),fe=w([A.MapType],Me),ye=s("ControlBar",{useMapConnect:g}),Ce=w([A.ControlBar],ye),me=()=>{const{mapRef:e,layerGroup:a}=m();return{addToMap:t=>{if(a){u.isArray(t)?a.addLayers(t):a.addLayer(t);return}e.value.add(t)},removeFromMap:t=>{if(a){u.isArray(t)?a.removeLayers(t):a.removeLayer(t);return}try{e.value.remove(t)}catch(c){console.error(c)}}}},y=e=>{const{addToMap:a,removeFromMap:r}=me();i.useEffect(()=>(a(e),()=>{r(e)}),[])},ve=o.defineComponent({props:{bind:{type:Boolean,default:!1},bindTime:{type:Number,default:void 0},opts$:{type:Object},show:{type:Boolean,default:!0},events:{type:Array}},setup:(e,{slots:a,expose:r})=>{const{mapRef:n}=m(),t=new window.AMap.LayerGroup;let c=!1;const p=()=>{c||(t.setMap(n.value),c=!0)},l=()=>{try{t.setMap(null)}catch(d){console.error(d)}c=!1},M=()=>t;i.useEffect(()=>()=>{l()},[]),i.useEffect(()=>{if(!u.isNumber(e.bindTime))return;const d=setTimeout(()=>{p()},e.bindTime);return()=>{d&&clearTimeout(d)}},[]);const f=u.debounce(()=>{p()},300);i.useWatch(()=>{e.bind&&f()},()=>e.bind);const C=o.toRef(e,"show");S(t,C);const T=o.toRef(e,"opts$");return b(t,T),r({getFeature:M,addToMap:p,removeFormMap:l}),R({mapRef:n,layerGroup:t}),()=>{var d;return(d=a.default)==null?void 0:d.call(a)}}}),he=o.defineComponent({props:{opts:{type:Object},itemOpts:{type:Object},data:{type:Array},show:{type:Boolean,default:!0},events:{type:Array}},setup:(e,{expose:a})=>{const{mapRef:r}=m(),n=new window.AMap.LabelsLayer(e.opts),t=()=>u.map(e.data,l=>{const M=new window.AMap.LabelMarker({...e.itemOpts,...l});return e.events&&u.forEach(e.events,f=>{M.on(f.type,f.handler,void 0,f.once)}),M}),c=()=>{n.clear();const l=t();n.add(l)};i.useEffect(()=>(u.size(e.data)>0&&c(),r.value.add(n),()=>{n.clear(),r.value.remove(n)}),[]),i.useWatch(()=>{c()},()=>e.data);const p=o.toRef(e,"show");return S(n,p),a({getFeature:()=>n}),()=>null}}),Ae=s("TileLayer",{useMapConnect:y}),we=s("TileLayer.Satellite",{useMapConnect:y,createFeatureObj:e=>new window.AMap.TileLayer.Satellite(e)}),Te=s("TileLayer.RoadNet",{useMapConnect:y,createFeatureObj:e=>new window.AMap.TileLayer.RoadNet(e)}),ge=s("TileLayer.Traffic",{useMapConnect:y,createFeatureObj:e=>new window.AMap.TileLayer.Traffic(e)}),Le=s("Buildings",{useMapConnect:y}),Se=s("MassMarks",{useMapConnect:B,createFeatureObj:e=>new window.AMap.MassMarks((e==null?void 0:e.data)||[],u.omit(e,"data"))}),be=s("TileLayer.Flexible",{useMapConnect:y,createFeatureObj:e=>new window.AMap.TileLayer.Flexible(e)}),Ee=s("ImageLayer",{useMapConnect:y}),Re=s("VideoLayer",{useMapConnect:y}),Fe=s("CanvasLayer",{useMapConnect:y}),Oe=s("CustomLayer",{useMapConnect:y,createFeatureObj:e=>new window.AMap.CustomLayer(e==null?void 0:e.canvas,u.omit(e,"canvas"))}),Pe=s("DistrictLayer.World",{useMapConnect:y,createFeatureObj:e=>new window.AMap.DistrictLayer.World(e)}),ke=s("DistrictLayer.Country",{useMapConnect:y,createFeatureObj:e=>new window.AMap.DistrictLayer.Country(e)}),Be=s("DistrictLayer.Province",{useMapConnect:y,createFeatureObj:e=>new window.AMap.DistrictLayer.Province(e)}),_e=s("HeatMap",{useMapConnect:B,createFeatureObj:e=>new window.AMap.HeatMap(null,e)}),De=w([A.HeatMap],_e),Ne=(e,a)=>{let r=!1,n=null;const[t,c]=i.useState(),p=o.ref(u.isBoolean(a.initEmit)?a.initEmit:!1),l=u.split(e,"_"),M=l[0],f=l[1],C=()=>{const v=u.get(window,M);return v?new v({...a.opts,...n==null?void 0:n.opts}):null},T=v=>v||(u.isFunction(a.params)?a.params():a.params||[]),d=()=>{if(!n)return;const v=C();if(!v||!u.isFunction(v[f]))return;const P=T(n.params);p.value=!0,v[f](...P,(E,L)=>{var _,D,N,j;c(L),(_=a.onComplete)==null||_.call(a,E,L),E==="complete"?(D=a.onSuccess)==null||D.call(a,L):E==="error"?(N=a.onFail)==null||N.call(a,L):E==="no_data"&&((j=a.onNoData)==null||j.call(a,L)),n=null,p.value=!1})};k([M],()=>{r=!0,d()});const O=(v,P)=>{n={opts:v||a.opts,params:T(P)},r&&d()};return i.useEffect(()=>{a.initEmit&&O()},[]),i.useWatch(()=>O(),a.deps||[]),{data:t,request:O,requesting:p}},je={Geocoder_getLocation:"AMap.Geocoder_getLocation",Geocoder_getAddress:"AMap.Geocoder_getAddress",Autocomplete_search:"AMap.Autocomplete_search",PlaceSearch_search:"AMap.PlaceSearch_search",PlaceSearch_searchNearBy:"AMap.PlaceSearch_searchNearBy",PlaceSearch_searchInBounds:"AMap.PlaceSearch_searchInBounds",PlaceSearch_getDetails:"AMap.PlaceSearch_getDetails",DistrictSearch_search:"AMap.DistrictSearch_search",LineSearch_search:"AMap.LineSearch_search",LineSearch_searchById:"AMap.LineSearch_searchById",StationSearch_search:"AMap.StationSearch_search",StationSearch_searchById:"AMap.StationSearch_searchById"};exports.ApiNames=je;exports.BezierCurve=ce;exports.Buildings=Le;exports.CanvasLayer=Fe;exports.Circle=re;exports.CircleMarker=X;exports.ControlBar=Ce;exports.CustomLayer=Oe;exports.DistrictLayerCountry=ke;exports.DistrictLayerProvince=Be;exports.DistrictLayerWorld=Pe;exports.ElasticMarker=Z;exports.Ellipse=oe;exports.HawkEye=de;exports.HeatMap=De;exports.ImageLayer=Ee;exports.InfoWindow=U;exports.LabelsLayer=he;exports.LayerGroup=ve;exports.Map=z;exports.MapPlugin=I;exports.MapPluginType=A;exports.MapType=fe;exports.Marker=ee;exports.MassMarks=Se;exports.OverlayGroup=Q;exports.Polygon=ae;exports.Polyline=te;exports.Rectangle=ne;exports.Scale=le;exports.Text=Y;exports.TileLayer=Ae;exports.TileLayerFlexible=be;exports.TileLayerRoadNet=Te;exports.TileLayerSatellite=we;exports.TileLayerTraffic=ge;exports.ToolBar=ue;exports.VideoLayer=Re;exports.createFeature=s;exports.createPluginFeature=w;exports.provideMap=R;exports.useFeatureOptMethods=b;exports.useMap=m;exports.useMapApi=Ne;exports.useMapConnect=F;exports.useMapConnect2=B;exports.useMapControlConnect=g;exports.useMapLayerConnect=y;exports.useMapOverlayConnect=h;exports.useMapPlugin=k;exports.useShowConnect=S;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vue-start/map",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.4",
|
|
4
4
|
"description": "amap wrapper",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"amap"
|
|
@@ -30,5 +30,5 @@
|
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@amap/amap-jsapi-loader": "^1.0.1"
|
|
32
32
|
},
|
|
33
|
-
"gitHead": "
|
|
33
|
+
"gitHead": "22878487160d4289b5858769691d7c6bf7146267"
|
|
34
34
|
}
|