This repository was archived by the owner on Feb 22, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9.8k
Support Hybrid Composition through the GoogleMaps Widget #4082
Merged
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
b17d1dc
start
bparrishMines 82c4614
change to hybrid composition in example
bparrishMines 7b6f801
UPdate readme
bparrishMines 736c073
Merge branch 'master' of github.com:flutter/plugins into android_maps
bparrishMines f6631b4
update README and remove unnecessary line
bparrishMines 50b548e
Merge branch 'master' of github.com:flutter/plugins into android_maps
bparrishMines 944d965
use buildViewWithTextDirection by default
bparrishMines e345f3a
remove hash
bparrishMines 1809e66
add default value if no directionality ancestor
bparrishMines f504ffc
remove mactro
bparrishMines be87b94
change text direction to layout direction
bparrishMines cf87583
Merge branch 'master' of github.com:flutter/plugins into android_maps
bparrishMines d907845
create android settings class
bparrishMines 58c3028
update readme
bparrishMines 0c26d6c
Update google_map.dart
bparrishMines 86f965c
Merge branch 'master' of github.com:flutter/plugins into android_maps
bparrishMines 35a8186
Merge branch 'master' of github.com:flutter/plugins into android_maps
bparrishMines 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
5 changes: 5 additions & 0 deletions
5
packages/google_maps_flutter/google_maps_flutter/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
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 |
---|---|---|
|
@@ -38,6 +38,44 @@ class UnknownMapObjectIdError extends Error { | |
} | ||
} | ||
|
||
/// Android specific settings for [GoogleMap]. | ||
class AndroidGoogleMapsFlutter { | ||
/// Whether to render [GoogleMap] with a [AndroidViewSurface] to build the Google Maps widget. | ||
/// | ||
/// This implementation uses hybrid composition to render the Google Maps | ||
/// Widget on Android. This comes at the cost of some performance on Android | ||
/// versions below 10. See | ||
/// https://flutter.dev/docs/development/platform-integration/platform-views#performance for more | ||
/// information. | ||
/// | ||
/// Defaults to false. | ||
static bool get useAndroidViewSurface { | ||
final GoogleMapsFlutterPlatform platform = | ||
GoogleMapsFlutterPlatform.instance; | ||
if (platform is MethodChannelGoogleMapsFlutter) { | ||
return platform.useAndroidViewSurface; | ||
} | ||
return false; | ||
} | ||
|
||
/// Set whether to render [GoogleMap] with a [AndroidViewSurface] to build the Google Maps widget. | ||
/// | ||
/// This implementation uses hybrid composition to render the Google Maps | ||
/// Widget on Android. This comes at the cost of some performance on Android | ||
/// versions below 10. See | ||
/// https://flutter.dev/docs/development/platform-integration/platform-views#performance for more | ||
/// information. | ||
/// | ||
/// Defaults to false. | ||
static set useAndroidViewSurface(bool useAndroidViewSurface) { | ||
final GoogleMapsFlutterPlatform platform = | ||
GoogleMapsFlutterPlatform.instance; | ||
if (platform is MethodChannelGoogleMapsFlutter) { | ||
platform.useAndroidViewSurface = useAndroidViewSurface; | ||
} | ||
} | ||
} | ||
|
||
/// A widget which displays a map with data obtained from the Google Maps service. | ||
class GoogleMap extends StatefulWidget { | ||
/// Creates a widget displaying data from Google Maps services. | ||
|
@@ -61,6 +99,7 @@ class GoogleMap extends StatefulWidget { | |
this.tiltGesturesEnabled = true, | ||
this.myLocationEnabled = false, | ||
this.myLocationButtonEnabled = true, | ||
this.layoutDirection, | ||
|
||
/// If no padding is specified default padding will be 0. | ||
this.padding = const EdgeInsets.all(0), | ||
|
@@ -100,6 +139,12 @@ class GoogleMap extends StatefulWidget { | |
/// Type of map tiles to be rendered. | ||
final MapType mapType; | ||
|
||
/// The layout direction to use for the embedded view. | ||
/// | ||
/// If this is null, the ambient [Directionality] is used instead. If there is | ||
/// no ambient [Directionality], [TextDirection.ltr] is used. | ||
final TextDirection? layoutDirection; | ||
|
||
/// Preferred bounds for the camera zoom level. | ||
/// | ||
/// Actual bounds depend on map data and device. | ||
|
@@ -250,9 +295,12 @@ class _GoogleMapState extends State<GoogleMap> { | |
|
||
@override | ||
Widget build(BuildContext context) { | ||
return GoogleMapsFlutterPlatform.instance.buildView( | ||
return GoogleMapsFlutterPlatform.instance.buildViewWithTextDirection( | ||
_mapId, | ||
onPlatformViewCreated, | ||
textDirection: widget.layoutDirection ?? | ||
Directionality.maybeOf(context) ?? | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This may return |
||
TextDirection.ltr, | ||
initialCameraPosition: widget.initialCameraPosition, | ||
markers: widget.markers, | ||
polygons: widget.polygons, | ||
|
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would expect this to be a MethodChannelGoogleMapsFlutter subclass. I guess we can add that later without it being a breaking change though, and doing it now would have registration complexities since we don't have
dartPluginClass
support for mobile on stable yet.