Skip to content

Commit

Permalink
Merge pull request #12 from RyanBirtch-aot/default-value-bug
Browse files Browse the repository at this point in the history
Default Value Delete/Edit Bug
  • Loading branch information
abhilash-aot authored Jul 25, 2024
2 parents 3402359 + f824346 commit 01cb3d5
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
6 changes: 5 additions & 1 deletion components/src/components/Map/Component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,10 @@ export default class Component extends (FieldComponent as any) {
drawOptions[this.component.markerType] = true; // set marker type from user choice
}

const { numPoints, defaultZoom, readOnlyMap, center } = this.component;
const { numPoints, defaultZoom, readOnlyMap, center, defaultValue } =
this.component;


const { readOnly: viewMode } = this.options;

let initialCenter;
Expand All @@ -88,6 +91,7 @@ export default class Component extends (FieldComponent as any) {
numPoints,
defaultZoom,
readOnlyMap,
defaultValue,
onDrawnItemsChange: this.saveDrawnItems.bind(this),
viewMode,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export default {
numPoints: 1,
tableView: false,
markerType: 'marker',
defaultZoom: 13,
defaultZoom: 5,
readOnlyMap: false,
description:
'Please select the desired default center using a single marker',
Expand Down
10 changes: 8 additions & 2 deletions components/src/components/Map/services/MapService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const DEFAULT_MAP_LAYER_URL =
'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png';
const DEFAULT_LAYER_ATTRIBUTION =
'&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors';
const DEFAULT_MAP_ZOOM = 13;
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';

Expand Down Expand Up @@ -48,6 +48,12 @@ class MapService {
this.bindPopupToLayer(layer);
options.onDrawnItemsChange(drawnItems.getLayers());
});
map.on(L.Draw.Event.DELETED, (e) => {
options.onDrawnItemsChange(drawnItems.getLayers());
});
map.on(L.Draw.Event.EDITED, (e) => {
options.onDrawnItemsChange(drawnItems.getLayers());
});
}
}

Expand Down Expand Up @@ -94,12 +100,12 @@ class MapService {
document.getElementsByClassName(COMPONENT_EDIT_CLASS);
if (form) {
if (form[0]?.classList.contains('formbuilder')) {
map.invalidateSize();
map.dragging.disable();
map.scrollWheelZoom.disable();
if (this.hasChildNode(componentEditNode[0], mapContainer)) {
map.dragging.enable();
map.scrollWheelZoom.enable();
map.invalidateSize(true);
}
}
}
Expand Down

0 comments on commit 01cb3d5

Please sign in to comment.