Skip to content

Commit 286a495

Browse files
committed
added div icon option
1 parent f123857 commit 286a495

File tree

2 files changed

+28
-21
lines changed

2 files changed

+28
-21
lines changed

schema.json

+4
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,10 @@
148148
{
149149
"value": "urlCustIcon",
150150
"label": "URL"
151+
},
152+
{
153+
"value": "divIcon",
154+
"label": "DivIcon"
151155
}
152156
],
153157
"dependsOn": "customizationBoolean"

src/Component.svelte

+24-21
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,6 @@
8787
position: "bottomright",
8888
});
8989
90-
9190
// Map and marker configuration
9291
$: defaultMarkerOptions = {
9392
html:
@@ -164,9 +163,8 @@
164163
$: updateLayerGroup(showLayerControlEnabled);
165164
166165
const updateLayerGroup = (showLayerControlEnabled) => {
167-
addLayerGroup(customIconOptions)
168-
}
169-
166+
addLayerGroup(customIconOptions);
167+
};
170168
171169
const addMultipleTileLayers = (mapInstance, tileMultipleURL) => {
172170
mapTileLayers.clearLayers();
@@ -181,13 +179,11 @@
181179
}
182180
};
183181
184-
185-
186182
const addLayerGroup = (customIconOptions) => {
187183
if (!mapInstance) {
188184
return;
189185
}
190-
if(!showLayerControl){
186+
if (!showLayerControl) {
191187
return;
192188
}
193189
@@ -253,19 +249,19 @@
253249
if (!mapInstance) {
254250
return;
255251
}
256-
if (mapMasterMarkerGroup.getLayers().length) { //if custom markers
252+
if (mapMasterMarkerGroup.getLayers().length) {
253+
//if custom markers
257254
mapInstance.setZoom(0);
258255
mapInstance.fitBounds(mapMasterMarkerGroup.getBounds(), {
259256
paddingTopLeft: [0, 24],
260257
});
261-
}
262-
else if (mapMarkerGroup.getLayers().length){ //if default markers
258+
} else if (mapMarkerGroup.getLayers().length) {
259+
//if default markers
263260
mapInstance.setZoom(0);
264261
mapInstance.fitBounds(mapMarkerGroup.getBounds(), {
265262
paddingTopLeft: [0, 24],
266263
});
267-
}
268-
else {
264+
} else {
269265
mapInstance.setView(defaultCoordinates, safeZoomLevel);
270266
}
271267
};
@@ -342,7 +338,7 @@
342338
if (!validRows?.length) {
343339
return;
344340
}
345-
mapMasterMarkerGroup.clearLayers()
341+
mapMasterMarkerGroup.clearLayers();
346342
if (!initialMarkerZoomCompleted && customIconOptions) {
347343
addLayerGroup(customIconOptions);
348344
}
@@ -371,7 +367,11 @@
371367
' ri-2x" draggable="false" style="color:' +
372368
colorIcon +
373369
'"></i></div>';
374-
} else if (iconType == "colorCustIcon") {
370+
}
371+
else if (iconType == "divIcon") {
372+
mapMarkerOptions.icon = L.divIcon({html:lookup_element.value, className: 'dummy'})
373+
}
374+
else if (iconType == "colorCustIcon") {
375375
let validColor = isValidColor(lookup_element.value)
376376
? lookup_element.value
377377
: colorIcon;
@@ -390,8 +390,12 @@
390390
iconSize: [26, 26],
391391
iconAnchor: [13, 26],
392392
popupAnchor: [0, -13],
393-
});
394-
} else {
393+
}
394+
395+
);
396+
}
397+
398+
else {
395399
}
396400
} else {
397401
}
@@ -453,14 +457,15 @@
453457
},
454458
});
455459
456-
mapInstance.addLayer(L.tileLayer(tileURL, {
460+
mapInstance.addLayer(
461+
L.tileLayer(tileURL, {
457462
attribution: "&copy; " + cleanAttribution,
458463
zoom,
459-
}))
464+
})
465+
);
460466
461467
mapTileLayers.addTo(mapInstance);
462468
463-
464469
mapInstance.on("click", handleMapClick);
465470
466471
// Reset view
@@ -506,8 +511,6 @@
506511
mounted = true;
507512
initMap(tileURL, mapAttribution, safeZoomLevel);
508513
});
509-
510-
511514
</script>
512515
513516
<div class="embedded-map-wrapper map-default" use:styleable={$component.styles}>

0 commit comments

Comments
 (0)