gdmap-utils 1.1.2 → 1.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -179,7 +179,7 @@ class MarkerLayer {
|
|
|
179
179
|
*/
|
|
180
180
|
refreshOverlayLabel(
|
|
181
181
|
marker: InstanceType<typeof AMap.Marker>,
|
|
182
|
-
labelOpts
|
|
182
|
+
labelOpts: {
|
|
183
183
|
content: string;
|
|
184
184
|
direction: string;
|
|
185
185
|
offset: [number, number] | Array<number>;
|
|
@@ -189,16 +189,10 @@ class MarkerLayer {
|
|
|
189
189
|
// 如果没有找到对应的marker
|
|
190
190
|
return MapUtils.error('marker is not found');
|
|
191
191
|
}
|
|
192
|
-
if (labelOpts) {
|
|
193
|
-
marker.setLabel(labelOpts);
|
|
194
|
-
} else {
|
|
195
|
-
let labelOpts = marker.getLabel();
|
|
196
192
|
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
});
|
|
201
|
-
}
|
|
193
|
+
marker.setLabel({
|
|
194
|
+
...labelOpts,
|
|
195
|
+
});
|
|
202
196
|
}
|
|
203
197
|
}
|
|
204
198
|
|
|
@@ -249,49 +249,41 @@ class BaseMarkerLayer<
|
|
|
249
249
|
}
|
|
250
250
|
const OvlLayer = BaseMarkerLayer.layerClassMap.get(this.layerType);
|
|
251
251
|
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
this.getIconUrl,
|
|
262
|
-
this.getOverlayOpts,
|
|
263
|
-
MapUtils
|
|
264
|
-
);
|
|
265
|
-
|
|
266
|
-
const iconImageUrl = this.getIconUrl(this.overlayList[ovlDataIndex]);
|
|
252
|
+
const marker = this.rawLayerIns.findLayerOverlay(overlayId);
|
|
253
|
+
// 函数可以动态计算label,
|
|
254
|
+
const ovlOpts = OvlLayer!.convertOverlayDataToOvlOpts(
|
|
255
|
+
this.overlayList[ovlDataIndex],
|
|
256
|
+
ovlDataIndex,
|
|
257
|
+
this.getIconUrl,
|
|
258
|
+
this.getOverlayOpts,
|
|
259
|
+
MapUtils
|
|
260
|
+
);
|
|
267
261
|
|
|
268
|
-
|
|
269
|
-
let icon = ovlOpts.icon! as AMap.Icon | string;
|
|
262
|
+
const iconImageUrl = this.getIconUrl(this.overlayList[ovlDataIndex]);
|
|
270
263
|
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
} else {
|
|
274
|
-
(icon as AMap.Icon).setImage(iconImageUrl);
|
|
275
|
-
}
|
|
264
|
+
if (this.rawLayerIns instanceof MarkerLayer) {
|
|
265
|
+
let icon = ovlOpts.icon! as AMap.Icon | string;
|
|
276
266
|
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
icon
|
|
280
|
-
);
|
|
267
|
+
if (typeof icon === 'string') {
|
|
268
|
+
icon = iconImageUrl;
|
|
281
269
|
} else {
|
|
282
|
-
|
|
270
|
+
(icon as AMap.Icon).setImage(iconImageUrl);
|
|
271
|
+
}
|
|
283
272
|
|
|
284
|
-
|
|
273
|
+
(this.rawLayerIns as MarkerLayerIns).refreshOverlayIcon(
|
|
274
|
+
(marker as AMap.Marker)!,
|
|
275
|
+
icon
|
|
276
|
+
);
|
|
277
|
+
} else {
|
|
278
|
+
let icon = ovlOpts.icon! as AMap.LabelMarkerIconOptions;
|
|
285
279
|
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
);
|
|
290
|
-
}
|
|
280
|
+
icon.image = iconImageUrl;
|
|
281
|
+
|
|
282
|
+
this.rawLayerIns.refreshOverlayIcon((marker as AMap.LabelMarker)!, icon);
|
|
291
283
|
}
|
|
292
284
|
}
|
|
293
285
|
|
|
294
|
-
refreshOverlayLabel(overlayId: string | number
|
|
286
|
+
refreshOverlayLabel(overlayId: string | number) {
|
|
295
287
|
const ovlDataIndex = this.overlayList.findIndex(
|
|
296
288
|
ovl => ovl.id === overlayId
|
|
297
289
|
);
|
|
@@ -302,49 +294,32 @@ class BaseMarkerLayer<
|
|
|
302
294
|
}
|
|
303
295
|
const OvlLayer = BaseMarkerLayer.layerClassMap.get(this.layerType);
|
|
304
296
|
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
this.rawLayerIns instanceof LabelMarkerLayer
|
|
308
|
-
) {
|
|
309
|
-
// marker拿到手
|
|
310
|
-
const marker = this.rawLayerIns.findLayerOverlay(overlayId)!;
|
|
311
|
-
|
|
312
|
-
const ovDataItem = this.overlayList.find(item => item.id === overlayId);
|
|
313
|
-
// 属性值转变为boolean
|
|
314
|
-
ovDataItem!.labelShowed = labelShow;
|
|
315
|
-
|
|
316
|
-
// 函数可以动态计算label,
|
|
317
|
-
const ovlOpts = OvlLayer!.convertOverlayDataToOvlOpts(
|
|
318
|
-
this.overlayList[ovlDataIndex],
|
|
319
|
-
ovlDataIndex,
|
|
320
|
-
this.getIconUrl,
|
|
321
|
-
this.getOverlayOpts,
|
|
322
|
-
MapUtils
|
|
323
|
-
);
|
|
297
|
+
// marker拿到手
|
|
298
|
+
const marker = this.rawLayerIns.findLayerOverlay(overlayId)!;
|
|
324
299
|
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
marker as AMap.LabelMarker,
|
|
342
|
-
ovlOpts.text as AMap.LabelMarkerTextOptions
|
|
343
|
-
);
|
|
344
|
-
} else {
|
|
345
|
-
this.rawLayerIns.refreshOverlayLabel(marker as AMap.LabelMarker);
|
|
300
|
+
// 函数可以动态计算label,
|
|
301
|
+
const ovlOpts = OvlLayer!.convertOverlayDataToOvlOpts(
|
|
302
|
+
this.overlayList[ovlDataIndex],
|
|
303
|
+
ovlDataIndex,
|
|
304
|
+
this.getIconUrl,
|
|
305
|
+
this.getOverlayOpts,
|
|
306
|
+
MapUtils
|
|
307
|
+
);
|
|
308
|
+
|
|
309
|
+
if (this.rawLayerIns instanceof MarkerLayer) {
|
|
310
|
+
this.rawLayerIns.refreshOverlayLabel(
|
|
311
|
+
marker as AMap.Marker,
|
|
312
|
+
(ovlOpts as AMap.MarkerOptions).label as {
|
|
313
|
+
content: string;
|
|
314
|
+
direction: string;
|
|
315
|
+
offset: [number, number] | Array<number>;
|
|
346
316
|
}
|
|
347
|
-
|
|
317
|
+
);
|
|
318
|
+
} else {
|
|
319
|
+
this.rawLayerIns.refreshOverlayLabel(
|
|
320
|
+
marker as AMap.LabelMarker,
|
|
321
|
+
ovlOpts.text as AMap.LabelMarkerTextOptions
|
|
322
|
+
);
|
|
348
323
|
}
|
|
349
324
|
}
|
|
350
325
|
|