-
Notifications
You must be signed in to change notification settings - Fork 1
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 #273 from performant-software/feature/cdc121_geoco…
…ding CDC #121 - Geocoding
- Loading branch information
Showing
17 changed files
with
207 additions
and
44 deletions.
There are no files selected for viewing
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
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "@performant-software/geospatial", | ||
"version": "2.1.1", | ||
"version": "2.1.2", | ||
"description": "A package of components for all things map-related.", | ||
"license": "MIT", | ||
"main": "./dist/index.cjs.js", | ||
|
@@ -19,6 +19,7 @@ | |
}, | ||
"dependencies": { | ||
"@mapbox/mapbox-gl-draw": "^1.4.3", | ||
"@maptiler/geocoding-control": "^1.2.2", | ||
"@turf/turf": "^6.5.0", | ||
"mapbox-gl": "npm:[email protected]", | ||
"maplibre-gl": "^3.6.2", | ||
|
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,33 @@ | ||
// @flow | ||
|
||
import { GeocodingControl as MapTilerGeocoding } from '@maptiler/geocoding-control/maplibregl'; | ||
import maplibregl from 'maplibre-gl'; | ||
import { forwardRef, useImperativeHandle } from 'react'; | ||
import { useControl, type ControlPosition } from 'react-map-gl'; | ||
|
||
type Props = { | ||
apiKey: string, | ||
onSelection: () => void, | ||
position?: ControlPosition | ||
}; | ||
|
||
const GeocodingControl = forwardRef(({ position, ...props }: Props, ref) => { | ||
/** | ||
* Creates the drawer ref using MapboxDraw. | ||
*/ | ||
const geocodingRef = useControl(() => { | ||
const control = new MapTilerGeocoding({ ...props, maplibregl }); | ||
control.addEventListener('pick', props.onSelection); | ||
|
||
return control; | ||
}, { position }); | ||
|
||
/** | ||
* Exposes the ref for the MapboxDraw object. | ||
*/ | ||
useImperativeHandle(ref, () => geocodingRef, [geocodingRef]); | ||
|
||
return null; | ||
}); | ||
|
||
export default GeocodingControl; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
@import '@mapbox/mapbox-gl-draw/dist/mapbox-gl-draw.css'; | ||
@import 'maplibre-gl/dist/maplibre-gl.css'; | ||
@import '@maptiler/geocoding-control/style.css'; | ||
@import 'maplibre-gl/dist/maplibre-gl.css'; |
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
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
Oops, something went wrong.