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.

Is it possible to change the layer's paint attribute while rendering circles on a map?

See original GitHub issue

Hello! I want to draw differently colored circles on a map using Layer's paint attribute and a Feature. Essentially, my code currently returns a feature to a layer, allowing a circle to be drawn at the specified coordinates. My problem with that implementation is that I cannot change the Layer's paint attribute while still drawing circles. Therefore, this led me to try the following code which results in no circles drawn on the map:

<Layer id="layer1" type="circle">
     {array.map((element, i) => {
          return (
               <Layer id="second" type="circle" paint={{boolOperator ? 'blue' : 'green'}}
                    <Feature coordinates={[0,0]} />
              </Layer>
          )
     })}
</Layer>

Is it possible to pass a Layer to another Layer, which then draws the circle on the map given the bottom Layer's paint attribute? The code above is meant to change the circle’s color if the boolOperator is either true or false, which changes per circle.

I appreciate any help! Thanks

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7

github_iconTop GitHub Comments

2reactions
mklopetscommented, Jun 13, 2019

The property name can be arbitrary. “Color” will work. You need to specify the layer’s paint to use that named property.

‘circle-color’: [‘get’, ‘xyz’] (in the layer’s paint options) should read the xyz property of the feature and use it for painting its corresponding circle (if I remember the syntax correctly by heart)

1reaction
ev0065commented, Jun 13, 2019

@mklopets That works, thank you very much! I appreciate all your help with this issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Shape attributes, paint operations, and path operations for ...
Learn how to add attributes—paths, paint operations, and path operations—to layers using the Tools panel or the Timeline panel.
Read more >
Layers | Style Specification | Mapbox GL JS
Layout properties appear in the layer's "layout" object. They are applied early in the rendering process and define how data for that layer...
Read more >
Symbology in vector tiles—ArcGIS Pro | Documentation
Vector tiles can be created from feature layers with symbology that varies by transparency, color, rotation, and size.
Read more >
Painting: Filling, Stroking and Marker Symbols — SVG 2
The fill and stroke properties, defined below, are used to specify the paint used to render the interior of and the stroke around...
Read more >
3.2. Lesson: Symbology - QGIS Documentation
3.2.3. basic Follow Along: Changing Symbol Structure¶ · Open the Layer Properties window for the landuse layer. · In the Symbol Layers panel,...
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