Commit fb893ca0 authored by Mattias J Duffy's avatar Mattias J Duffy

more map performance improvements

parent c650e27f
Pipeline #2897 passed with stages
in 1 minute and 42 seconds
...@@ -42,12 +42,17 @@ class FacilitiesMap extends React.Component { ...@@ -42,12 +42,17 @@ class FacilitiesMap extends React.Component {
this.state = { this.state = {
maxBounds: getMaxBounds(campusRegion), maxBounds: getMaxBounds(campusRegion),
campusRegion: campusRegion, campusRegion: campusRegion,
center: facilityLocationExists ? facility.facility_location.coordinate_location.coordinates : getCenterOfCampusRegion(campusRegion), zoom: [17],
zoom: facilityLocationExists ? [17] : [0],
fitBoundsOptions: {}, fitBoundsOptions: {},
facilityLocations: [], facilityLocations: [],
selectedLocation: null selectedLocation: null,
isLoaded: false
}; };
setTimeout(() => {
this.setState({
center: facilityLocationExists ? facility.facility_location.coordinate_location.coordinates : getCenterOfCampusRegion(campusRegion)
});
}, 500);
} }
componentWillReceiveProps(nextProps) { componentWillReceiveProps(nextProps) {
...@@ -72,7 +77,7 @@ class FacilitiesMap extends React.Component { ...@@ -72,7 +77,7 @@ class FacilitiesMap extends React.Component {
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: facilityLocationExists ? [17] : [0] zoom: [17]
}); });
}; };
...@@ -108,14 +113,13 @@ class FacilitiesMap extends React.Component { ...@@ -108,14 +113,13 @@ class FacilitiesMap extends React.Component {
this.setState({ this.setState({
selectedLocation: oldSelectedLocation !== location ? location : null, selectedLocation: oldSelectedLocation !== location ? location : null,
center: location && location.location.coordinate_location.coordinates, center: location && location.location.coordinate_location.coordinates,
zoom: oldSelectedLocation !== location ? [17] : oldZoom zoom: [17]
}); });
} }
render() { render() {
const {interactive = true} = this.props; const {interactive = true} = this.props;
const {maxBounds, fitBoundsOptions, facilityLocations, selectedLocation, center, zoom} = this.state; const {maxBounds, fitBoundsOptions, facilityLocations, selectedLocation, center, zoom} = this.state;
return ( return (
<this.Map <this.Map
onStyleLoad={(map) => { onStyleLoad={(map) => {
...@@ -130,7 +134,7 @@ class FacilitiesMap extends React.Component { ...@@ -130,7 +134,7 @@ class FacilitiesMap extends React.Component {
}} }}
animationOptions={{ animationOptions={{
animate: true, animate: true,
duration: 1500 duration: 1250
}} }}
style="mapbox://styles/mduffy8/cjbcdxi3v73hp2spiyhxbkjde" style="mapbox://styles/mduffy8/cjbcdxi3v73hp2spiyhxbkjde"
movingMethod="easeTo" movingMethod="easeTo"
......
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