Skip to content
This repository was archived by the owner on Jun 25, 2019. It is now read-only.
Merged
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
Expand Up @@ -63,6 +63,9 @@ class MapActivity : AppCompatActivity(),
val loc = map.myLocation ?: return@setOnMyLocationChangeListener
MapViewPlugin.locationDidUpdate(loc)
}
map.setOnInfoWindowClickListener{ marker ->
MapViewPlugin.infoWindowTapped(marker.tag as String)
}
map.moveCamera(CameraUpdateFactory.newCameraPosition(
MapViewPlugin.initialCameraPosition))
MapViewPlugin.onMapReady()
Expand All @@ -76,6 +79,7 @@ class MapActivity : AppCompatActivity(),
return super.onCreateOptionsMenu(menu)
}


override fun onOptionsItemSelected(item: MenuItem): Boolean {
MapViewPlugin.handleToolbarAction(item.itemId)
return true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ class MapViewPlugin(val activity: Activity) : MethodCallHandler {
"longitude" to loc.longitude
))
}

fun infoWindowTapped(id: String) {
this.channel.invokeMethod("infoWindowTapped", id)
}
}

override fun onMethodCall(call: MethodCall, result: Result): Unit {
Expand Down
5 changes: 5 additions & 0 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,11 @@ class _MyAppState extends State<MyApp> {
}
});
compositeSubscription.add(sub);

sub = mapView.onInfoWindowTapped.listen((marker) {
debugPrint("\nAPP LEVEL - DETECT CLICK INFO WINDOW ${marker.title} \n");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you use the same print we use in the other example calls.

});
compositeSubscription.add(sub);
}

_handleDismiss() async {
Expand Down
5 changes: 4 additions & 1 deletion ios/Classes/MapViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -190,11 +190,14 @@ - (BOOL)mapView:(GMSMapView *)mapView didTapMarker:(GMSMarker *)marker {
return NO;
}

- (void)mapView:(GMSMapView *)mapView didTapInfoWindowOfMarker:(GMSMarker *)marker {
[self.plugin infoWindowTapped:marker.userData];
}

- (void)mapView:(GMSMapView *)mapView didTapAtCoordinate:(CLLocationCoordinate2D)coordinate {
[self.plugin mapTapped:coordinate];
}


- (void)mapView:(GMSMapView *)mapView didChangeCameraPosition:(GMSCameraPosition *)position {
[self.plugin cameraPositionChanged:position];
}
Expand Down
1 change: 1 addition & 0 deletions ios/Classes/MapViewPlugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
- (void)onMapReady;
- (void)locationDidUpdate:(CLLocation *)location;
- (void)annotationTapped:(NSString *)identifier;
- (void)infoWindowTapped:(NSString *)identifier;
- (void)mapTapped:(CLLocationCoordinate2D)coordinate;
- (void)cameraPositionChanged:(GMSCameraPosition *)position;
@end
4 changes: 4 additions & 0 deletions ios/Classes/MapViewPlugin.m
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,10 @@ - (void)annotationTapped:(NSString *)identifier {
[self.channel invokeMethod:@"annotationTapped" arguments:identifier];
}

- (void)infoWindowTapped:(GMSMarker *)identifier {
[self.channel invokeMethod:@"infoWindowTapped" arguments:identifier];
}

- (void)mapTapped:(CLLocationCoordinate2D)coordinate {
[self.channel invokeMethod:@"mapTapped" arguments:@{@"latitude": @(coordinate.latitude), @"longitude": @(coordinate.longitude)}];
}
Expand Down
11 changes: 11 additions & 0 deletions lib/map_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ class MapView {
new StreamController.broadcast();
StreamController<Null> _mapReadyStreamController =
new StreamController.broadcast();
StreamController<Marker> _infoWindowStreamController =
new StreamController.broadcast();

Map<String, Marker> _annotations = {};

Expand Down Expand Up @@ -113,6 +115,8 @@ class MapView {

Stream<Null> get onMapReady => _mapReadyStreamController.stream;

Stream<Marker> get onInfoWindowTapped => _infoWindowStreamController.stream;

Future<dynamic> _handleMethod(MethodCall call) async {
switch (call.method) {
case "onMapReady":
Expand All @@ -129,6 +133,13 @@ class MapView {
_annotationStreamController.add(annotation);
}
return new Future.value("");
case "infoWindowTapped":
String id = call.arguments;
var annotation = _annotations[id];
if (annotation != null) {
_infoWindowStreamController.add(annotation);
}
return new Future.value("");
case "mapTapped":
Map locationMap = call.arguments;
Location location = new Location.fromMap(locationMap);
Expand Down