Skip to content

How to use URL as iconImage in SymbolLayer? #2755

Answered by mfazekas
NDobricic asked this question in Q&A
Discussion options

You must be logged in to vote

@NDobricic pls note that using an url as iconImage should be (deprecated in v10)[https://github.com/rnmapbox/maps/wiki/Deprecated-URLInIconImages].

Pls use Images and onImageMissing.

This is pseudo code, but somthing like this should work:

const features = [
    {
      type: 'Feature',
      id: 'a-feature',
      properties: {
        icon: 'V1REv35.jpeg',
      },
      geometry: {
        type: 'Point',
        coordinates: [45, 45],
      },
    }
  ]
  
  
         const [images,setImages] = useState({});
         
         ...

         <MapView>
             <Images onImageMissing={(imageKey) => {
                      setImages({...images,imageKey: `https://i.imgur.com/${imageKey}`}

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@NDobricic
Comment options

@mfazekas
Comment options

@between0n1
Comment options

Answer selected by NDobricic
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants