@@ -44,7 +44,7 @@ const defaultMapOptions: MapOptions = {
44
44
45
45
export default defineComponent ({
46
46
47
- emits: [" place" , " update:modelValue" , " error" ],
47
+ emits: [" place" , " update:modelValue" , " error" , " mapReady " ],
48
48
49
49
props: {
50
50
activatorColor: {
@@ -122,6 +122,11 @@ export default defineComponent({
122
122
geoJsonFiles: {
123
123
type: Array as PropType <GeoJSONProp []>,
124
124
default : () => []
125
+ },
126
+
127
+ layers: {
128
+ type: Array as PropType <L .Layer []>,
129
+ default : () => []
125
130
}
126
131
},
127
132
@@ -264,6 +269,7 @@ export default defineComponent({
264
269
265
270
map .attributionControl .setPrefix (' <a href="https://leafletjs.com" title="A JavaScript library for interactive maps" target="_blank" rel="noopener noreferrer" >Leaflet</a>' );
266
271
272
+ this .layers .forEach ((layer ) => layer .addTo (map ));
267
273
// show the geojson files
268
274
this .geoJsonFiles .forEach ((geojsonrecord ) => {
269
275
const url = geojsonrecord .url ;
@@ -300,12 +306,26 @@ export default defineComponent({
300
306
});
301
307
302
308
this .map = map ;
309
+
310
+ this .$emit (' mapReady' );
303
311
},
304
312
305
313
updateValue(value : LocationDeg ) {
306
314
this .$emit (' update:modelValue' , value );
307
315
},
308
316
317
+ addLayerToMap(leafletObject : L .Layer ) {
318
+ if (this .map ) {
319
+ leafletObject .addTo (this .map as Map );
320
+ }
321
+ },
322
+
323
+ removeLayerFromMap(leafletObject : L .Layer ) {
324
+ if (this .map ) {
325
+ leafletObject .removeFrom (this .map as Map );
326
+ }
327
+ },
328
+
309
329
updateCircle() {
310
330
if (this .map ) {
311
331
this .selectedCircle ?.remove ();
0 commit comments