Draw a line from geojson with harp.gl

2

Can somesone give me an example how can I draw a line from a geojson LineString in harp.gl? The tutorial and the doc missing it.

Currently I'm trying with this in index.js:

fetch('my_data.geojson')
.then(data => data.json())
.then(data => {
   const geoJsonDataProvider = new harp.GeoJsonDataProvider("my_data", data);
   const geoJsonDataSource = new harp.OmvDataSource({
      dataProvider: geoJsonDataProvider,
      name: "my_data"
   });

    map.addDataSource(geoJsonDataSource).then(() => {
       const styles = [{
          when: "$geometryType == 'line'",
          renderOrder: 10000,
          attr: {
             color: 0x000000fe,
             size: 30
          }
       }]
       geoJsonDataSource.setStyleSet(styles);
       map.update();
    });
});

my_data.geojson generated at geojson.io

javascript
geojson
harp.gl
asked on Stack Overflow Nov 8, 2019 by Petya

1 Answer

1

I just missed some properties from the style. With this style it works fine:

 const styles = [{
     "when": "$geometryType ^= 'line'",
     "renderOrder": 1000,
     "technique": "solid-line",
     "attr": {
        "color": "blue",
        "opacity": 1,
        "metricUnit": "Pixel",
        "lineWidth": 4
     }
  }];
answered on Stack Overflow Nov 9, 2019 by Petya

User contributions licensed under CC BY-SA 3.0