Commit 9e2c4717 authored by Florent Chehab's avatar Florent Chehab

Fix map size

parent fe67608e
import React from 'react';
import MyComponent from '../MyComponent'
import {connect} from "react-redux";
import { connect } from "react-redux";
import { Map, TileLayer, LayersControl, LayerGroup } from 'react-leaflet';
import UnivMarkers from './UnivMakers';
......@@ -11,10 +11,26 @@ class UnivMap extends MyComponent {
constructor() {
super();
this.state = {
leaflet_instance: null
leaflet_instance: null,
height: 800,
};
}
updateDimensions() {
try {
const height = window.innerHeight - document.getElementById('MySuperMap').getBoundingClientRect().y;
this.setState({ height: Math.round(0.9 * height) })
}
catch (err) { }
}
componentWillMount() {
this.updateDimensions()
}
myComponentDidMount() {
window.addEventListener("resize", this.updateDimensions.bind(this))
}
componentWillUnmount() {
let l = this.state.leaflet_instance;
......@@ -33,16 +49,17 @@ class UnivMap extends MyComponent {
selected_layer
})
}
window.removeEventListener("resize", this.updateDimensions.bind(this))
}
saveLeafletInstance = (l) => {
this.setState(Object.assign({},this.state, {
this.setState(Object.assign({}, this.state, {
leaflet_instance: l,
}))
}
saveSelectedLayer = (e) => {
this.setState(Object.assign({},this.state, {
this.setState(Object.assign({}, this.state, {
selected_layer: e.name,
}))
}
......@@ -53,7 +70,7 @@ class UnivMap extends MyComponent {
let esri_name = "Esri WorldImagery";
return (
<Map center={this.props.map.center} zoom={this.props.map.zoom} style={{ height: "800px" }} whenReady={(e) => this.saveLeafletInstance(e.target)} onBaselayerchange={(e) => this.saveSelectedLayer(e)}>
<Map id={"MySuperMap"} center={this.props.map.center} zoom={this.props.map.zoom} style={{ height: this.state.height }} whenReady={(e) => this.saveLeafletInstance(e.target)} onBaselayerchange={(e) => this.saveSelectedLayer(e)}>
<LayersControl position="topright">
<LayersControl.BaseLayer name={osm_fr_name} checked={this.props.map.selected_layer == osm_fr_name}>
<TileLayer
......
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