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.

layerIndex Property Throws Error/Not Adding Layers In Correct Order

See original GitHub issue

Describe the bug Using layerIndex property in layers does not appear to be working and throws an error.

To Reproduce Steps to reproduce the behavior

        {loading ? null : (<Mapbox.RasterSource id="rasterSourceBasemap" tileSize={256} url={Url}>
          <Mapbox.RasterLayer
            id="basemap"
            sourceID="rasterSourceBasemap"
            style={{ rasterOpacity: 1 }}
            layerIndex={1}
          />
        </Mapbox.RasterSource>)}

        {loading ? null : (<Mapbox.ShapeSource>
          <Mapbox.SymbolLayer 
            id="guz" 
            style={{ visibility: (layers.guz.show ? "visible" : "none") }}
            layerIndex={10}
          />
        </Mapbox.ShapeSource>)}

Expected behavior The layers would show in the order of the defined layerIndex.

Screenshots I get the following error:

Screen Shot 2019-05-29 at 1 31 24 AM

At times when the error is not present the layers don’t seem to respond to the actual layerIndex defined in each layer.

Versions (please complete the following information):

  • Platfrom: iOS
  • React Native Version 0.59

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
dmlitvinovcommented, Aug 14, 2019

We have exactly the same problem. There is no error without specifying an index, but there is no way to set the correct layer order

0reactions
anfriiscommented, Sep 4, 2019

I tried #361 in my project with setting layerIndex instead of aboveLayerId. The layers in my map style (street names, etc.) are placed rather high up with the highest being around layerIndex 40-42. I want my own layers to be placed above all the map’s own layers, so if I set layerIndex to 50 for my own layer, I get: Terminating app due to uncaught exception 'NSRangeException', reason: 'Cannot insert style layer at out-of-bounds index 50. I have 14 layers on my map, so I have to use the 8 indexes between 42 and 50, and rely on aboveLayerId layers in the same ShapeSource.

Does anyone know why it is not possible to use an index >= 50? @mfazekas

Versions (please complete the following information):

Platfrom: iOS React Native Version 0.59.9

Read more comments on GitHub >

github_iconTop Results From Across the Web

layerIndex Property Throws Error/Not Adding Layers ... - GitHub
Terminating app due to uncaught exception 'NSRangeException', reason: 'Cannot insert style layer at out-of-bounds index 50. I have 14 layers on my map,...
Read more >
Error: The layer, <layer_name>, cannot be added to the map
Solution or Workaround · In Map Viewer Classic, in the Contents pane, browse to the layer, and click Remove. · When prompted, click...
Read more >
Using layers with your Lambda function - AWS Documentation
Adding a layer to a function​​ Open the Functions page of the Lambda console. Choose the function to configure. Under Choose a layer,...
Read more >
Using z-index - CSS: Cascading Style Sheets - MDN Web Docs
The first article of this guide, Stacking without the z-index property, explains how stacking is arranged by default.
Read more >
Layer—ArcGIS Pro | Documentation
Used to determine if a particular layer type supports a property on the layer object. Not all layers support the same set of...
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