react-native-maps: Polygon fill color not working properly
Bug
I am using Google Maps on iOS and I have Polygons. Before update (to version 0.18.3. - at the moment I am not able to update to latest version) everything works properly, but from now fill color gets weird results. Sometimes color is ok, sometimes it is not proper, no rules. On android everything works well.
Environment info
React native info output:
Binaries:
Node: 10.16.0 - /usr/local/bin/node
npm: 6.9.0 - /usr/local/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
SDKs:
iOS SDK:
Platforms: iOS 12.4, macOS 10.14, tvOS 12.4, watchOS 5.3
Android SDK:
API Levels: 26, 28, 29
Build Tools: 28.0.3, 29.0.1
System Images: android-28 | Intel x86 Atom_64, android-28 | Google Play Intel x86 Atom, android-29 | Google APIs Intel x86 Atom
IDEs:
Android Studio: 3.4 AI-183.6156.11.34.5692245
Xcode: 10.3/10G8 - /usr/bin/xcodebuild
npmPackages:
react: ^16.9.0 => 16.9.0
react-native: 0.59.10 => 0.59.10
npmGlobalPackages:
react-native-cli: 2.0.1
Library version: 0.18.3
Steps To Reproduce
1. react-native run-ios
…
Describe what you expected to happen:
- Polygon with proper color
Reproducible sample code
export const Polygon = (props) => {
return (
<MapView.Polygon
coordinates={ props.selectedAreas }
fillColor={ props.fillColor }
strokeColor={ props.strokeColor }
/>
)
};
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 33
- Comments: 66 (16 by maintainers)
Commits related to this issue
- https://github.com/react-native-community/react-native-maps/issues/3057 — committed to wem2017/react-native-maps by deleted user 4 years ago
- fix(ios-google): circle & polygon props not being applied Resolves #3057 — committed to react-native-maps/react-native-maps by monholm 2 years ago
- chore(release): 1.3.0-beta.2 [skip ci] # [1.3.0-beta.2](https://github.com/react-native-maps/react-native-maps/compare/v1.3.0-beta.1...v1.3.0-beta.2) (2022-08-12) ### Bug Fixes * **ios-google:** ci... — committed to react-native-maps/react-native-maps by semantic-release-bot 2 years ago
- chore(release): 1.3.0 [skip ci] # [1.3.0](https://github.com/react-native-maps/react-native-maps/compare/v1.2.0...v1.3.0) (2022-08-22) ### Bug Fixes * **android:** onLayout not being called ([#4404... — committed to react-native-maps/react-native-maps by semantic-release-bot 2 years ago
- chore(release): 1.3.0-beta.2 [skip ci] # [1.3.0-beta.2](https://github.com/react-native-maps/react-native-maps/compare/v1.3.0-beta.1...v1.3.0-beta.2) (2022-08-12) ### Bug Fixes * **ios-google:** ci... — committed to joshpeterson30489/maps-develop-with-react-native by joshpeterson30489 2 years ago
- chore(release): 1.3.0 [skip ci] # [1.3.0](https://github.com/react-native-maps/react-native-maps/compare/v1.2.0...v1.3.0) (2022-08-22) ### Bug Fixes * **android:** onLayout not being called ([#4404... — committed to joshpeterson30489/maps-develop-with-react-native by joshpeterson30489 2 years ago
- chore(release): 1.3.0-beta.2 [skip ci] # [1.3.0-beta.2](https://github.com/react-native-maps/react-native-maps/compare/v1.3.0-beta.1...v1.3.0-beta.2) (2022-08-12) ### Bug Fixes * **ios-google:** ci... — committed to superstar1205/Map-ReactNative by superstar1205 2 years ago
- chore(release): 1.3.0 [skip ci] # [1.3.0](https://github.com/react-native-maps/react-native-maps/compare/v1.2.0...v1.3.0) (2022-08-22) ### Bug Fixes * **android:** onLayout not being called ([#4404... — committed to superstar1205/Map-ReactNative by superstar1205 2 years ago
- chore(release): 1.3.0-beta.2 [skip ci] # [1.3.0-beta.2](https://github.com/react-native-maps/react-native-maps/compare/v1.3.0-beta.1...v1.3.0-beta.2) (2022-08-12) ### Bug Fixes * **ios-google:** ci... — committed to anthony0506/react-native-maps by anthony0506 2 years ago
- chore(release): 1.3.0 [skip ci] # [1.3.0](https://github.com/react-native-maps/react-native-maps/compare/v1.2.0...v1.3.0) (2022-08-22) ### Bug Fixes * **android:** onLayout not being called ([#4404... — committed to anthony0506/react-native-maps by anthony0506 2 years ago
- chore(release): 1.3.0-beta.2 [skip ci] # [1.3.0-beta.2](https://github.com/react-native-maps/react-native-maps/compare/v1.3.0-beta.1...v1.3.0-beta.2) (2022-08-12) ### Bug Fixes * **ios-google:** ci... — committed to johney6767/Map-ReactNative by deleted user 2 years ago
- chore(release): 1.3.0 [skip ci] # [1.3.0](https://github.com/react-native-maps/react-native-maps/compare/v1.2.0...v1.3.0) (2022-08-22) ### Bug Fixes * **android:** onLayout not being called ([#4404... — committed to johney6767/Map-ReactNative by deleted user 2 years ago
- chore(release): 1.3.0-beta.2 [skip ci] # [1.3.0-beta.2](https://github.com/react-native-maps/react-native-maps/compare/v1.3.0-beta.1...v1.3.0-beta.2) (2022-08-12) ### Bug Fixes * **ios-google:** ci... — committed to osk-poita121/react-native-maps by semantic-release-bot 2 years ago
- chore(release): 1.3.0 [skip ci] # [1.3.0](https://github.com/react-native-maps/react-native-maps/compare/v1.2.0...v1.3.0) (2022-08-22) ### Bug Fixes * **android:** onLayout not being called ([#4404... — committed to osk-poita121/react-native-maps by semantic-release-bot 2 years ago
- chore(release): 1.3.0-beta.2 [skip ci] # [1.3.0-beta.2](https://github.com/react-native-maps/react-native-maps/compare/v1.3.0-beta.1...v1.3.0-beta.2) (2022-08-12) ### Bug Fixes * **ios-google:** ci... — committed to GoldenDragon0710/google-map-react-native by GoldenDragon0710 2 years ago
- chore(release): 1.3.0 [skip ci] # [1.3.0](https://github.com/react-native-maps/react-native-maps/compare/v1.2.0...v1.3.0) (2022-08-22) ### Bug Fixes * **android:** onLayout not being called ([#4404... — committed to GoldenDragon0710/google-map-react-native by GoldenDragon0710 2 years ago
- chore(release): 1.3.0-beta.2 [skip ci] # [1.3.0-beta.2](https://github.com/react-native-maps/react-native-maps/compare/v1.3.0-beta.1...v1.3.0-beta.2) (2022-08-12) ### Bug Fixes * **ios-google:** ci... — committed to PainStaker0331/react-native-maps by PainStaker0331 2 years ago
- chore(release): 1.3.0 [skip ci] # [1.3.0](https://github.com/react-native-maps/react-native-maps/compare/v1.2.0...v1.3.0) (2022-08-22) ### Bug Fixes * **android:** onLayout not being called ([#4404... — committed to PainStaker0331/react-native-maps by PainStaker0331 2 years ago
- chore(release): 1.3.0-beta.2 [skip ci] # [1.3.0-beta.2](https://github.com/react-native-maps/react-native-maps/compare/v1.3.0-beta.1...v1.3.0-beta.2) (2022-08-12) ### Bug Fixes * **ios-google:** ci... — committed to Super-CodeKing/react_native_map by Super-CodeKing 2 years ago
- chore(release): 1.3.0 [skip ci] # [1.3.0](https://github.com/react-native-maps/react-native-maps/compare/v1.2.0...v1.3.0) (2022-08-22) ### Bug Fixes * **android:** onLayout not being called ([#4404... — committed to Super-CodeKing/react_native_map by Super-CodeKing 2 years ago
Any news from this? Im with the same problem.
@wdhilliard If any one of you are dealing with the blue fill color on iOS. here is my workaround.
In node_modules/react-native-maps/lib/ios/AirGoogleMaps/AIRGoogleMapPolygon.m, add this after
_polygon = [[AIRGMSPolygon alloc] init];i just tried circle, it has the same issue
As you might have guessed from the comment above, I decided to work around the quirks of the Google SDK and implement a fix directly in
react-native-maps. Could you please try out the beta version and report back to me if it fixes the issue?I wasn’t satisfied with the workaround as it still introduces a flash of default blue before the polygon updates, so I did some experimenting and found some leads. Maybe someone with more iOS experience than I have can chime in, but it’s looking like something in the realm of an async/threading race condition to me.
First, the temporary fix: insert a short delay before the polygon gets added to the map here: https://github.com/react-native-community/react-native-maps/blob/master/lib/ios/AirGoogleMaps/AIRGoogleMap.m#L135-L136
I changed to:
I initially tried only a
dispatch_async, but found that the below code still showed default blue polygons sometimes (most of the time it worked though):I’m going to patch-package for now as I don’t think this is the actual fix, but I’m hoping some iOS dev out there can identify the underlying issue take it over the finish line.
tested with new react-native-maps 0.31.0 and GoogleMaps 6.1.1. Same issue
Here the polygons were rendered on the second render with blue/purple fill. Initial render was always using the provided fillcolor. It only happened on iOS, but probably not the older iOS version.
We “resolved” it, by using the 2.5.0 pods with version 0.26.1. So far, there are no problems. (Android works fine without any adjustments.)
To make the patch persisintent we added a postinstall script to npm to copy the following file to
./node_modules/react-native-maps/react-native-google-maps.podspec:The workaround https://github.com/react-native-community/react-native-maps/issues/3025#issuecomment-538345230 appears to work in all versions of GoogleMaps 3.+ as long the wrapper component sets a property with a non null value on any visible element. I have updated the demo code to toggle the wrapper with a single button.
It seams like that we should not wait for an update of the GoogelMaps pod, but that there is a tiny bug in the iOS code here. Any ideas where to start investigating?
Yes it’s a super annoying problem for us since we need GoogleMaps 3+ to have geolocation services working right in our app and we can’t go backward. Hope a fix will come out sooner than later
I wonder how many more years will this take to fix since reproducing it is so easy 😢
I filed an issue with Google IssueTracker here: https://issuetracker.google.com/issues/218789650
we’re facing this issue too while using the
<Geojson/>component!setNativePropswont work for us in that case since we’ll have to get the ref for each of the<Polygon>components being rendered by the Geojson component.I continue to have this same issue with Polygons and Circles. Props work half the time. Using v0.28.0, which includes changes from @ddarren , the problem still persists. The “workarounds” using setNativeProps, while ultimately displaying the correct color are not a fix as the correct props are not applied on first render. This results in a flash of the blue styles and then a correction to the styles defined in props
Adding comment to keep this issue alive, unless someone can tell it’s fixed.
I’m experiencing the same problem on the project I’m working on with react-native-maps version 0.26.1 , as a temporal fix I applied this solution: https://github.com/react-native-community/react-native-maps/issues/3025#issuecomment-522968087
Although, on the project, we have one specific case where it’s not working 100% perfect (sometimes it shows the correct styles, sometimes it doesn’t), but as temporal fix, we can cope with it…
Does anybody know if this bug related with Google Maps is already being addressed and an official solution will arrive soon? If I’m not mistaken, this is happening since July 2019 (v0.25.0) 😕
@rborn I have just tested it with GoogleMaps 3.5.0, but this reintroduced the bug. Before we went backwards and tested with the versions we found in the commits. 3.2.0, 3.1.0 and 3.0.3 did not work, but 2.5.0 did.
According to the changelog, the bug was introduced/documented with 3.0.0. I did not find any indication that it is resolved yet. Nor did I find it in the issue tracker to verify its status. Maybe it is related to that issue.
Now after reading through the changelog we tested 2.7.0 and this works fine so far. So we will keep that for the time beeing.
I am not sure if that should be patched by just reverting the version number back to 2.7.0. There are probably some valid use cases that do not need correctly rendered polygons but depend on some features of version 3.