Skip to content

Commit

Permalink
Merge pull request #14 from RyanBirtch-aot/marker-image-bug
Browse files Browse the repository at this point in the history
Marker Zoom Fix
  • Loading branch information
abhilash-aot authored Aug 1, 2024
2 parents b5afae5 + 174dfb1 commit 47b8da9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 13 additions & 1 deletion components/src/components/Map/services/MapService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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/[email protected]/dist/images/marker-icon.png';

interface MapServiceOptions {
mapContainer: HTMLElement;
Expand Down Expand Up @@ -47,6 +49,9 @@ class MapService {
.setContent('<p>Only one marker for submission</p>')
.openOn(map);
} else {
if (layer.type === 'marker') {
layer.setIcon(this.customMarker);
}
drawnItems.addLayer(layer);
}
this.bindPopupToLayer(layer);
Expand Down Expand Up @@ -90,6 +95,8 @@ class MapService {

// Initialize Draw Layer
let drawnItems = new L.FeatureGroup();
//({ iconUrl: '../common/marker-icon.png/' });

map.addLayer(drawnItems);

// Add Drawing Controllers
Expand Down Expand Up @@ -165,7 +172,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') {
Expand Down Expand Up @@ -193,5 +200,10 @@ class MapService {
}
return false;
}
customMarker = L.icon({
iconUrl: CUSTOM_MARKER_PATH,
iconSize: [25, 41],
iconAnchor: [12, 41],
});
}
export default MapService;

0 comments on commit 47b8da9

Please sign in to comment.