Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- export class Livemap extends Component {
- componentDidMount() {
- var map = this.map = L.map(ReactDOM.findDOMNode(this), {
- minZoom: 2,
- maxZoom: 20,
- layers: [
- L.tileLayer(
- 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
- {attribution: '© <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, <a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>'})
- ],
- attributionControl: false,
- });
- map.on('click', this.onMapClick);
- map.fitWorld();
- }
- componentWillUnmount() {
- this.map.off('click', this.onMapClick);
- this.map = null;
- }
- onMapClick() {
- // Do some wonderful map things...
- }
- render() {
- return (
- <div className='mainmap'></div>
- );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment