我刚刚开始使用 React-leaflet 库并获得了一个要加载 geoJSON 层的地图,但是我想使用 TopoJSON 层。
我知道这样的纯传单是可能的: https: //gist.github.com/rclark/5779673/。
但是我该如何使用 React-Leaflet 来做到这一点呢?
编辑
class MapViz extends React.Component {
getStyle() {...};
render() {
const position = [x,y];
var geoData = topojson.feature(test_topo,test_topo.objects).geometries;
return (
<Map id="my-map" center={position} zoom={10.2}>
<TileLayer ... />
<GeoJSON data={geoData} style={this.getStyle} />
</Map>
)
}
}
Run Code Online (Sandbox Code Playgroud)