Skip to content

Instantly share code, notes, and snippets.

@tsi
Created August 8, 2016 14:52
Show Gist options
  • Save tsi/0354ad479e3204a3d7e6254b5f235461 to your computer and use it in GitHub Desktop.
Save tsi/0354ad479e3204a3d7e6254b5f235461 to your computer and use it in GitHub Desktop.
Simplest open-layers ReactJS component basic example
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