React-native-mapbox-gl: [QUESTION] Callout without PointAnnotation

Created on 17 Nov 2017  路  10Comments  路  Source: nitaliano/react-native-mapbox-gl

Hey guys,

thanks for this great library. I just switched over from react-native-maps.

I would like to have Callouts (e.g. labels) on my map without PointAnnotations. Is this possible?

I already tried to make the PointAnnotation invisible with opacity and visibility stuff but it didn't work.
Thanks!

Most helpful comment

This got me as far as adding text labels to the map:
image

But what about adding the callout box underneath the text? Can I add anything more than text to the box like a button or an entire component? I'm looking to build something like this:
image

All 10 comments

Depending on what you need it to look like you can achieve something like this with a SymbolLayer. Would you be able to post a screen of what it would look like?

@nitaliano
adb_2017-11-17_18-07-50

I checked out your examples but couldn't figure out how to achieve this. It doesn't seem to be possible to set a text per feature in SymbolLayer, right?

You can your styles have access to your feature properties

Let's say you have this feature collection, you can see each feature has a property name

{
  "type": "FeatureCollection",
  "features": [
    {
      "type": "Feature",
      "properties": {
        "name": "Test 1"
      },
      "geometry": {
        "type": "Point",
        "coordinates": [
          -118.828125,
          37.16031654673677
        ]
      }
    },
    {
      "type": "Feature",
      "properties": {
        "name": "Test 2"
      },
      "geometry": {
        "type": "Point",
        "coordinates": [
          -124.8046875,
          33.43144133557529
        ]
      }
    },
    {
      "type": "Feature",
      "properties": {
        "name": "Test 3"
      },
      "geometry": {
        "type": "Point",
        "coordinates": [
          -128.32031249999997,
          51.83577752045248
        ]
      }
    }
  ]
}

and for the style you can access that property by using a token string

const styles = MapboxGL.StyleSheet.create({
   textSymbol: {
      textField: '{name}'
   }
})

Thanks. Is it possible to register onPress events for the symbols in the spacesource?

Follow this example - https://github.com/mapbox/react-native-mapbox-gl/blob/master/example/src/components/QueryAtPoint.js#L44

You can query the features rendered on the map with a point or bbox. I'll be releasing a PR this week that adds support for an onPress on a ShapeSource, so I'll query under the hood for the user

This got me as far as adding text labels to the map:
image

But what about adding the callout box underneath the text? Can I add anything more than text to the box like a button or an entire component? I'm looking to build something like this:
image

@nitaliano Any ideas?

@stdavis Did you managed to add anything more than text?

No. We decided to just navigate to a different view when the point is pressed rather than showing a popup.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

lernerbot picture lernerbot  路  3Comments

glennverschooren picture glennverschooren  路  4Comments

alexisohayon picture alexisohayon  路  4Comments

VentsislavDinev picture VentsislavDinev  路  3Comments

vyankat70war picture vyankat70war  路  3Comments