Commit 25886cac authored by Mattias J Duffy's avatar Mattias J Duffy
Browse files

small fixes

added smoother transition to map open
you wont be prompted for location on page load
parent 3171d26f
Pipeline #1774 passed with stage
in 1 minute and 40 seconds
......@@ -50,20 +50,21 @@ class FacilitiesMap extends React.Component {
}
componentWillMount = () =>{
if ("geolocation" in navigator) {
const t1 = performance.now();
navigator.geolocation.getCurrentPosition((position) =>{
const newCoords = position.coords
this.setState({
position:position.coords,
positionReady:true,
})
const t2 = performance.now()
console.log("took "+(t2-t1)/1000 + " seconds to load your current position")
})
} else {
console.log('geolocation is not availabe for your computer')
}
// if ("geolocation" in navigator) {
// const t1 = performance.now();
// navigator.geolocation.getCurrentPosition((position) =>{
// const newCoords = position.coords
// this.setState({
// position:newCoords,
// positionReady:true,
// })
// const t2 = performance.now()
// console.log("took "+(t2-t1)/1000 + " seconds to load your current position")
// })
// } else {
// console.log('geolocation is not availabe for your computer')
// }
}
// componentWillReceiveProps = (nextProps) =>{
......@@ -97,7 +98,7 @@ class FacilitiesMap extends React.Component {
const {position,positionReady,fitBounds,maxBounds,mappedRoute,fitBoundsOptions} = this.state
console.log(fitBounds)
return(
<div className={classes.mapContainer} style={{'height': isMapOpen ? '400px' : 0}}>
<div className={classes.mapContainer} style={{'transform': isMapOpen ? 'translateY(0px)' : 'translateY(436px)'}}>
<Map
onStyleLoad={(map,e)=>{
map.addControl(new mapboxgl.GeolocateControl({
......@@ -110,8 +111,9 @@ class FacilitiesMap extends React.Component {
style="mapbox://styles/mapbox/streets-v9"
movingMethod={'easeTo'}
containerStyle={{
height: "100%",
width: "100%"
height: "400px",
width: "400px"
}}
fitBounds={fitBounds}
fitBoundsOptions={fitBoundsOptions}
......
......@@ -7,6 +7,7 @@ import TextwTitle from '../components/TextwTitle'
import FacilitiesMap from '../components/FacilitiesMap'
import classNames from 'classnames';
import Button from 'material-ui/Button';
import { toggleSidebar } from '../actions/ui';
const Sidebar = ({facility, isSidebarOpen, isSidebarMapOpen, toggleSidebarMap, facilities}) => {
......@@ -22,7 +23,16 @@ const Sidebar = ({facility, isSidebarOpen, isSidebarMapOpen, toggleSidebarMap, f
return name;
};
const handleSidebarMapToggle = () =>{
if (navigator.geolocation) {
console.log('Geolocation is supported!');
// navigator.geolocation.getCurrentPosition(()=>{})
}
else {
console.log('Geolocation is not supported for this Browser/OS.');
}
toggleSidebarMap()
}
return (
<Paper
className={classNames(['sidebar-root', (!isSidebarOpen && 'sidebar-open'), (isSidebarOpen && 'sidebar-closed')])}>
......@@ -48,7 +58,7 @@ const Sidebar = ({facility, isSidebarOpen, isSidebarMapOpen, toggleSidebarMap, f
<FacilitiesMap isMapOpen={isSidebarMapOpen} facilities={facilities} facility={facility}/>
<Button className={'sidebar-toggle-map-btn'}
onClick={toggleSidebarMap}>{isSidebarMapOpen ? 'Close Map' : 'Open Map'}</Button>
onClick={handleSidebarMapToggle}>{isSidebarMapOpen ? 'Close Map' : 'Open Map'}</Button>
</div>
</Paper>
)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment