Skip to content

Commit

Permalink
Adding form and location popups
Browse files Browse the repository at this point in the history
  • Loading branch information
RyanBirtch-aot committed Oct 15, 2024
1 parent 47d32a5 commit 04a7d2f
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 18 deletions.
2 changes: 2 additions & 0 deletions components/src/components/Map/Component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ export default class Component extends (FieldComponent as any) {
center,
defaultValue,
myLocation,
bcGeocoder,
} = this.component;

const { readOnly: viewMode } = this.options;
Expand All @@ -114,6 +115,7 @@ export default class Component extends (FieldComponent as any) {
onDrawnItemsChange: this.saveDrawnItems.bind(this),
viewMode,
myLocation,
bcGeocoder,
});

// Load existing data if available
Expand Down
9 changes: 9 additions & 0 deletions components/src/components/Map/editForm/Component.edit.data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,5 +106,14 @@ export default {
input: true,
defaultValue: true,
},
{
label: 'Enable BC Address Autocomplete',
description:
'This allows for the user to enter an address and have results appear in a dropdown. The user can then select the result which fits best and have the map center on that location',
key: 'bcGeocoder',
type: 'simplecheckboxadvanced',
input: true,
defaultValue: true,
},
],
};
34 changes: 16 additions & 18 deletions components/src/components/Map/services/MapService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ interface MapServiceOptions {
onDrawnItemsChange: (items: any) => void; // Support both single and multiple items
viewMode?: boolean;
myLocation?: boolean;
geocoder: any;
bcGeocoder: boolean;
}

class MapService {
Expand Down Expand Up @@ -86,6 +86,7 @@ class MapService {
readOnlyMap,
viewMode,
myLocation,
bcGeocoder,
} = options;

if (drawOptions.rectangle) {
Expand Down Expand Up @@ -150,23 +151,20 @@ class MapService {
myLocationControl.addTo(map);
}

//Geocoder Control
// const geoControl = new GeoSearch.GeoSearchControl({

// })
const geocoderControl = new (GeoSearch.GeoSearchControl as any)({
provider: new BCGeocoderProvider(),
style: 'bar',
position: 'bottomleft',
});

// const geocoderControl = new (GeoSearch.GeoSearchControl as any)({
// provider: new GeoSearch.OpenStreetMapProvider(),
// style: 'bar',
// position: 'bottomleft',
// });

map.addControl(geocoderControl);
if (bcGeocoder) {
const geocoderControl = new (GeoSearch.GeoSearchControl as any)({
provider: new BCGeocoderProvider(),
style: 'bar',
position: 'bottomleft',
});
map.addControl(geocoderControl);
map.on('geosearch/showlocation', (e) => {
L.popup()
.setLatLng([(e as any).location.y, (e as any).location.x])
.setContent(`${(e as any).location.label}`)
.openOn(map);
});
}

// Add Drawing Controllers
if (!readOnlyMap) {
Expand Down

0 comments on commit 04a7d2f

Please sign in to comment.