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.

SymbolLayer not shown when rendering custom icons

See original GitHub issue

I’m trying to add a different pin for each feature’s category like follows, but pins are not visible no matter what I do. I’m surely missing something so let me ask 4 quick questions:

  1. What am I missing that this code below doesn’t work (at least on Android)?
  2. Is this the way to go to show custom pins based on the category of the features plus a default pin?
  3. Is this approach fine in terms of performance when you show many hundred pins on a map?
  4. Is it a better idea to create a .png image of each pin and use that instead of a CustomIcon (which renders at least two Icon inside a View)?
<MapboxGL.ShapeSource shape={this._createGeoJson()}>
  // Restaurant category
  <MapboxGL.SymbolLayer filter={["==","category", "foo"]}>
    <CustomIcon name="foo" color="#ff5c5c" />
  </MapboxGL.SymbolLayer>

  // Bank category
  <MapboxGL.SymbolLayer filter={["==","category", "bar"]}>
    <CustomIcon name="bar" color="#159b00" />
  </MapboxGL.SymbolLayer>

  // Many other SymbolLayers for other categories...
  //<MapboxGL.SymbolLayer ...

  // Features with no category
  <MapboxGL.SymbolLayer filter={["!", ["has", "category"]]}>
    <CustomIcon name="default" color="#5c94ff" />
  </MapboxGL.SymbolLayer>
</MapboxGL.ShapeSource>

Where CustomIcon renders the corresponding MaterialCommunityIcons over a pin-like Image.

Issue Analytics

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

github_iconTop GitHub Comments

6reactions
mfazekascommented, Dec 13, 2019

We only support png images. You might be able to generate PNG from vector fonts and use that.

1reaction
emmxcommented, Dec 13, 2019

That wouldn’t work for me, I need to set some params like the color and icon image from react-native-vector-icons.

Being able to use your own <CustomIcon> to <MapboxGL.Images> would be nice, there must be a way to avoid having the image exported beforehand as it’s sometimes impossible!

Any other idea?

Read more comments on GitHub >

github_iconTop Results From Across the Web

SymbolLayer not shown when rendering custom icons #561
I'm trying to add a different pin for each feature's category like follows, but pins are not visible no matter what I do....
Read more >
react-native mapbox symbol layer render icons from URI ...
I need to show custom icons in my places, that icons are loaded from a specific URL dynamically. Here is my code.
Read more >
How do I know if the marker symbol layer will be displayed ...
I need to find out whether or not this marker layer will be displayed when rendering for the feature I selected. How can...
Read more >
rnmapbox/Lobby - Gitter
SymbolLayer id="exampleIconName" style={styles.icon} /> </MapboxGL. ... custom icons as pins, I'm doing something wrong and pins are not shown on the map.
Read more >
Azure Maps Samples
This sample shows how to customize the rendering of the drawing shapes in the drawing manager by accessing the rendering layers using the...
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