forked from bcgov/common-hosted-form-service
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #26 from RyanBirtch-aot/my-location-button
Geocoder
- Loading branch information
Showing
8 changed files
with
113 additions
and
13 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
components/src/components/Map/services/BCGeocoderProvider.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { OpenStreetMapProvider } from 'leaflet-geosearch'; | ||
import { EndpointArgument } from 'leaflet-geosearch/dist/providers/provider'; | ||
|
||
export class BCGeocoderProvider extends OpenStreetMapProvider { | ||
endpoint({ query, type }: EndpointArgument): string { | ||
console.log(query); | ||
return this.getUrl(import.meta.env.VITE_CHEFS_GEO_ADDRESS_APIURL, { | ||
addressString: query as string, | ||
}); | ||
} | ||
parse({ data }) { | ||
return data.features | ||
.filter(function (feature) { | ||
if (!feature.geometry.coordinates) return false; | ||
if (feature.properties.fullAddress == 'BC') return false; | ||
return true; | ||
}) | ||
.map(function (feature) { | ||
return { | ||
x: feature.geometry.coordinates[0], | ||
y: feature.geometry.coordinates[1], | ||
label: feature.properties.fullAddress, | ||
matchPrecision: feature.properties.matchPrecision, | ||
raw: feature, | ||
}; | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters