Skip to content

Commit

Permalink
Added multiple marker type options, default to add input map
Browse files Browse the repository at this point in the history
  • Loading branch information
RyanBirtch-aot committed Sep 26, 2024
1 parent 518b568 commit 03d20e4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
10 changes: 8 additions & 2 deletions components/src/components/Map/Component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export default class Component extends (FieldComponent as any) {
loadMap() {
const mapContainer = document.getElementById(`map-${this.componentID}`);
const form = document.getElementsByClassName('formio');

const drawOptions = {
marker: false,
circlemarker: false,
Expand All @@ -63,13 +64,18 @@ export default class Component extends (FieldComponent as any) {
circle: false,
rectangle: null,
};
// set marker type from user choice
if (this.component.markerType) {
for (const [key, value] of Object.entries(this.component.markerType)) {
drawOptions[key] = value;
}
}

// Set drawing options based on markerType
if (this.component.markerType === 'rectangle') {
if (this.component?.markerType?.rectangle) {
drawOptions.rectangle = { showArea: false }; // fixes a bug in Leaflet.Draw
} else {
drawOptions.rectangle = false;
drawOptions[this.component.markerType] = true; // set marker type from user choice
}

const {
Expand Down
9 changes: 5 additions & 4 deletions components/src/components/Map/editForm/Component.edit.data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export default {
label: 'Default Center',
numPoints: 1,
tableView: false,
markerType: 'marker',
markerType: { marker: true },
defaultZoom: 5,
allowSubmissions: true,
description:
Expand Down Expand Up @@ -81,7 +81,7 @@ export default {
],
defaultValue: 'marker',
key: 'markerType',
type: 'simpleradios',
type: 'simplecheckboxes',
input: true,
},
{
Expand All @@ -92,12 +92,13 @@ export default {
input: true,
},
{
label: 'Submitter "My Location" button',
label: 'Enable Submitter "My Location" button',
description:
'This allows for the user to center the map on their location.',
key: 'myLocation',
type: 'simplecheckbox',
type: 'simplecheckboxadvanced',
input: true,
defaultValue: true,
},
],
};

0 comments on commit 03d20e4

Please sign in to comment.