This repository has been archived by the owner on Mar 5, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 29
/
LeafletMap.js
65 lines (51 loc) · 2.19 KB
/
LeafletMap.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
var _react = require('react');
var _react2 = _interopRequireDefault(_react);
var _reactLeaflet = require('react-leaflet');
var _isClient = require('../utils/isClient');
var _isClient2 = _interopRequireDefault(_isClient);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }
var LeafletMap = function LeafletMap(_ref) {
var width = _ref.width,
height = _ref.height,
children = _ref.children,
mapProps = _objectWithoutProperties(_ref, ['width', 'height', 'children']);
return _react2.default.createElement(
'div',
null,
_isClient2.default && _react2.default.createElement(
_reactLeaflet.Map,
_extends({}, mapProps, { style: { width: width, height: height } }),
_react2.default.createElement(_reactLeaflet.TileLayer, {
url: mapProps.url,
attribution: mapProps.attribution
}),
children
)
);
};
LeafletMap.propTypes = {
center: _react.PropTypes.arrayOf(_react.PropTypes.number),
zoom: _react.PropTypes.number,
scrollWheelZoom: _react.PropTypes.bool,
children: _react.PropTypes.node.isRequired,
width: _react.PropTypes.oneOfType([_react.PropTypes.number, _react.PropTypes.string]),
height: _react.PropTypes.oneOfType([_react.PropTypes.number, _react.PropTypes.string]),
url: _react.PropTypes.string,
attribution: _react.PropTypes.string
};
LeafletMap.defaultProps = {
center: [0, 0],
zoom: 0,
width: '100%',
height: 600,
scrollWheelZoom: false,
url: 'http://{s}.tile.osm.org/{z}/{x}/{y}.png',
attribution: "© <a href='http://osm.org/copyright'>OpenStreetMap</a> contributors"
};
exports.default = LeafletMap;