Skip to content

Commit

Permalink
fix(iOS): removing polylines on iOS with googleProvider (react-native…
Browse files Browse the repository at this point in the history
…-maps#4973)

* fix: removing polylines on ios with googleProvider

* chore: code format
  • Loading branch information
mateki0 committed Mar 11, 2024
1 parent 2eb4492 commit 6603060
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
1 change: 1 addition & 0 deletions ios/AirGoogleMaps/AIRGoogleMapPolyline.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
@property (nonatomic, strong) AIRGMSPolyline *polyline;
@property (nonatomic, strong) NSArray<AIRMapCoordinate *> *coordinates;
@property (nonatomic, copy) RCTBubblingEventBlock onPress;
@property (nonatomic, strong) GMSMapView *originalMap;

@property (nonatomic, strong) UIColor *strokeColor;
@property (nonatomic, strong) NSArray<UIColor *> *strokeColors;
Expand Down
16 changes: 15 additions & 1 deletion ios/AirGoogleMaps/AIRGoogleMapPolyline.m
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,25 @@ -(void)setCoordinates:(NSArray<AIRMapCoordinate *> *)coordinates
_coordinates = coordinates;

GMSMutablePath *path = [GMSMutablePath path];
for(int i = 0; i < coordinates.count; i++)

if (!coordinates || coordinates.count == 0)
{
_polyline.map = nil; // Remove polyline from the map
return;
}

for (int i = 0; i < coordinates.count; i++) {
[path addCoordinate:coordinates[i].coordinate];
}

if (!_originalMap) {
_originalMap = _polyline.map; // Store the original map
}

if (!_polyline.map) {
_polyline.map = _originalMap;
}

_polyline.path = path;

[self configureStyleSpansIfNeeded];
Expand Down

0 comments on commit 6603060

Please sign in to comment.