-
Notifications
You must be signed in to change notification settings - Fork 3.6k
[google_maps_flutter] Implement polyline patterns in google maps ios #5757
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
48 commits
Select commit
Hold shift + click to select a range
9af4bad
Implement polyline in google maps ios
Hari-07 b6c0d6a
Updated changelog
Hari-07 5652138
Add . to changelog
Hari-07 3b3f7ac
Implement tests
Hari-07 8729818
Fix formatting in test files
Hari-07 a4fdeaa
Add license text
Hari-07 d184edd
Revert merge changelog mess
Hari-07 5859fd2
Run update-release-info
Hari-07 1a314d8
Use floating point value for length
Hari-07 98669dd
Comment explaining cannot use isequal
Hari-07 00ea572
Add new test file to xcode project
Hari-07 937a030
Add period to comment
Hari-07 91439c5
Set version in pubspec
Hari-07 ef1d1a6
Make the polyline controller test stateless
Hari-07 5c6a694
Remove empty line
Hari-07 cb7b9ea
Dont make polyline controller public
Hari-07 762741e
add comments and avoid making get path public
Hari-07 90537da
Fix test
Hari-07 76b3d59
Add stroke style json conversion test
Hari-07 c10082c
Fix formatting issue in new test
Hari-07 28a7840
Format comment
Hari-07 41e4a2c
Update changelog
Hari-07 ef19218
Remove android changelog comment
Hari-07 25e003e
Fix some of the comments
Hari-07 6d7f7c1
Use helper function to extract nullable field from dict
Hari-07 2a58ab9
Revert path for polyline into static function
Hari-07 8428c96
Specify the type more
Hari-07 4eca5a6
Remove on ios in changelog
Hari-07 3975be2
Move the header file
Hari-07 0daeda6
Remove test temporarily
Hari-07 a1daf7a
Merge branch 'main' of github.com:flutter/packages into polyline-patt…
Hari-07 3506885
Add back tests
Hari-07 64006eb
Add back changelog change
Hari-07 9649254
Bump pubspec version
Hari-07 4b3ddad
Add polyline test file to xcode
Hari-07 e605cb4
Fix comment style and use fast iteration
Hari-07 c984efb
Fix some formatting
Hari-07 c5f2bb3
Rename and cleanup
Hari-07 9d8bdcd
Comment on test method
Hari-07 2e31f57
Make getvalue or nil static
Hari-07 3d2a257
Run format tool again
Hari-07 f91bf90
Merge branch 'main' of github.com:flutter/packages into polyline-patt…
Hari-07 01b1b62
Stop using deprecated method
Hari-07 7e8d346
Add some more missing types
Hari-07 3d83dad
Fix formatting issue
Hari-07 a6abf68
Remove extra line around comments
Hari-07 26aba97
Make test header public
Hari-07 cf68784
Merge branch 'main' of github.com:flutter/packages into polyline-patt…
Hari-07 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
packages/google_maps_flutter/google_maps_flutter_ios/CHANGELOG.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 81 additions & 0 deletions
81
...oogle_maps_flutter_ios/example/ios14/ios/RunnerTests/GoogleMapsPolylinesControllerTests.m
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
| // Copyright 2013 The Flutter Authors. All rights reserved. | ||
| // Use of this source code is governed by a BSD-style license that can be | ||
| // found in the LICENSE file. | ||
|
|
||
| @import google_maps_flutter_ios; | ||
| @import google_maps_flutter_ios.Test; | ||
| @import XCTest; | ||
| @import GoogleMaps; | ||
|
|
||
| #import <OCMock/OCMock.h> | ||
| #import <google_maps_flutter_ios/GoogleMapPolylineController_Test.h> | ||
| #import "PartiallyMockedMapView.h" | ||
|
|
||
| @interface GoogleMapsPolylinesControllerTests : XCTestCase | ||
| @end | ||
|
|
||
| @implementation GoogleMapsPolylinesControllerTests | ||
|
|
||
| /// Returns GoogleMapPolylineController object instantiated with a mocked map instance | ||
| /// | ||
| /// @return An object of FLTGoogleMapPolylineController | ||
| - (FLTGoogleMapPolylineController *)polylineControllerWithMockedMap { | ||
| NSDictionary<NSString *, id> *polyline = @{ | ||
| @"points" : @[ | ||
| @[ @(52.4816), @(-3.1791) ], @[ @(54.043), @(-2.9925) ], @[ @(54.1396), @(-4.2739) ], | ||
| @[ @(53.4153), @(-4.0829) ] | ||
| ], | ||
| @"polylineId" : @"polyline_id_0", | ||
| }; | ||
|
|
||
| CGRect frame = CGRectMake(0, 0, 100, 100); | ||
| GMSCameraPosition *camera = [[GMSCameraPosition alloc] initWithLatitude:0 longitude:0 zoom:0]; | ||
|
|
||
| GMSMapViewOptions *mapViewOptions = [[GMSMapViewOptions alloc] init]; | ||
| mapViewOptions.frame = frame; | ||
| mapViewOptions.camera = camera; | ||
|
|
||
| PartiallyMockedMapView *mapView = [[PartiallyMockedMapView alloc] initWithOptions:mapViewOptions]; | ||
|
|
||
| GMSMutablePath *path = [FLTPolylinesController pathForPolyline:polyline]; | ||
| NSString *identifier = polyline[@"polylineId"]; | ||
|
|
||
| FLTGoogleMapPolylineController *polylineControllerWithMockedMap = | ||
| [[FLTGoogleMapPolylineController alloc] initPolylineWithPath:path | ||
| identifier:identifier | ||
| mapView:mapView]; | ||
|
|
||
| return polylineControllerWithMockedMap; | ||
| } | ||
|
|
||
| - (void)testSetPatterns { | ||
| NSArray<GMSStrokeStyle *> *styles = @[ | ||
| [GMSStrokeStyle solidColor:[UIColor clearColor]], [GMSStrokeStyle solidColor:[UIColor redColor]] | ||
| ]; | ||
|
|
||
| NSArray<NSNumber *> *lengths = @[ @10, @10 ]; | ||
|
|
||
| FLTGoogleMapPolylineController *polylineController = [self polylineControllerWithMockedMap]; | ||
|
|
||
| XCTAssertNil(polylineController.polyline.spans); | ||
|
|
||
| [polylineController setPattern:styles lengths:lengths]; | ||
|
|
||
| // `GMSStyleSpan` doesn't implement `isEqual` so cannot be compared by value at present. | ||
| XCTAssertNotNil(polylineController.polyline.spans); | ||
| } | ||
|
|
||
| - (void)testStrokeStylesFromPatterns { | ||
| NSArray<NSArray<id> *> *patterns = @[ @[ @"gap", @10 ], @[ @"dash", @10 ] ]; | ||
| UIColor *strokeColor = [UIColor redColor]; | ||
|
|
||
| NSArray<GMSStrokeStyle *> *patternStrokeStyle = | ||
| [FLTGoogleMapJSONConversions strokeStylesFromPatterns:patterns strokeColor:strokeColor]; | ||
|
|
||
| XCTAssertEqual([patternStrokeStyle count], 2); | ||
|
|
||
| // None of the parameters of `patternStrokeStyle` is observable, so we limit to testing | ||
| // the length of this output array. | ||
| } | ||
|
|
||
| @end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
...oogle_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapPolylineController_Test.h
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| // Copyright 2013 The Flutter Authors. All rights reserved. | ||
| // Use of this source code is governed by a BSD-style license that can be | ||
| // found in the LICENSE file. | ||
|
|
||
| #import "GoogleMapPolylineController.h" | ||
|
|
||
| /// Internal APIs exposed for unit testing | ||
| @interface FLTGoogleMapPolylineController (Test) | ||
|
|
||
| /// Polyline instance the controller is attached to | ||
| @property(strong, nonatomic) GMSPolyline *polyline; | ||
|
|
||
| @end | ||
|
|
||
| /// Internal APIs explosed for unit testing | ||
| @interface FLTPolylinesController (Test) | ||
|
|
||
| /// Returns the path for polyline based on the points(locations) the polyline has. | ||
| /// | ||
| /// @param polyline The polyline instance for which path is calculated. | ||
| /// @return An instance of GMSMutablePath. | ||
| + (GMSMutablePath *)pathForPolyline:(NSDictionary *)polyline; | ||
|
|
||
| @end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.