Is it possible to combine <Layer paint> and click on <Feature> ?
See original GitHub issueHello !
I have this source
<Source id={'source-cities'} geoJsonSource={this.props.citiesGeoJSON} />
that I’m using for this layer
<Layer
type='circle'
sourceId={'source-cities'}
id={'layer-1'}
paint={
'circle-radius': {
property: 'population',
type: 'exponential',
stops: [
// https://www.mapbox.com/mapbox-gl-js/style-spec#types-function-zoom-property
[{zoom: 5, value: 0}, 3], // zoom, pop, radius
[{zoom: 5, value: 855393}, 30], // zoom, pop, radius
[{zoom: 10, value: 0}, 10], // zoom, pop, radius
[{zoom: 10, value: 855393}, 50] // zoom, pop, radius
]
}
}
/>
And this is working fine, my circles radius are connected to the property ‘population’ .
But I can’t click on a point to display a popup. I need Feature component. So be it, I add all my Features :
<Layer
type='circle'
id={'clicklayer'}
sourceId={'source-cities'}
paint={
'circle-radius': {
property: 'population',
type: 'exponential',
stops: [
// https://www.mapbox.com/mapbox-gl-js/style-spec#types-function-zoom-property
[{zoom: 5, value: 0}, 3], // zoom, pop, radius
[{zoom: 5, value: 855393}, 30], // zoom, pop, radius
[{zoom: 10, value: 0}, 10], // zoom, pop, radius
[{zoom: 10, value: 855393}, 50] // zoom, pop, radius
]
}
}
>
{
this.props.cities.map((city, i) => (
<Feature
key={i}
onClick={() => console.log('click)}
coordinates={city.geo}
/>
))
}
</Layer>
Click on Feature is not working unless I remove the sourceId in Layer 😦 But if I do remove sourceId I am losing the paint (circle-radius depending on the property ‘population’.
How can I keep both click on Feature and paint style depending on a property ?
Thanks for your help !
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
PaintShop Pro : How To Merge Layers Tutorial | Graphicxtras
How-to merge layers feature in PaintShop Pro, merge layers to create all kinds of amazing designs in PSP tutorial / Paintshop pro how-to ......
Read more >Manage layers and groups in Photoshop - Adobe Support
Merge down: To merge two adjacent visible layers where the bottom layer is a pixel layer, select the top layer in the Layers...
Read more >Draw a picture by combining and merging shapes
Select the shapes you want to merge: press and hold the Shift key while you select each shape in turn. (If you don't...
Read more >How to rasterize, duplicate and merge layers - Drawing Desk
The Layer Merge feature combines the selected layer with the one directly below it in your panel of layers. Once two layers are...
Read more >Introduction to Layers and Masks - Krita Manual
Usually, when you put one paint layer on top of another, the upper paint layer will be fully visible, while the layer behind...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
We just released #675 that adds mouse events to
<Layer>
enjoy!Here’s another solution:
I extracted this from real code. I hope it’s still usable.