Skip to content

Commit

Permalink
feat(all): expose markerInfoWindowClosed event
Browse files Browse the repository at this point in the history
  • Loading branch information
Finn Gutteridge committed Jan 3, 2020
1 parent 30c692e commit 6a80f82
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 5 deletions.
3 changes: 2 additions & 1 deletion demo/app/main-page.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
tilt="{{ tilt }}" i-padding="50,50,50,50" padding="{{ padding }}" mapReady="onMapReady"
markerSelect="onMarkerEvent" markerBeginDragging="onMarkerEvent"
markerEndDragging="onMarkerEvent" markerDrag="onMarkerEvent"
markerInfoWindowTapped="onMarkerEvent" coordinateTapped="onCoordinateTapped"
markerInfoWindowTapped="onMarkerEvent" markerInfoWindowClosed="onMarkerEvent"
coordinateTapped="onCoordinateTapped"
cameraChanged="onCameraChanged"
indoorBuildingFocused="onIndoorBuildingFocused"
indoorLevelActivated="onIndoorLevelActivated"
Expand Down
9 changes: 9 additions & 0 deletions src/map-view-common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ export abstract class MapViewBase extends View implements MapView {
public static mapReadyEvent: string = "mapReady";
public static markerSelectEvent: string = "markerSelect";
public static markerInfoWindowTappedEvent: string = "markerInfoWindowTapped";
public static markerInfoWindowClosedEvent: string = "markerInfoWindowClosed";
public static shapeSelectEvent: string = "shapeSelect";
public static markerBeginDraggingEvent: string = "markerBeginDragging";
public static markerEndDraggingEvent: string = "markerEndDragging";
Expand Down Expand Up @@ -321,15 +322,23 @@ export abstract class MapViewBase extends View implements MapView {
let args: ShapeEventData = { eventName: eventName, object: this, shape: shape };
this.notify(args);
}

notifyMarkerTapped(marker: MarkerBase) {
this.notifyMarkerEvent(MapViewBase.markerSelectEvent, marker);
}

notifyMarkerInfoWindowTapped(marker: MarkerBase) {
this.notifyMarkerEvent(MapViewBase.markerInfoWindowTappedEvent, marker);
}

notifyMarkerInfoWindowClosed(marker: MarkerBase) {
this.notifyMarkerEvent(MapViewBase.markerInfoWindowClosedEvent, marker);
}

notifyShapeTapped(shape: ShapeBase) {
this.notifyShapeEvent(MapViewBase.shapeSelectEvent, shape);
}

notifyMarkerBeginDragging(marker: MarkerBase) {
this.notifyMarkerEvent(MapViewBase.markerBeginDraggingEvent, marker);
}
Expand Down
9 changes: 9 additions & 0 deletions src/map-view.android.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,15 @@ export class MapView extends MapViewBase {
}
}));

gMap.setOnInfoWindowCloseListener(new com.google.android.gms.maps.GoogleMap.OnInfoWindowCloseListener({
onInfoWindowClose: (gmsMarker) => {
let marker = owner.findMarker((marker: Marker) => marker.android.getId() === gmsMarker.getId());
owner.notifyMarkerInfoWindowClosed(marker);

return false;
}
}));

gMap.setOnMyLocationButtonClickListener(new com.google.android.gms.maps.GoogleMap.OnMyLocationButtonClickListener({
onMyLocationButtonClick: () => {
owner.notifyMyLocationTapped();
Expand Down
12 changes: 10 additions & 2 deletions src/map-view.ios.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,13 +197,21 @@ class MapViewDelegateImpl extends NSObject implements GMSMapViewDelegate {
}

public mapViewDidTapInfoWindowOfMarker(mapView: GMSMapView, gmsMarker: GMSMarker): void {
var owner = this._owner.get();
let owner = this._owner.get();
if (owner) {
var marker = owner.findMarker(function (marker) { return marker.ios == gmsMarker; });
let marker: Marker = owner.findMarker((marker: Marker) => marker.ios == gmsMarker);
owner.notifyMarkerInfoWindowTapped(marker);
}
}

public mapViewDidCloseInfoWindowOfMarker(mapView: GMSMapView, gmsMarker: GMSMarker): void {
let owner = this._owner.get();
if (owner) {
let marker: Marker = owner.findMarker((marker: Marker) => marker.ios == gmsMarker);
owner.notifyMarkerInfoWindowClosed(marker);
}
}

public didTapMyLocationButtonForMapView(mapView: GMSMapView): boolean {
const owner = this._owner.get();
if (owner) {
Expand Down
5 changes: 3 additions & 2 deletions src/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 6a80f82

Please sign in to comment.