Skip to content

Commit

Permalink
Merge pull request #9 from RyanBirtch-aot/settings-default-center
Browse files Browse the repository at this point in the history
Settings default center
  • Loading branch information
RyanBirtch-aot authored Jul 8, 2024
2 parents c260fe2 + f82e707 commit a1c2da1
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
14 changes: 11 additions & 3 deletions components/src/components/Map/Component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ import MapService from './services/MapService';
import baseEditForm from './Component.form';
import * as L from 'leaflet';

const CENTER: [number, number] = [48.41939025932759, -123.37029576301576]; // Ensure CENTER is a tuple with exactly two elements
const DEFAULT_CENTER: [number, number] = [
48.41939025932759, -123.37029576301576,
]; // Ensure CENTER is a tuple with exactly two elements

export default class Component extends (FieldComponent as any) {
static schema(...extend) {
Expand Down Expand Up @@ -69,11 +71,17 @@ export default class Component extends (FieldComponent as any) {
drawOptions[this.component.markerType] = true; // set marker type from user choice
}

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

let parsedCenter;
if (center) {
parsedCenter = JSON.parse(center).latlng;
}

this.mapService = new MapService({
mapContainer,
drawOptions,
center: CENTER,
center: center ? parsedCenter : DEFAULT_CENTER,
form,
numPoints,
defaultZoom,
Expand Down
13 changes: 13 additions & 0 deletions components/src/components/Map/editForm/Component.edit.data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,19 @@ export default {
type: 'simplenumber',
input: true,
},
{
key: 'center',
type: 'map',
input: true,
label: 'Default Center',
numPoints: 1,
tableView: false,
markerType: 'marker',
defaultZoom: 13,
readOnlyMap: false,
description:
'Please select the desired default center using a single marker',
},
{
label: 'Read Only Map',
description:
Expand Down

0 comments on commit a1c2da1

Please sign in to comment.