Commit 1227c0ff authored by Florent Chehab's avatar Florent Chehab

Cleaned UnivMap

parent 505d85ba
Pipeline #35568 passed with stages
in 6 minutes and 29 seconds
import React from "react"; import React, { Component } from "react";
import CustomComponentForAPI from "../CustomComponentForAPI";
import { connect } from "react-redux"; import { connect } from "react-redux";
import { Map, TileLayer, LayersControl, LayerGroup } from "react-leaflet"; import PropTypes from "prop-types";
import { Map, TileLayer, LayersControl, LayerGroup } from "react-leaflet";
import UnivMarkers from "./UnivMakers"; import UnivMarkers from "./UnivMakers";
import { saveMainMapStatus } from "../../actions/map"; import { saveMainMapStatus } from "../../actions/map";
...@@ -12,9 +12,9 @@ import { saveMainMapStatus } from "../../actions/map"; ...@@ -12,9 +12,9 @@ import { saveMainMapStatus } from "../../actions/map";
* Component to create the map of universities * Component to create the map of universities
* *
* @class UnivMap * @class UnivMap
* @extends {CustomComponentForAPI} * @extends {Component}
*/ */
class UnivMap extends CustomComponentForAPI { class UnivMap extends Component {
// Initial state // Initial state
state = { state = {
...@@ -22,6 +22,12 @@ class UnivMap extends CustomComponentForAPI { ...@@ -22,6 +22,12 @@ class UnivMap extends CustomComponentForAPI {
height: 800, height: 800,
} }
constructor(props) {
super(props);
// Make sure to set the correct height on mount
this.updateDimensions();
}
/** /**
* Custom function to update the appropriate height of the map * Custom function to update the appropriate height of the map
* *
...@@ -37,15 +43,10 @@ class UnivMap extends CustomComponentForAPI { ...@@ -37,15 +43,10 @@ class UnivMap extends CustomComponentForAPI {
catch (err) { } catch (err) { }
} }
componentWillMount() {
// Make sure to set the correct height on mount
this.updateDimensions();
}
componentDidMount() { componentDidMount() {
// add an event listener to resize the map when needed // add an event listener to resize the map when needed
window.addEventListener("resize", this.updateDimensions.bind(this)); window.addEventListener("resize", this.updateDimensions.bind(this));
super.componentDidMount(); this.updateDimensions();
} }
componentWillUnmount() { componentWillUnmount() {
...@@ -93,7 +94,7 @@ class UnivMap extends CustomComponentForAPI { ...@@ -93,7 +94,7 @@ class UnivMap extends CustomComponentForAPI {
})); }));
} }
customRender() { render() {
const stamenName = "Stamen Watercolor", const stamenName = "Stamen Watercolor",
osmFrName = "OpenStreetMap France", osmFrName = "OpenStreetMap France",
esriName = "Esri WorldImagery", esriName = "Esri WorldImagery",
...@@ -154,6 +155,11 @@ class UnivMap extends CustomComponentForAPI { ...@@ -154,6 +155,11 @@ class UnivMap extends CustomComponentForAPI {
} }
UnivMap.propTypes = {
map: PropTypes.object.isRequired,
saveMainMap: PropTypes.func.isRequired
};
const mapStateToProps = (state) => { const mapStateToProps = (state) => {
return { return {
map: state.app.mainMap map: state.app.mainMap
......
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