Skip to content

Commit

Permalink
feat: implmenting CLLocationManagerDelegate need more stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
kefahB committed Oct 29, 2020
1 parent e918db9 commit 4b6509e
Showing 1 changed file with 3 additions and 50 deletions.
53 changes: 3 additions & 50 deletions src/map-view.ios.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,63 +70,18 @@ class IndoorDisplayDelegateImpl extends NSObject implements GMSIndoorDisplayDele
}

@NativeClass
class MapViewDelegateImpl extends NSObject implements GMSMapViewDelegate, CLLocationManagerDelegate {
class MapViewDelegateImpl extends NSObject implements GMSMapViewDelegate {

public static ObjCProtocols = [GMSMapViewDelegate];

private _owner: WeakRef<MapView>;

public static initWithOwner(owner: WeakRef<MapView>): MapViewDelegateImpl {
let handler = <MapViewDelegateImpl>MapViewDelegateImpl.new();
MapViewDelegateImpl.ObjCProtocols = [CLLocationManagerDelegate, GMSMapViewDelegate];
handler._owner = owner;
return handler;
}

public locationManagerDidChangeAuthorizationStatus(manager: CLLocationManager, status: CLAuthorizationStatus)
{
let owner = this._owner.get();
let lm = new CLLocationManager();
switch (status)
{
case CLAuthorizationStatus.kCLAuthorizationStatusAuthorizedAlways:
console.log("Location AuthorizedAlways")
owner.myLocationEnabled = true
lm.startUpdatingLocation()

case CLAuthorizationStatus.kCLAuthorizationStatusAuthorizedWhenInUse:
console.log("Location AuthorizedWhenInUse")
owner.myLocationEnabled = true
lm.startUpdatingLocation()

case CLAuthorizationStatus.kCLAuthorizationStatusDenied:
console.log("Location Denied")
owner.myLocationEnabled = false
lm.stopUpdatingLocation()

case CLAuthorizationStatus.kCLAuthorizationStatusNotDetermined:
console.log("Location NotDetermined")
owner.myLocationEnabled = false
lm.stopUpdatingLocation()

case CLAuthorizationStatus.kCLAuthorizationStatusRestricted:
console.log("Location Restricted")
owner.myLocationEnabled = false
lm.stopUpdatingLocation()
}
}

public locationManagerDidUpdateLocations(manager: CLLocationManager, locations: NSArray<CLLocation> | CLLocation[])
{
let owner = this._owner.get();
console.log(locations)
/*if (locations.length > 0)
{
owner.gMap.camera = GMSCameraPosition.cameraWithTargetZoom(locations.coordinate, 10.0)
owner.settings.myLocationButton = true
}*/
}

public mapViewIdleAtCameraPosition(mapView: GMSMapView, cameraPosition: GMSCameraPosition): void {
let owner = this._owner.get();
if (owner) {
Expand Down Expand Up @@ -243,7 +198,6 @@ class MapViewDelegateImpl extends NSObject implements GMSMapViewDelegate, CLLoca

public mapViewDidTapInfoWindowOfMarker(mapView: GMSMapView, gmsMarker: GMSMarker): void {
let owner = this._owner.get();
console.log("infowindow taped")
if (owner) {
let marker: Marker = owner.findMarker((marker: Marker) => marker.ios == gmsMarker);
owner.notifyMarkerInfoWindowTapped(marker);
Expand All @@ -260,7 +214,7 @@ class MapViewDelegateImpl extends NSObject implements GMSMapViewDelegate, CLLoca

public didTapMyLocationButtonForMapView(mapView: GMSMapView): boolean {
const owner = this._owner.get();
console.log("TAPED")
owner.setDelegate()
if (owner) {
owner.notifyMyLocationTapped();
return true;
Expand Down Expand Up @@ -386,7 +340,7 @@ export class MapView extends MapViewBase {

public _delegate: MapViewDelegateImpl;
private _indoorDelegate:IndoorDisplayDelegateImpl;
private _mapVCDelegate:MapVCDelegateImpl;
//private _mapVCDelegate:MapVCDelegateImpl;

constructor() {
super();
Expand Down Expand Up @@ -415,7 +369,6 @@ export class MapView extends MapViewBase {
this._markers = null;
this._delegate = null;
this._indoorDelegate=null;
this._mapVCDelegate = null;
super.disposeNativeView();
GC();
};
Expand Down

0 comments on commit 4b6509e

Please sign in to comment.