I'm trying to work with the react-friendly wrapper written by the uber team for mapbox gl.
I am wondering if anyone has successfully rendered polygon features from a geojson source with their API. It states that a source options is attribute is available on the <Layer/>
component:
sourceOptions: Options object merged to the object used when calling GeoJSONSource method
Following the mapbox API for geoJsonSource, I am trying the following and wondering what else I need to do in order to get it to render:
import React, { Component } from 'react';
import ReactMapboxGl, { Layer, Feature } from "../node_modules/react-mapbox-gl/dist";
import logo from './logo.svg';
import './App.css';
let containerStyle = {
height: "100vh",
width: "100vw"
};
const accessToken = _removed for safety_
class App extends Component {
_polygonClicked = ({ feature }) => {
console.log("Polygon clicked", feature.geometry.coordinates);
};
render() {
return (
<div className="App">
<div className="App-header">
<img src={logo} className="App-logo" alt="logo" />
<h2>Welcome to React</h2>
</div>
<ReactMapboxGl
style={"mapbox://styles/mapbox/streets-v8"}
center={[11.956511272000057,10.095463399000039]}
zoom={[11]}
accessToken={accessToken}
containerStyle={containerStyle}>
<Layer
type="fill"
paint={{ "fill-color": "#3bb2d0", "fill-opacity": .5 }}
id="testing"
sourceOptions={'religious',{
"type": 'geojson',
"data":'../small_poly/bridges.geojson'
}}
sourceId={'religious'}>
</Layer>
</ReactMapboxGl>
</div>
);
}
}
export default App;