-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add Mapbox GL and related libraries required to serve maps from Webpack. * Update Webpack config based on Mapbox example and https://mikewilliamson.wordpress.com/2016/02/24/using-mapbox-gl-and-webpack-together/, and visgl/react-map-gl#21 (comment). * Create map component and add to SightingsList component. Closes #8
- Loading branch information
1 parent
d8898ef
commit d7d1645
Showing
6 changed files
with
120 additions
and
19 deletions.
There are no files selected for viewing
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import React, { Component, PropTypes } from 'react'; | ||
|
||
import mapboxgl from 'mapbox-gl'; | ||
|
||
export default class HotspotMap extends Component { | ||
componentDidMount() { | ||
mapboxgl.accessToken = | ||
'pk.eyJ1IjoiY2FzZXlwdCIsImEiOiJjaXA3OTUxODcwMHpic3ZseWtqcDZ1NXV2In0.felyQy7-DwS8zTiILhWf1g'; | ||
|
||
const map = new mapboxgl.Map({ | ||
container: 'map', | ||
style: 'mapbox://styles/mapbox/outdoors-v9', | ||
center: this.props.position, | ||
zoom: 15, | ||
}); | ||
|
||
map.on('load', () => { | ||
map.addSource('symbols', { | ||
type: 'geojson', | ||
data: { | ||
type: 'Feature', | ||
properties: {}, | ||
geometry: { | ||
type: 'Point', | ||
coordinates: [ | ||
this.props.position[0], | ||
this.props.position[1], | ||
], | ||
}, | ||
}, | ||
}); | ||
|
||
map.addLayer({ | ||
id: 'symbols', | ||
type: 'symbol', | ||
source: 'symbols', | ||
layout: { | ||
'icon-image': 'marker-15', | ||
}, | ||
}); | ||
}); | ||
} | ||
|
||
render() { | ||
return <div id="map"></div>; | ||
} | ||
} | ||
|
||
HotspotMap.propTypes = { | ||
position: PropTypes.arrayOf(PropTypes.number.isRequired).isRequired, | ||
}; |
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
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