Created
August 8, 2016 14:52
-
-
Save tsi/0354ad479e3204a3d7e6254b5f235461 to your computer and use it in GitHub Desktop.
Simplest open-layers ReactJS component basic example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { Component } from 'react'; | |
require('ol3-google-maps'); | |
require('openlayers/css/ol.css'); | |
require('./Map.scss'); | |
export default class Map extends Component { | |
componentDidMount() { | |
let map = new ol.Map({ | |
layers: [ | |
new ol.layer.Tile({ | |
source: new ol.source.OSM() | |
}) | |
], | |
target: 'map', | |
view: new ol.View({ | |
center: [0, 0], | |
zoom: 2 | |
}) | |
}); | |
} | |
render() { | |
return ( | |
<section className="panel-map"> | |
<div id="map" className="map" ref="olmap"></div> | |
</section> | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment