Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
76a7779
added pointForMeters implemetention for iOS.
klaes-ashford Feb 5, 2020
27ebbcc
added integration test for pointForMeters
klaes-ashford Feb 5, 2020
e45832f
updated changelog and version.
klaes-ashford Feb 5, 2020
f0be831
resolved conflicts and updated changelog and version.
klaes-ashford Feb 5, 2020
f1264b4
applied flutter_plugin_tools formatter patch to fix formatting issues.
klaes-ashford Feb 5, 2020
89c2f51
resolved conflicts from upstream master
Apr 28, 2020
d7898d5
moved getDistance to platform_interface
Apr 28, 2020
a1ef77c
fixed interface and implementation for getDistance.
Apr 28, 2020
4590704
added get distance to controller and tests.
Apr 28, 2020
9fc32e5
fixed syntax issue in getDistance in controller
Apr 28, 2020
f5babcd
formatted using flutter_plugin_tools
Apr 28, 2020
09694ce
bumped google_maps_flutter_platform_interface to 1.0.2
Apr 28, 2020
4aaef50
updated getDistance test to not use hardcoded pointForMeters
Apr 28, 2020
2b80e0b
updated google_maps_flutter_platform_interface to use relative path.
Apr 28, 2020
d56f01d
renamed getDistance to getPoint.
Apr 28, 2020
56a4363
remove relative path for google_maps_flutter_platform_interface
Apr 28, 2020
f1af845
added getpoint to support projection method pointForMeters in iOS.
Apr 29, 2020
4ec34a1
method renamed to getPointsForMeters to closely follow native API
May 2, 2020
0a59700
formatted the dart files.
May 2, 2020
0560b5a
resolved conflicts from getPoint branch.
May 2, 2020
8750952
method renamed to getPointsForMeters to closely follow native API
May 2, 2020
8b611e8
formatted the dart files.
May 2, 2020
bad59e1
Update pubspec.yaml
ditman May 4, 2020
1f9cdea
Merge branch 'master' of https://github.com/flutter/plugins
May 5, 2020
b46e906
skip testGetPointsForMeters if not iOS implemented.
May 5, 2020
aa33f19
conflict resolved.
May 15, 2020
1f23ead
bumped minor version.
May 15, 2020
347f172
resolved conflicts
May 15, 2020
500b775
resolved conflicts
May 15, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions packages/google_maps_flutter/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 0.5.22+2

* Support projection method pointForMeters to get the distance in meters to content size
from the specified LatLng in the map.

## 0.5.22+1

* Fix for toggling traffic layer on Android not working
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -718,6 +718,35 @@ void main() {
expect(topLeft, const ScreenCoordinate(x: 0, y: 0));
});

testWidgets('testGetDistance', (WidgetTester tester) async {
final Key key = GlobalKey();
final Completer<GoogleMapController> controllerCompleter =
Completer<GoogleMapController>();

await tester.pumpWidget(Directionality(
textDirection: TextDirection.ltr,
child: GoogleMap(
key: key,
initialCameraPosition: _kInitialCameraPosition,
onMapCreated: (GoogleMapController controller) {
controllerCompleter.complete(controller);
},
),
));
final GoogleMapController controller = await controllerCompleter.future;

// We suspected a bug in the iOS Google Maps SDK caused the camera is not properly positioned at
// initialization. https://github.com/flutter/flutter/issues/24806
// This temporary workaround fix is provided while the actual fix in the Google Maps SDK is
// still being investigated.
// TODO(cyanglaz): Remove this temporary fix once the Maps SDK issue is resolved.
// https://github.com/flutter/flutter/issues/27550
await tester.pumpAndSettle(const Duration(seconds: 3));

final double distance = await controller.getDistance(1, _kInitialMapCenter);
expect(distance, 0.00020464534463826567);
Comment thread
klaes-ashford marked this conversation as resolved.
Outdated
});

testWidgets('testResizeWidget', (WidgetTester tester) async {
final Completer<GoogleMapController> controllerCompleter =
Completer<GoogleMapController>();
Expand Down
12 changes: 12 additions & 0 deletions packages/google_maps_flutter/ios/Classes/GoogleMapController.m
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,18 @@ - (void)onMethodCall:(FlutterMethodCall*)call result:(FlutterResult)result {
message:@"getLatLng called prior to map initialization"
details:nil]);
}
} else if ([call.method isEqualToString:@"map#getDistance"]) {
if (_mapView != nil) {
CLLocationDistance meter = ToDouble(call.arguments[@"meter"]);
CLLocationCoordinate2D location =
[FLTGoogleMapJsonConversions toLocation:call.arguments[@"location"]];
CGFloat distance = [_mapView.projection pointsForMeters:meter atCoordinate:location];
result(@(distance));
} else {
result([FlutterError errorWithCode:@"GoogleMap uninitialized"
message:@"getPoints called prior to map initialization"
details:nil]);
}
} else if ([call.method isEqualToString:@"map#waitForMap"]) {
result(nil);
} else if ([call.method isEqualToString:@"markers#update"]) {
Expand Down
11 changes: 11 additions & 0 deletions packages/google_maps_flutter/lib/src/controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -236,4 +236,15 @@ class GoogleMapController {
'map#getLatLng', screenCoordinate._toJson());
return LatLng(latLng[0], latLng[1]);
}

/// Returns [double] corresponding to the distance in meters of the [LatLng] in the current map view.
///
/// Return NaN (Not-a-Number) if unable to get distance in meters.
/// This is only accurate for small Earth distances.
Future<double> getDistance(double meters, LatLng latLng) async {
Comment thread
klaes-ashford marked this conversation as resolved.
Outdated
final double distance = await channel.invokeMethod<double>(
'map#getDistance',
<String, dynamic>{"meter": meters, "location": latLng._toJson()});
return distance;
Comment thread
klaes-ashford marked this conversation as resolved.
Outdated
}
}
2 changes: 1 addition & 1 deletion packages/google_maps_flutter/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: google_maps_flutter
description: A Flutter plugin for integrating Google Maps in iOS and Android applications.
homepage: https://github.com/flutter/plugins/tree/master/packages/google_maps_flutter
version: 0.5.22+1
version: 0.5.22+2
Comment thread
klaes-ashford marked this conversation as resolved.
Outdated

dependencies:
flutter:
Expand Down