-
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 #1426 from culturecreates/develop
Develop
- Loading branch information
Showing
9 changed files
with
215 additions
and
13 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,13 +18,11 @@ jobs: | |
uses: actions/checkout@v2 | ||
- name: setup node | ||
run: npm install | ||
- name: Make envfile | ||
uses: SpicyPizza/[email protected] | ||
with: | ||
envkey_GOOGLE_MAPS_API_KEY: ${{ secrets.GOOGLE_MAPS_API_KEY }} | ||
envkey_GOOGLE_MAPS_ID: ${{ secrets.GOOGLE_MAPS_ID }} | ||
file_name: .env.staging | ||
fail_on_empty: false | ||
# Append additional environment variables to .env.staging | ||
- name: Add extra env variables | ||
run: | | ||
echo "REACT_APP_GOOGLE_MAPS_API_KEY=${{ secrets.GOOGLE_MAPS_API_KEY }}" >> .env.staging | ||
echo "REACT_APP_GOOGLE_MAPS_ID=${{ secrets.GOOGLE_MAPS_ID }}" >> .env.staging | ||
- name: build | ||
run: npm run build:staging | ||
# Upload to S3 | ||
|
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import React, { useState, useEffect } from 'react'; | ||
import { APIProvider, Map, AdvancedMarker, Pin } from '@vis.gl/react-google-maps'; | ||
|
||
const MapComponent = (props) => { | ||
const { latitude, longitude, form, fieldName, handleGeocode } = props; | ||
const [markerPosition, setMarkerPosition] = useState({ | ||
lat: latitude ?? 54.35291352856401, | ||
lng: longitude ?? -110.072423828125, | ||
}); | ||
const [center, setCenter] = useState({ | ||
lat: latitude ?? 54.35291352856401, | ||
lng: longitude ?? -110.072423828125, | ||
}); | ||
|
||
const [zoom, setZoom] = useState(20); | ||
|
||
const handleMarkerDragEnd = (event) => { | ||
const { latLng } = event; | ||
const newPosition = { | ||
lat: latLng.lat(), | ||
lng: latLng.lng(), | ||
}; | ||
setMarkerPosition(newPosition); | ||
form.setFieldsValue({ | ||
[fieldName]: `${newPosition.lat},${newPosition.lng}`, | ||
latitude: newPosition.lat, | ||
longitude: newPosition.lng, | ||
}); | ||
handleGeocode([newPosition.lat, newPosition.lng]); | ||
}; | ||
|
||
useEffect(() => { | ||
if (latitude && longitude) { | ||
setMarkerPosition({ | ||
lat: latitude, | ||
lng: longitude, | ||
}); | ||
setCenter({ | ||
lat: latitude, | ||
lng: longitude, | ||
}); | ||
if (zoom !== 20) setZoom(20); | ||
} | ||
}, [latitude, longitude]); | ||
|
||
return ( | ||
<APIProvider apiKey={process.env.REACT_APP_GOOGLE_MAPS_API_KEY}> | ||
<Map | ||
defaultZoom={5} | ||
mapId={process.env.REACT_APP_GOOGLE_MAPS_ID} | ||
style={{ | ||
height: '40vh', | ||
width: '100%', | ||
}} | ||
zoom={zoom} | ||
defaultCenter={center} | ||
center={center} | ||
onCameraChanged={(ev) => { | ||
setZoom(ev?.detail?.zoom); | ||
setCenter(ev?.detail?.center); | ||
}}> | ||
<AdvancedMarker position={markerPosition} draggable={true} onDragEnd={handleMarkerDragEnd}> | ||
<Pin /> | ||
</AdvancedMarker> | ||
</Map> | ||
</APIProvider> | ||
); | ||
}; | ||
|
||
export default MapComponent; |
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 @@ | ||
export { default } from './MapComponent'; |
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