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 Bug #22

Merged
merged 8 commits into from
Sep 17, 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
22 changes: 11 additions & 11 deletions components/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 8 additions & 7 deletions components/src/components/Map/services/MapService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ 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 READ_ONLY_CLASS = 'formio-read-only';
const CUSTOM_MARKER_PATH = 'https://unpkg.com/[email protected]/dist/images/';

L.Icon.Default.imagePath = CUSTOM_MARKER_PATH;
Expand All @@ -36,8 +37,8 @@ class MapService {

if (options.mapContainer) {
const { map, drawnItems } = this.initializeMap(options);

this.map = map;
// this.map = map;
this.drawnItems = drawnItems;

map.invalidateSize();
Expand All @@ -63,7 +64,6 @@ class MapService {
map.on(L.Draw.Event.EDITSTOP, (e) => {
options.onDrawnItemsChange(drawnItems.getLayers());
});

map.on('resize', () => {
map.invalidateSize();
});
Expand All @@ -84,10 +84,12 @@ class MapService {
if (drawOptions.rectangle) {
drawOptions.rectangle.showArea = false;
}
const map = L.map(mapContainer).setView(
center,
defaultZoom || DEFAULT_MAP_ZOOM
);
//Check to see if there is the formio read only class in the current page, and set notEditable to true if the map is inside a read-only page

//if the user chooses it to be read-only, and the
const map = L.map(mapContainer, {
zoomAnimation: viewMode,
}).setView(center, defaultZoom || DEFAULT_MAP_ZOOM);
L.tileLayer(DEFAULT_MAP_LAYER_URL, {
attribution: DEFAULT_LAYER_ATTRIBUTION,
}).addTo(map);
Expand Down Expand Up @@ -126,7 +128,6 @@ class MapService {
}
return { map, drawnItems };
}

bindPopupToLayer(layer) {
if (layer instanceof L.Marker) {
layer
Expand Down
Loading