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 all 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/google_maps_flutter/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 0.5.28

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

## 0.5.27+3

* iOS: Update the gesture recognizer blocking policy to "WaitUntilTouchesEnded", which fixes the camera idle callback not triggered issue.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import 'dart:async';
import 'dart:io';
import 'dart:math';
import 'dart:typed_data';

import 'package:e2e/e2e.dart';
Expand Down Expand Up @@ -832,6 +833,39 @@ void main() {
expect(topLeft, const ScreenCoordinate(x: 0, y: 0));
});

testWidgets('testGetPointsForMeters', (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;

await tester.pumpAndSettle();
// TODO(cyanglaz): Remove this after we added `mapRendered` callback, and `mapControllerCompleter.complete(controller)` above should happen
// in `mapRendered`.
// https://github.com/flutter/flutter/issues/54758
await Future.delayed(Duration(seconds: 1));

final double points =
await controller.getPointsForMeters(1, _kInitialCameraPosition.target);
// Formula is from Chris Broadfoot's comment : https://groups.google.com/d/msg/google-maps-js-api-v3/hDRO4oHVSeM/osOYQYXg2oUJ
final double meters_per_pixel = 156543.03392 *
cos(_kInitialCameraPosition.target.latitude * pi / 180) /
pow(2, _kInitialZoomLevel);
final double points_per_meter = 1 / meters_per_pixel;
expect(points, moreOrLessEquals(points_per_meter, epsilon: 1e-5));
}, skip: !Platform.isIOS);

testWidgets('testResizeWidget', (WidgetTester tester) async {
final Completer<GoogleMapController> controllerCompleter =
Completer<GoogleMapController>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,18 @@ - (void)onMethodCall:(FlutterMethodCall*)call result:(FlutterResult)result {
message:@"getLatLng called prior to map initialization"
details:nil]);
}
} else if ([call.method isEqualToString:@"projection#getPointsForMeters"]) {
if (_mapView != nil) {
CLLocationDistance meter = ToDouble(call.arguments[@"meter"]);
CLLocationCoordinate2D location =
[FLTGoogleMapJsonConversions toLocation:call.arguments[@"location"]];
CGFloat points = [_mapView.projection pointsForMeters:meter atCoordinate:location];
result(@(points));
} else {
result([FlutterError errorWithCode:@"GoogleMap uninitialized"
message:@"getPointsForMeters called prior to map initialization"
details:nil]);
}
} else if ([call.method isEqualToString:@"map#waitForMap"]) {
result(nil);
} else if ([call.method isEqualToString:@"map#takeSnapshot"]) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,12 @@ class GoogleMapController {
return _googleMapsFlutterPlatform.getZoomLevel(mapId: mapId);
}

/// Converts a distance in meters to content size.
Future<double> getPointsForMeters(double meters, LatLng latLng) {
return _googleMapsFlutterPlatform.getPointsForMeters(meters, latLng,
mapId: mapId);
}

/// Returns the image bytes of the map
Future<Uint8List> takeSnapshot() {
return _googleMapsFlutterPlatform.takeSnapshot(mapId: mapId);
Expand Down
5 changes: 3 additions & 2 deletions packages/google_maps_flutter/google_maps_flutter/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
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/google_maps_flutter
version: 0.5.27+3
version: 0.5.28

dependencies:
flutter:
sdk: flutter
flutter_plugin_android_lifecycle: ^1.0.0
google_maps_flutter_platform_interface: ^1.0.1
google_maps_flutter_platform_interface:
path: ../google_maps_flutter_platform_interface

dev_dependencies:
flutter_test:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 1.1.0

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

## 1.0.2

* Update lower bound of dart dependency to 2.1.0.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,14 @@ class MethodChannelGoogleMapsFlutter extends GoogleMapsFlutterPlatform {
return channel(mapId).invokeMethod<double>('map#getZoomLevel');
}

/// Converts a distance in meters to content size.
Future<double> getPointsForMeters(double meters, LatLng latLng,
{@required int mapId}) {
assert(meters != null && latLng != null);
return channel(mapId).invokeMethod<double>('projection#getPointsForMeters',
<String, dynamic>{"meter": meters, "location": latLng.toJson()});
}

/// Returns the image bytes of the map
@override
Future<Uint8List> takeSnapshot({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,12 @@ abstract class GoogleMapsFlutterPlatform extends PlatformInterface {
throw UnimplementedError('getZoomLevel() has not been implemented.');
}

/// Converts a distance in meters to content size.
Future<double> getPointsForMeters(double meters, LatLng latLng,
{@required int mapId}) {
throw UnimplementedError('getPointsForMeters() has not been implemented.');
}

/// Returns the image bytes of the map
Future<Uint8List> takeSnapshot({
@required int mapId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ description: A common platform interface for the google_maps_flutter plugin.
homepage: https://github.com/flutter/plugins/tree/master/packages/google_maps_flutter/google_maps_flutter_platform_interface
# NOTE: We strongly prefer non-breaking changes, even at the expense of a
# less-clean API. See https://flutter.dev/go/platform-interface-breaking-changes
version: 1.0.2
version: 1.1.0

dependencies:
flutter:
Expand Down