-
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.
Can view map with directions; need to implement routes for more locat…
…ions and make it property manager specific
- Loading branch information
1 parent
fe1da69
commit 6dd24d5
Showing
8 changed files
with
1,472 additions
and
25 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import React, { useEffect } from 'react'; | ||
import mapboxgl from 'mapbox-gl'; | ||
import MapboxDirections from '@mapbox/mapbox-gl-directions/dist/mapbox-gl-directions'; | ||
import '@mapbox/mapbox-gl-directions/dist/mapbox-gl-directions.css'; | ||
import 'mapbox-gl/dist/mapbox-gl.css'; | ||
|
||
const ACCESS_TOKEN = "pk.eyJ1IjoicGRldjAwMTAiLCJhIjoiY2x6ajVxNG1nMG4xOTJucTE1MHY4bDF2bCJ9.HfHy4wIk1KMg658ISOLoRQ" | ||
|
||
const MapComponent = ({ origin, destination }) => { | ||
useEffect(() => { | ||
const map = new mapboxgl.Map({ | ||
accessToken: ACCESS_TOKEN, | ||
container: 'map', | ||
style: "mapbox://styles/mapbox/streets-v12", | ||
center: [-79.4512, 43.6568], | ||
zoom: 13, | ||
}); | ||
|
||
const directions = new MapboxDirections({ | ||
accessToken: ACCESS_TOKEN | ||
}); | ||
|
||
map.addControl(directions, 'top-left'); | ||
|
||
if (origin) { | ||
directions.setOrigin(origin); | ||
} | ||
|
||
if (destination) { | ||
directions.setDestination(destination); | ||
} | ||
|
||
// Cleanup on unmount | ||
return () => map.remove(); | ||
}, [origin, destination]); | ||
|
||
return <div id="map" style={{ width: 600, height: 400 }} />; | ||
}; | ||
|
||
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
Oops, something went wrong.