Skip to content
Snippets Groups Projects
Commit ab8ac745 authored by Esko Ikkala's avatar Esko Ikkala
Browse files

Add leaflet

parent 1d092f64
No related branches found
No related tags found
No related merge requests found
...@@ -6726,6 +6726,11 @@ ...@@ -6726,6 +6726,11 @@
"invert-kv": "1.0.0" "invert-kv": "1.0.0"
} }
}, },
"leaflet": {
"version": "1.3.1",
"resolved": "https://registry.npmjs.org/leaflet/-/leaflet-1.3.1.tgz",
"integrity": "sha512-adQOIzh+bfdridLM1xIgJ9VnJbAUY3wqs/ueF+ITla+PLQ1z47USdBKUf+iD9FuUA8RtlT6j6hZBfZoA6mW+XQ=="
},
"levn": { "levn": {
"version": "0.3.0", "version": "0.3.0",
"resolved": "https://registry.npmjs.org/levn/-/levn-0.3.0.tgz", "resolved": "https://registry.npmjs.org/levn/-/levn-0.3.0.tgz",
...@@ -7052,6 +7057,11 @@ ...@@ -7052,6 +7057,11 @@
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.5.tgz", "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.5.tgz",
"integrity": "sha512-svL3uiZf1RwhH+cWrfZn3A4+U58wbP0tGVTLQPbjplZxZ8ROD9VLuNgsRniTlLe7OlSqR79RUehXgpBW/s0IQw==" "integrity": "sha512-svL3uiZf1RwhH+cWrfZn3A4+U58wbP0tGVTLQPbjplZxZ8ROD9VLuNgsRniTlLe7OlSqR79RUehXgpBW/s0IQw=="
}, },
"lodash-es": {
"version": "4.17.8",
"resolved": "https://registry.npmjs.org/lodash-es/-/lodash-es-4.17.8.tgz",
"integrity": "sha512-I9mjAxengFAleSThFhhAhvba6fsO0hunb9/0sQ6qQihSZsJRBofv2rYH58WXaOb/O++eUmYpCLywSQ22GfU+sA=="
},
"lodash.camelcase": { "lodash.camelcase": {
"version": "4.3.0", "version": "4.3.0",
"resolved": "https://registry.npmjs.org/lodash.camelcase/-/lodash.camelcase-4.3.0.tgz", "resolved": "https://registry.npmjs.org/lodash.camelcase/-/lodash.camelcase-4.3.0.tgz",
...@@ -9330,6 +9340,16 @@ ...@@ -9330,6 +9340,16 @@
"theming": "1.3.0" "theming": "1.3.0"
} }
}, },
"react-leaflet": {
"version": "1.9.1",
"resolved": "https://registry.npmjs.org/react-leaflet/-/react-leaflet-1.9.1.tgz",
"integrity": "sha512-QiYpjyf1DHy0gLAR2958Mo5Wlu2u7FubIjapPpuUAQNFmjkVSteiDLlEdDpGswTHTyNAfKLS+u9PqvfipMDZKA==",
"requires": {
"lodash": "4.17.5",
"lodash-es": "4.17.8",
"warning": "3.0.0"
}
},
"react-lifecycles-compat": { "react-lifecycles-compat": {
"version": "2.0.2", "version": "2.0.2",
"resolved": "https://registry.npmjs.org/react-lifecycles-compat/-/react-lifecycles-compat-2.0.2.tgz", "resolved": "https://registry.npmjs.org/react-lifecycles-compat/-/react-lifecycles-compat-2.0.2.tgz",
......
...@@ -5,6 +5,7 @@ import { withStyles } from 'material-ui/styles'; ...@@ -5,6 +5,7 @@ import { withStyles } from 'material-ui/styles';
import Grid from 'material-ui/Grid'; import Grid from 'material-ui/Grid';
import ButtonAppBar from './ButtonAppBar'; import ButtonAppBar from './ButtonAppBar';
import IntegrationAutosuggest from './IntegrationAutosuggest'; import IntegrationAutosuggest from './IntegrationAutosuggest';
import LeafletMapContainer from './LeafletMapContainer';
const styles = theme => ({ const styles = theme => ({
root: { root: {
...@@ -29,6 +30,9 @@ function FullWidthGrid(props) { ...@@ -29,6 +30,9 @@ function FullWidthGrid(props) {
<Grid item xs={12} sm={3}> <Grid item xs={12} sm={3}>
<IntegrationAutosuggest /> <IntegrationAutosuggest />
</Grid> </Grid>
<Grid item xs={12} sm={9}>
<LeafletMapContainer />
</Grid>
</Grid> </Grid>
</div> </div>
); );
......
import React from 'react';
import { Map, TileLayer, Marker, Popup } from 'react-leaflet';
class LeafletMap extends React.Component {
state = {
lat: 51.505,
lng: -0.09,
zoom: 13,
}
render() {
const position = [this.state.lat, this.state.lng];
return (
<Map
center={position}
zoom={this.state.zoom}>
<TileLayer
attribution="&amp;copy <a href=&quot;http://osm.org/copyright&quot;>OpenStreetMap</a> contributors"
url="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"
/>
<Marker position={position}>
<Popup>
<span>
A pretty CSS3 popup. <br /> Easily customizable.
</span>
</Popup>
</Marker>
</Map>
);
}
}
export default LeafletMap;
import React from 'react';
import LeafletMap from './LeafletMap';
class LeafletMapContainer extends React.Component {
updateDimensions() {
const height = window.innerWidth >= 992 ? window.innerHeight : 400;
this.setState({ height: height });
}
componentWillMount() {
this.updateDimensions();
}
componentDidMount() {
window.addEventListener('resize', this.updateDimensions.bind(this));
}
componentWillUnmount() {
window.removeEventListener('resize', this.updateDimensions.bind(this));
}
render() {
return (
<div className="map-container" style={{ height: this.state.height }}>
<LeafletMap />
</div>
);
}
}
export default LeafletMapContainer;
...@@ -3,6 +3,14 @@ ...@@ -3,6 +3,14 @@
<head> <head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8"/> <meta http-equiv="Content-type" content="text/html; charset=utf-8"/>
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500"> <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500">
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.3.1/dist/leaflet.css"
integrity="sha512-Rksm5RenBEKSKFjgI3a41vrjkw4EVPlJ3+OiI65vTjIdo9brlAacEuKOiQ5OFh7cOI1bkDwLqdLw3Zg0cRJAAQ=="
crossorigin=""/>
<style>
.leaflet-container {
height: 100%;
}
</style>
<title><%= htmlWebpackPlugin.options.title %></title> <title><%= htmlWebpackPlugin.options.title %></title>
</head> </head>
<body> <body>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment