= {
+ type: "FeatureCollection",
+ features: [
+ {
+ type: "Feature",
+ geometry: {
+ type: "Point",
+ coordinates: [0, 0],
+ },
+ properties: {},
+ },
+ ],
+ };
+
+ const mapStore = useMapStore();
+ const layerData: LayerData = {
+ layer: L.geoJSON(featureCollection, {
+ style: () => ({
+ fillColor: "test",
+ color: "test",
+ }),
+ }),
+ loaded: false,
+ visible: false,
+ };
+
+ mapStore.addMapLayer(fakeMapSlug, layerData, sampleMaintainerData);
+
+ const beforeKeyCount = Object.keys(
+ mapStore.loadedMaps[fakeMapSlug].layer,
+ ).length;
+
+ await mapStore.clearLayerData();
+
+ const afterKeyCount = Object.keys(
+ mapStore.loadedMaps[fakeMapSlug].layer,
+ ).length;
+
+ expect(beforeKeyCount).toBeGreaterThan(afterKeyCount);
+
+ expect(typeof layerData.layer.options.style).toEqual("function");
+
+ if (typeof layerData.layer.options.style == "function") {
+ expect(JSON.stringify(layerData.layer.options.style())).toEqual(
+ JSON.stringify({
+ fillColor: "test",
+ color: "test",
+ }),
+ );
+ }
+ });
+ });
});
diff --git a/src/utils/map.ts b/src/utils/map.ts
new file mode 100644
index 0000000..121dad1
--- /dev/null
+++ b/src/utils/map.ts
@@ -0,0 +1,63 @@
+import L, { LatLng } from "leaflet";
+import type { Feature } from "geojson";
+import type { GeoJSON } from "leaflet";
+
+export function createMarker(color: string, latlng: LatLng) {
+ const markerHtmlStyles = `
+ background-color: ${color};
+ width: 2rem;
+ height: 2rem;
+ display: block;
+ left: -1rem;
+ top: -1rem;
+ position: relative;
+ border-radius: 2rem 2rem 0;
+ transform: rotate(45deg);
+ border: 1px solid #FFFFFFAA`;
+
+ const markerIcon = L.divIcon({
+ className: "",
+ iconAnchor: [0, 24],
+ popupAnchor: [0, -36],
+ html: ``,
+ });
+
+ return L.marker(latlng, { icon: markerIcon });
+}
+
+export function setTooltips(
+ mapTitle: string,
+ feature: Feature,
+ layer: GeoJSON,
+) {
+ if (feature && feature.properties) {
+ const properties = feature.properties;
+
+ const tooltipString =
+ `Map: ${mapTitle}
` +
+ Object.keys(properties)
+ .filter((key) => key != "OBJECTID" && properties[key])
+ .map((key) => {
+ const propertyName = toTitleCase(key.toString()).replace(/_/g, " ");
+ let propertyValue;
+ if (
+ properties[key]?.toString().startsWith("http") ||
+ properties[key]?.toString().startsWith("tel")
+ ) {
+ propertyValue = `${properties[key]}`;
+ } else {
+ propertyValue = properties[key];
+ }
+
+ return `${propertyName}: ${propertyValue}
`;
+ })
+ .join("");
+ layer.bindPopup(tooltipString, {});
+ }
+}
+
+function toTitleCase(string: string) {
+ return string.replace(/\w\S*/g, function (txt) {
+ return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();
+ });
+}