Cannot apply `translate` to a PointAnnotation
See original GitHub issueDescribe 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:
- Created 2 years ago
- Comments:8 (5 by maintainers)
Top 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 >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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Ops. missed that notification. Will do! 😃
-> https://github.com/react-native-mapbox-gl/maps/discussions/1537
@tdranv you might need the parent view some background otherwise it might be optimised away: