Wildsong / ol-react

React bindings for OpenLayers
MIT License
8 stars 2 forks source link

vectorSource not working for layer.Vector #2

Open mgogh opened 5 years ago

mgogh commented 5 years ago

I would like to add a geojson vector source to the component "layer.Vector". I started to make a really simple example:

       var style = {
            image: {
                type: 'circle',
                radius: 4,
                fill: { color: [100,100,100, 0.5] },
                stroke: { color: 'green', width: 1 }
            }
        }
        var point = new Point(
            transform([-1.49, 49], 'EPSG:4326', 'EPSG:3857')
        );
        var pointFeature = new Feature(point);
        var vectorSource = new VectorSource({
            projection: 'EPSG:4326'
        });
        vectorSource.addFeatures([pointFeature]);

        return (
            <div className="container">
                <Map view={<View resolution={10000} center={[0, 0]}/>}>
                    <layer.Tile source="OSM"/>
                    <layer.Vector name="Display" source={vectorSource} style={style}/>
                </Map>
            </div>
        );

But I get only the OSM TileLayer, there no "Point" and I get also an error: GET http://localhost:8000/undefined0/query/?f=json&returnGeometry=true&spatialRel=esriSpatialRelIntersects&geometry=%7B%22xmin%22%3A-10018754.171394622%2C%22ymin%22%3A-5009377.085697312%2C%22xmax%22%3A-5009377.085697311%2C%22ymax%22%3A-9.313225746154785e-10&geometryType=esriGeometryEnvelope&outFields=*&callback=__jp0 net::ERR_ABORTED 404 (Not Found)

Is there any solution to display a geojson with the layer.Vector component ?

brian32768 commented 5 years ago

Sorry it took me so long to respond, I added your code as a test into "examples/example5.js" It builds but the codes not there to support it yet. I see what you are doing, I am looking at adding support.