diff --git a/components/src/components/Map/Common/marker-icon.png b/components/src/components/Map/Common/marker-icon.png new file mode 100644 index 000000000..950edf246 Binary files /dev/null and b/components/src/components/Map/Common/marker-icon.png differ diff --git a/components/src/components/Map/services/MapService.ts b/components/src/components/Map/services/MapService.ts index 06b110b23..55aaca367 100644 --- a/components/src/components/Map/services/MapService.ts +++ b/components/src/components/Map/services/MapService.ts @@ -9,6 +9,8 @@ const DEFAULT_LAYER_ATTRIBUTION = const DEFAULT_MAP_ZOOM = 5; const DECIMALS_LATLNG = 5; // the number of decimals of latitude and longitude to be displayed in the marker popup const COMPONENT_EDIT_CLASS = 'component-edit-tabs'; +const CUSTOM_MARKER_PATH = + 'https://unpkg.com/leaflet@1.9.4/dist/images/marker-icon.png'; interface MapServiceOptions { mapContainer: HTMLElement; @@ -43,6 +45,9 @@ class MapService { .setContent('
Only one marker for submission
') .openOn(map); } else { + if (layer.type === 'marker') { + layer.setIcon(this.customMarker); + } drawnItems.addLayer(layer); } this.bindPopupToLayer(layer); @@ -68,7 +73,6 @@ class MapService { viewMode, } = options; - if (drawOptions.rectangle) { drawOptions.rectangle.showArea = false; } @@ -81,6 +85,8 @@ class MapService { }).addTo(map); // Initialize Draw Layer let drawnItems = new L.FeatureGroup(); + //({ iconUrl: '../common/marker-icon.png/' }); + map.addLayer(drawnItems); // Add Drawing Controllers @@ -153,7 +159,7 @@ class MapService { items.forEach((item) => { let layer; if (item.type === 'marker') { - layer = L.marker(item.coordinates); + layer = L.marker(item.coordinates).setIcon(this.customMarker); //layer.setIcon(this.customMarker); } else if (item.type === 'rectangle') { layer = L.rectangle(item.bounds); } else if (item.type === 'circle') { @@ -180,5 +186,10 @@ class MapService { } return false; } + customMarker = L.icon({ + iconUrl: CUSTOM_MARKER_PATH, + iconSize: [25, 41], + iconAnchor: [12, 41], + }); } export default MapService;