Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 2.14.2

* Adds `onMapLoaded` callback.

## 2.14.1

* Replaces internal use of deprecated methods.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,7 @@ class MapUiBodyState extends State<MapUiBody> {
myLocationButtonEnabled: _myLocationButtonEnabled,
trafficEnabled: _myTrafficEnabled,
onCameraMove: _updateCameraPosition,
onMapLoaded: onMapLoaded,
);

final columnChildren = <Widget>[
Expand Down Expand Up @@ -407,6 +408,12 @@ class MapUiBodyState extends State<MapUiBody> {
});
}

void onMapLoaded() {
ScaffoldMessenger.of(
context,
).showSnackBar(const SnackBar(content: Text('Map is loaded')));
}

void onMapCreated(GoogleMapController controller) {
setState(() {
_controller = controller;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,10 @@ flutter:
uses-material-design: true
assets:
- assets/
# FOR TESTING AND INITIAL REVIEW ONLY. DO NOT MERGE.
# See https://github.com/flutter/flutter/blob/master/docs/ecosystem/contributing/README.md#changing-federated-plugins
dependency_overrides:
google_maps_flutter_android: {path: ../../../../packages/google_maps_flutter/google_maps_flutter_android}
google_maps_flutter_ios: {path: ../../../../packages/google_maps_flutter/google_maps_flutter_ios}
google_maps_flutter_platform_interface: {path: ../../../../packages/google_maps_flutter/google_maps_flutter_platform_interface}
google_maps_flutter_web: {path: ../../../../packages/google_maps_flutter/google_maps_flutter_web}
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,11 @@ class GoogleMapController {
.onClusterTap(mapId: mapId)
.listen((ClusterTapEvent e) => _googleMapState.onClusterTap(e.value)),
);
_streamSubscriptions.add(
GoogleMapsFlutterPlatform.instance
.onMapLoaded(mapId: mapId)
.listen((_) => _googleMapState.onMapLoaded()),
);
}

/// Updates configuration options of the map user interface.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ class GoogleMap extends StatefulWidget {
this.onCameraIdle,
this.onTap,
this.onLongPress,
this.onMapLoaded,
this.cloudMapId,
});

Expand Down Expand Up @@ -290,6 +291,13 @@ class GoogleMap extends StatefulWidget {
/// Called every time a [GoogleMap] is long pressed.
final ArgumentCallback<LatLng>? onLongPress;

/// Called when the tiles have been loaded.
///
/// This implementation maps to [Map.tilesloaded](https://developers.google.com/maps/documentation/javascript/reference/map#Map.tilesloaded) on Web,
/// [GoogleMap.OnMapLoadedCallback](https://developers.google.com/android/reference/com/google/android/gms/maps/GoogleMap.OnMapLoadedCallback) on Android,
/// and [GMSMapViewDelegate.mapViewDidFinishTileRendering](https://developers.google.com/maps/documentation/ios-sdk/reference/objc/Protocols/GMSMapViewDelegate#-mapviewdidfinishtilerendering:) on iOS.
final VoidCallback? onMapLoaded;

/// True if a "My Location" layer should be shown on the map.
///
/// This layer includes a location indicator at the current device location,
Expand Down Expand Up @@ -696,6 +704,13 @@ class _GoogleMapState extends State<GoogleMap> {
onClusterTap(cluster);
}
}

void onMapLoaded() {
final VoidCallback? onMapLoaded = widget.onMapLoaded;
if (onMapLoaded != null) {
onMapLoaded();
}
}
}

/// Builds a [MapConfiguration] from the given [map].
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: google_maps_flutter
description: A Flutter plugin for integrating Google Maps in iOS and Android applications.
repository: https://github.com/flutter/packages/tree/main/packages/google_maps_flutter/google_maps_flutter
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+maps%22
version: 2.14.1
version: 2.14.2

environment:
sdk: ^3.8.0
Expand Down Expand Up @@ -41,3 +41,10 @@ topics:
# The example deliberately includes limited-use secrets.
false_secrets:
- /example/web/index.html
# FOR TESTING AND INITIAL REVIEW ONLY. DO NOT MERGE.
# See https://github.com/flutter/flutter/blob/master/docs/ecosystem/contributing/README.md#changing-federated-plugins
dependency_overrides:
google_maps_flutter_android: {path: ../../../packages/google_maps_flutter/google_maps_flutter_android}
google_maps_flutter_ios: {path: ../../../packages/google_maps_flutter/google_maps_flutter_ios}
google_maps_flutter_platform_interface: {path: ../../../packages/google_maps_flutter/google_maps_flutter_platform_interface}
google_maps_flutter_web: {path: ../../../packages/google_maps_flutter/google_maps_flutter_web}
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,11 @@ class FakeGoogleMapsFlutterPlatform extends GoogleMapsFlutterPlatform {
return mapEventStreamController.stream.whereType<GroundOverlayTapEvent>();
}

