Commit 8107785c authored by Mattias J Duffy's avatar Mattias J Duffy

more mapbox improvements

parent d27c70f2
Pipeline #2923 passed with stages
in 1 minute and 45 seconds
...@@ -26,7 +26,7 @@ class FacilitiesMap extends React.Component { ...@@ -26,7 +26,7 @@ class FacilitiesMap extends React.Component {
this.Map = ReactMapboxGl({ this.Map = ReactMapboxGl({
accessToken: mapboxToken, accessToken: mapboxToken,
interactive: false, interactive: interactive,
attributionControl: false attributionControl: false
}); });
const facilityLocationExists = facility && facility.facility_location && facility.facility_location.campus_region === campusRegion; const facilityLocationExists = facility && facility.facility_location && facility.facility_location.campus_region === campusRegion;
...@@ -42,21 +42,21 @@ class FacilitiesMap extends React.Component { ...@@ -42,21 +42,21 @@ class FacilitiesMap extends React.Component {
maxBounds: getMaxBounds(campusRegion), maxBounds: getMaxBounds(campusRegion),
campusRegion: campusRegion, campusRegion: campusRegion,
zoom: [17], zoom: [17],
// center: facilityLocationExists ? facility.facility_location.coordinate_location.coordinates : getCenterOfCampusRegion(campusRegion), center: facilityLocationExists ? facility.facility_location.coordinate_location.coordinates : getCenterOfCampusRegion(campusRegion),
fitBoundsOptions: {}, fitBoundsOptions: {},
facilityLocations: [], facilityLocations: [],
selectedLocation: null, selectedLocation: null,
isLoaded: false isLoaded: false
}; };
if (interactive) { // if (interactive) {
this.state.center = facilityLocationExists ? facility.facility_location.coordinate_location.coordinates : getCenterOfCampusRegion(campusRegion); // this.state.center = facilityLocationExists ? facility.facility_location.coordinate_location.coordinates : getCenterOfCampusRegion(campusRegion);
}else{ // }else{
setTimeout(() => { // setTimeout(() => {
this.setState({ // this.setState({
center: facilityLocationExists ? facility.facility_location.coordinate_location.coordinates : getCenterOfCampusRegion(campusRegion) // center: facilityLocationExists ? facility.facility_location.coordinate_location.coordinates : getCenterOfCampusRegion(campusRegion)
}); // });
}, 500); // }, 500);
} // }
} }
componentWillReceiveProps(nextProps) { componentWillReceiveProps(nextProps) {
...@@ -77,12 +77,15 @@ class FacilitiesMap extends React.Component { ...@@ -77,12 +77,15 @@ class FacilitiesMap extends React.Component {
const facilityLocationExists = facility && facility.facility_location && facility.facility_location.campus_region === campusRegion; const facilityLocationExists = facility && facility.facility_location && facility.facility_location.campus_region === campusRegion;
this.setState({ const newState = {
maxBounds: getMaxBounds(campusRegion), maxBounds: getMaxBounds(campusRegion),
campusRegion: campusRegion, campusRegion: campusRegion,
center: facilityLocationExists ? facility.facility_location.coordinate_location.coordinates : getCenterOfCampusRegion(campusRegion), center: facilityLocationExists ? facility.facility_location.coordinate_location.coordinates : getCenterOfCampusRegion(campusRegion),
zoom: [17] zoom: [17]
}); };
setTimeout(() => {
this.setState(newState);
}, 100);
}; };
generateLocationArray = (facilities) => { generateLocationArray = (facilities) => {
......
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