generated from bcgov/quickstart-openshift
-
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.
- Loading branch information
Showing
8 changed files
with
108 additions
and
56 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,81 @@ | ||
import 'leaflet/dist/leaflet.css' // Import Leaflet CSS | ||
import L from 'leaflet' | ||
import { MapContainer, Marker, Popup, TileLayer } from 'react-leaflet' | ||
import { useEffect, useState } from 'react' | ||
import apiService from '@/service/api-service' | ||
import pin from '../assets/marker-icon-2x-red.png' | ||
import shadow from '../assets/marker-shadow.png' | ||
/** | ||
* Renders a map with a marker at the supplied location | ||
* | ||
*/ | ||
const LeafletMapWithPoint = () => { | ||
const [data, setData] = useState([]) | ||
const [dataFetched, setDataFetched] = useState(false) | ||
|
||
useEffect(() => { | ||
apiService | ||
.getAxiosInstance() | ||
.get('/omrr') | ||
.then((response) => { | ||
// iterate over the response data and set the state key is lat and long and details is rest of the data | ||
const points = response?.data | ||
?.filter((item) => item.Latitude && item.Longitude) | ||
?.map((item) => { | ||
return { | ||
position: [item?.Latitude, item?.Longitude], | ||
details: item, | ||
} | ||
}) | ||
setData(points) | ||
console.log(points) | ||
setDataFetched(true) | ||
}) | ||
.catch((error) => { | ||
console.error(error) | ||
}) | ||
}, []) | ||
// Set the position of the marker for center of BC | ||
const position = [53.7267, -127.6476] | ||
// define points | ||
const samplePoints = [ | ||
{ position: [60, -140], details: 'BC' }, | ||
{ position: [49.019, -122.455], details: 'BC' }, | ||
{ position: [51.7267, -128.6476], details: 'BC' }, | ||
] | ||
//define red icon | ||
const redIcon = new L.Icon({ | ||
//read from assets | ||
iconUrl: pin, | ||
shadowUrl: shadow, | ||
iconSize: [25, 41], | ||
iconAnchor: [12, 41], | ||
popupAnchor: [1, -34], | ||
shadowSize: [41, 41], | ||
}) | ||
|
||
return ( | ||
<> | ||
<MapContainer | ||
id="map" | ||
center={position} | ||
zoom={6} | ||
style={{ height: '60em', width: '100%', marginLeft: '4em' }} | ||
className="map-container" | ||
> | ||
<TileLayer | ||
attribution='© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors' | ||
url="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png" | ||
/> | ||
{dataFetched && | ||
data.map((item, index) => ( | ||
<Marker key={index} position={item.position} icon={redIcon}> | ||
<Popup>{item.details['Authorization Number']}</Popup> | ||
</Marker> | ||
))} | ||
</MapContainer> | ||
</> | ||
) | ||
} | ||
|
||
export default LeafletMapWithPoint |
This file was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,33 @@ | ||
@font-face { | ||
font-family: 'BCSans'; | ||
font-style: normal; | ||
src: url('../node_modules/@bcgov/bc-sans/fonts/BCSans-Regular.woff') | ||
format('woff'); | ||
font-family: 'BCSans'; | ||
font-style: normal; | ||
src: url('../node_modules/@bcgov/bc-sans/fonts/BCSans-Regular.woff') format('woff'); | ||
} | ||
|
||
@font-face { | ||
font-family: 'BCSans-Italic'; | ||
font-style: italic; | ||
src: url('../node_modules/@bcgov/bc-sans/fonts/BCSans-Italic.woff') | ||
format('woff'); | ||
font-family: 'BCSans-Italic'; | ||
font-style: italic; | ||
src: url('../node_modules/@bcgov/bc-sans/fonts/BCSans-Italic.woff') format('woff'); | ||
} | ||
|
||
@font-face { | ||
font-family: 'BCSans-Bold'; | ||
font-weight: 700; | ||
src: url('../node_modules/@bcgov/bc-sans/fonts/BCSans-Bold.woff') | ||
format('woff'); | ||
font-family: 'BCSans-Bold'; | ||
font-weight: 700; | ||
src: url('../node_modules/@bcgov/bc-sans/fonts/BCSans-Bold.woff') format('woff'); | ||
} | ||
|
||
@font-face { | ||
font-family: 'BCSans-BoldItalic'; | ||
font-style: italic; | ||
font-weight: 700; | ||
src: url('../node_modules/@bcgov/bc-sans/fonts/BCSans-BoldItalic.woff') | ||
format('woff'); | ||
font-family: 'BCSans-BoldItalic'; | ||
font-style: italic; | ||
font-weight: 700; | ||
src: url('../node_modules/@bcgov/bc-sans/fonts/BCSans-BoldItalic.woff') format('woff'); | ||
} | ||
|
||
.MuiDrawer-paperAnchorLeft { | ||
margin-top: 4.2em !important; | ||
margin-top: 4.2em !important; | ||
} | ||
|
||
.map-container { | ||
border-radius: 4px; | ||
z-index: 1; | ||
} |
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