@override
Stream<MapLoadedEvent> onMapLoaded({required int mapId}) {
return mapEventStreamController.stream.whereType<MapLoadedEvent>();
}

@override
void dispose({required int mapId}) {
disposed = true;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 2.18.9

* Adds support for `onMapLoaded` callback.

## 2.18.8

* Bumps com.google.maps.android:android-maps-utils from 3.6.0 to 3.19.1.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ class GoogleMapController
ClusterManager.OnClusterItemClickListener<MarkerBuilder>,
ClusterManagersController.OnClusterItemRendered<MarkerBuilder>,
DefaultLifecycleObserver,
GoogleMap.OnMapLoadedCallback,
GoogleMapListener,
GoogleMapOptionsSink,
MapsApi,
Expand Down Expand Up @@ -239,6 +240,7 @@ public void onMapReady(@NonNull GoogleMap googleMap) {
updateMapStyle(initialMapStyle);
initialMapStyle = null;
}
googleMap.setOnMapLoadedCallback(this);
}

// Returns the first TextureView found in the view hierarchy.
Expand Down Expand Up @@ -343,6 +345,11 @@ public void onCameraIdle() {
flutterApi.onCameraIdle(new NoOpVoidResult());
}

@Override
public void onMapLoaded() {
flutterApi.onMapLoaded(new NoOpVoidResult());
}

@Override
public boolean onMarkerClick(Marker marker) {
return markersController.onMapsMarkerTap(marker.getId());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright 2013 The Flutter Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Autogenerated from Pigeon (v26.1.0), do not edit directly.
// Autogenerated from Pigeon (v26.1.5), do not edit directly.
// See also: https://pub.dev/packages/pigeon

package io.flutter.plugins.googlemaps;
Expand Down Expand Up @@ -7683,6 +7683,30 @@ public void onGroundOverlayTap(@NonNull String groundOverlayIdArg, @NonNull Void
}
});
}
/** Called when the map is fully loaded. */
public void onMapLoaded(@NonNull VoidResult result) {
final String channelName =
"dev.flutter.pigeon.google_maps_flutter_android.MapsCallbackApi.onMapLoaded"
+ messageChannelSuffix;
BasicMessageChannel<Object> channel =
new BasicMessageChannel<>(binaryMessenger, channelName, getCodec());
channel.send(
null,
channelReply -> {
if (channelReply instanceof List) {
List<Object> listReply = (List<Object>) channelReply;
if (listReply.size() > 1) {
result.error(
new FlutterError(
(String) listReply.get(0), (String) listReply.get(1), listReply.get(2)));
} else {
result.success();
}
} else {
result.error(createConnectionError(channelName));
}
});
}
/** Called to get data for a map tile. */
public void getTileOverlayTile(
@NonNull String tileOverlayIdArg,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,7 @@ flutter:
uses-material-design: true
assets:
- assets/
# FOR TESTING AND INITIAL REVIEW ONLY. DO NOT MERGE.
# See https://github.com/flutter/flutter/blob/master/docs/ecosystem/contributing/README.md#changing-federated-plugins
dependency_overrides:
google_maps_flutter_platform_interface: {path: ../../../../packages/google_maps_flutter/google_maps_flutter_platform_interface}
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,11 @@ class GoogleMapsFlutterAndroid extends GoogleMapsFlutterPlatform {
return _events(mapId).whereType<ClusterTapEvent>();
}

@override
Stream<MapLoadedEvent> onMapLoaded({required int mapId}) {
return _events(mapId).whereType<MapLoadedEvent>();
}

@override
Future<void> updateMapConfiguration(
MapConfiguration configuration, {
Expand Down Expand Up @@ -1251,6 +1256,11 @@ class HostMapMessageHandler implements MapsCallbackApi {
MapTapEvent(mapId, _latLngFromPlatformLatLng(position)),
);
}

@override
void onMapLoaded() {
streamController.add(MapLoadedEvent(mapId));
}
}

LatLng _latLngFromPlatformLatLng(PlatformLatLng latLng) {
Expand Down
Loading