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 CustomComponentForAPI from "../CustomComponentForAPI";
import React, { Component } from "react";
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 { saveMainMapStatus } from "../../actions/map";
......@@ -12,9 +12,9 @@ import { saveMainMapStatus } from "../../actions/map";
* Component to create the map of universities
*
* @class UnivMap
* @extends {CustomComponentForAPI}
* @extends {Component}
*/
class UnivMap extends CustomComponentForAPI {
class UnivMap extends Component {
// Initial state
state = {
......@@ -22,6 +22,12 @@ class UnivMap extends CustomComponentForAPI {
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
*
......@@ -37,15 +43,10 @@ class UnivMap extends CustomComponentForAPI {
catch (err) { }
}
componentWillMount() {
// Make sure to set the correct height on mount
this.updateDimensions();
}
componentDidMount() {
// add an event listener to resize the map when needed
window.addEventListener("resize", this.updateDimensions.bind(this));
super.componentDidMount();
this.updateDimensions();
}
componentWillUnmount() {
......@@ -93,7 +94,7 @@ class UnivMap extends CustomComponentForAPI {
}));
}
customRender() {
render() {
const stamenName = "Stamen Watercolor",
osmFrName = "OpenStreetMap France",
esriName = "Esri WorldImagery",
......@@ -154,6 +155,11 @@ class UnivMap extends CustomComponentForAPI {
}
UnivMap.propTypes = {
map: PropTypes.object.isRequired,
saveMainMap: PropTypes.func.isRequired
};
const mapStateToProps = (state) => {
return {
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