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.

Cannot apply `translate` to a PointAnnotation

See original GitHub issue

Describe the bug
I want to render a custom icon, drawn with CSS, and applied the translate property, as an annotation but cannot with PointAnnotation. It does work with MarkerView, thought, but I also need the annotation to be clickable and MarkerView is not.

Example:

import React from 'react';
import MapboxGL from "@react-native-mapbox-gl/maps";

const Annotation = () => {
  return (
    <MapboxGL.PointAnnotation
      id={v.id}
      key={v.id}
      style={{ flex: 1 }}
      selected={isSelected}
      coordinate={coordinate}
      onSelected={feature => this.onAnnotationSelected(v)}
      >
        <View style={[style.annotationContainer]} />
      </MapboxGL.PointAnnotation>
   );
}

const styles = StyleSheets.create({
  annotationContainer: {
    width: 20,
    height: 20,
    alignItems: "center",
    justifyContent: "center",
    borderTopLeftRadius: 50,
    borderTopRightRadius: 50,
    borderBottomRightRadius: 0,
    borderBottomLeftRadius: 50,
    position: "relative",
    transform: [{ rotate: "45deg" }]
  }
});

The strange thing is, as I said, that if I switch to a MarkerView, instead of PointAnnotation, the transform is applied. I went through the source code of both components but couldn’t find anything that might be causing this. I’m willing to submit a PR if you can guide me to where the problem might be.

Screenshots
If applicable, add screenshots to help explain your problem.

Versions (please complete the following information):

  • Platform: Android
  • Platform OS: Android 10
  • Device: OnePlus 5
  • Emulator/ Simulator: no
  • Dev OS: Win10
  • react-native-mapbox-gl Version: 8.1.0
  • Mapbox GL version -
  • React Native Version 0.63.4

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
tdranvcommented, Sep 14, 2021

Ops. missed that notification. Will do! 😃

-> https://github.com/react-native-mapbox-gl/maps/discussions/1537

1reaction
mfazekascommented, Aug 26, 2021

@tdranv you might need the parent view some background otherwise it might be optimised away:

<MapboxGL.PointAnnotation
      id={v.id}
      key={v.id}
      style={{ flex: 1 }}
      selected={isSelected}
      coordinate={coordinate}
      onSelected={feature => this.onAnnotationSelected(v)}
      >
        <View style={{backgroundColor:'red'}}>
          <View style={[style.annotationContainer]} />
       </View>
      </MapboxGL.PointAnnotation>
   );
Read more comments on GitHub >

github_iconTop Results From Across the Web

Could not cast value of type - Custom Point Annotation
When I tried to create thumbnail images for each pin when you click on it. I get the error message: Could not cast...
Read more >
Google Translate
No information is available for this page.
Read more >
Migrate to v10 | Maps SDK | iOS - Mapbox docs
In the Maps SDK v10, a JSON expression from Mapbox Studio can be used directly or can be translated to Swift. To use...
Read more >
translate() - CSS: Cascading Style Sheets - MDN Web Docs
The translate() CSS function repositions an element in the horizontal and/or vertical directions. Its result is a data type.
Read more >
Unable to update location of a Point Annotation #478 - GitHub
Here's how I am adding a point annotation guard let lat = locationManager. ... 3782B-layer is in use, cannot remove") Warning: <Annotations> ...
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