Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Marker Zoom Fix #14

Merged
merged 4 commits into from
Aug 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 13 additions & 2 deletions 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 @@ -43,6 +45,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 All @@ -68,7 +73,6 @@ class MapService {
viewMode,
} = options;


if (drawOptions.rectangle) {
drawOptions.rectangle.showArea = false;
}
Expand All @@ -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

Expand Down Expand Up @@ -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') {
Expand All @@ -180,5 +186,10 @@ class MapService {
}
return false;
}
customMarker = L.icon({
iconUrl: CUSTOM_MARKER_PATH,
iconSize: [25, 41],
iconAnchor: [12, 41],
});
}
export default MapService;
Loading