question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to highlight line in <GeoJSONLayer/>

See original GitHub issue

I have this code, Lines are drawn. But I want to highlight a line when hovered or clicked.

        {Object.keys(this.props.pavements).length > 0 && (
          <GeoJSONLayer
            data={this.props.pavements}
            linePaint={{
              'line-color': ['get', 'color'],
              'line-width': 10,
            }}
            lineLayout={{
              'line-cap': 'round',
            }}
            lineOnClick={e => this.populateInfobox(e)}
            lineOnMouseEnter={e => this.populateInfobox(e)}
          />
        )}

What can I do in lineOnClick to change the color of the clicked line?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5

github_iconTop GitHub Comments

4reactions
mklopetscommented, Sep 24, 2018

You can use React state to provide a different line-color property after the click or provide a different color property on the clicked feature.

2reactions
suyeshcommented, Sep 26, 2018

I did it by saving the color property of GeoJson in redux and changing the color of the selected feature

Read more comments on GitHub >

github_iconTop Results From Across the Web

Highlighting selected geojson feature and return to ...
Point is that I'd like to have the selected feature to highlight when clicked and return to unselected state when another one is...
Read more >
How to set line color in Geojson layer using xamarin forms
I am new in Xamarin forms I want to add a line color to my GeoJson Layer. How Can I do this. Please...
Read more >
GeoJsonLayer - deck.gl
The outline will have "horizontal" lines closing the top and bottom polygons and a vertical line (a "strut") for each vertex on the...
Read more >
update GeoJsonLayer feature color on click · Issue #3545
I'm using the deck.gl GeoJsonLayer to display regions on a map. through an event, I was able to make these regions selectable. what...
Read more >
Highlight point features | Sample Code - ArcGIS Developers
This sample shows how to highlight features in a layer. Features in SceneLayer, FeatureLayer, CSVLayer, GeoRSSLayer and GraphicsLayer can be highlighted.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found