react-native-maps: Callout does not stretch based on content with React Native v0.28.0.
At React Native v0.26.3. the content is visible and callout size varies based on the content size:
<MapView.Marker coordinate={marker.latlng}>
<MapView.Callout>
<Text> ABCDEFG </TEXT>
</MapView.Callout>
</MapView.Marker>
But in v0.28.0 the callout size does not change:
Tested versions: react-native-maps v0.5.0 iOS 9.3 Android 6.0.1
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Reactions: 8
- Comments: 25
Same with RNM 0.6.0 and RN v0.29.0, setting
<MapView.Callout style={{ flex: 1, position: 'relative' }}>fixed it for meThis is still a problem…
@gblejman: The flex and relative position didn’t fix it for me. The callouts appeared in weird positions and flickered when panning the map. I had been setting a constant width on the child view inside the
MapView.Calloutbut I think that’s what broke with the new version.I was able to fix it by setting a width directly on the callout:
<MapView.Callout style={{ width: 250 }}>.Using RN 0.32 and latest 0.8.0 maps
The restricted custom callout width on both Android and iOS seems related to the layout position. When layout position is absolute, something is restricting the custom callout view width.
I am hoping this indicates a possible fix in react-native-maps JS rather than a fix required in each of the Android and iOS native modules.
position: ‘relative’ fixes the restricted width but now both marker and callout are in wrong location.
<MapView.Callout style={{ flex: 1, position: 'relative' }}>position: ‘absolute’ restricts maximum width of custom callout when showCallout() is called.
<MapView.Callout style={{ flex: 1, position: 'absoluteHey! I’ve been trying to work around this all morning and I ended up creating a Callout that imitates the default one but also allows for a custom view, responsive up to a width of callout_container.width… The component that goes inside the <Marker>:
The styles:
Example of the normal view and one without a description:
Example with a custom view:
Please note that the callout_container.width (75% of the device width), as discussed by other users, is the limit to the width of the inner view and although it’s background is transparent (you can only see the callout_view), the element still has that width and clicking on it counts as clicking the callout and not the map! Hope this helps you!
Not sure why this was closed it’s still broken.
@jeveloper I tried a couple of props with offset in the name.
I think they were not working because I was using layout position: relative because relative seem to fix the width constraint issue ( but break location position ).
Anyway, with your suggestion on issue https://github.com/lelandrichardson/react-native-maps/issues/427, setting flex -1, and width fixes my issue with the custom callout width, and both marker and callout are now displayed at correct locations on the map.
It was exhausting but I am finally using the latest version of both RN 32 and react-native-maps 0.8.0. All is good again!