Skip to content

Commit 736c85b

Browse files
authored
Merge pull request #446 from kefahB/master
fix: Button My Location not working on IOS
2 parents 40e0569 + 5bc6037 commit 736c85b

File tree

1 file changed

+3
-131
lines changed

1 file changed

+3
-131
lines changed

src/map-view.ios.ts

Lines changed: 3 additions & 131 deletions
Original file line numberDiff line numberDiff line change
@@ -216,9 +216,10 @@ class MapViewDelegateImpl extends NSObject implements GMSMapViewDelegate {
216216

217217
if (owner) {
218218
owner.notifyMyLocationTapped();
219-
return true;
219+
// Should return false in order to center the map on user position
220+
return false;
220221
}
221-
return false;
222+
return true;
222223
}
223224

224225
public mapViewMarkerInfoWindow(mapView: GMSMapView, gmsMarker: GMSMarker): UIView {
@@ -274,133 +275,6 @@ class MapViewDelegateImpl extends NSObject implements GMSMapViewDelegate {
274275
}
275276
}
276277

277-
@NativeClass()
278-
class MapVCDelegateImpl extends NSObject implements CLLocationManagerDelegate
279-
{
280-
public static ObjCProtocols = [CLLocationManagerDelegate];
281-
282-
protected _owner: WeakRef<MapView>;
283-
public lm: CLLocationManager = new CLLocationManager();
284-
285-
public static initWithOwner(owner: WeakRef<MapView>): MapVCDelegateImpl {
286-
let handler = <MapVCDelegateImpl>MapVCDelegateImpl.new();
287-
handler._owner = owner;
288-
return handler;
289-
}
290-
291-
locationManagerDidDetermineStateForRegion?(manager: CLLocationManager, state: CLRegionState, region: CLRegion): void {
292-
293-
}
294-
295-
locationManagerDidEnterRegion?(manager: CLLocationManager, region: CLRegion): void {
296-
297-
}
298-
299-
locationManagerDidExitRegion?(manager: CLLocationManager, region: CLRegion): void {
300-
301-
}
302-
303-
locationManagerDidFailRangingBeaconsForConstraintError?(manager: CLLocationManager, beaconConstraint: CLBeaconIdentityConstraint, error: NSError): void {
304-
305-
}
306-
307-
locationManagerDidFailWithError?(manager: CLLocationManager, error: NSError): void {
308-
309-
}
310-
311-
locationManagerDidFinishDeferredUpdatesWithError?(manager: CLLocationManager, error: NSError): void {
312-
313-
}
314-
315-
locationManagerDidPauseLocationUpdates?(manager: CLLocationManager): void {
316-
317-
}
318-
319-
locationManagerDidRangeBeaconsInRegion?(manager: CLLocationManager, beacons: NSArray<CLBeacon> | CLBeacon[], region: CLBeaconRegion): void {
320-
321-
}
322-
323-
locationManagerDidRangeBeaconsSatisfyingConstraint?(manager: CLLocationManager, beacons: NSArray<CLBeacon> | CLBeacon[], beaconConstraint: CLBeaconIdentityConstraint): void {
324-
325-
}
326-
327-
locationManagerDidResumeLocationUpdates?(manager: CLLocationManager): void {
328-
329-
}
330-
331-
locationManagerDidStartMonitoringForRegion?(manager: CLLocationManager, region: CLRegion): void {
332-
333-
}
334-
335-
locationManagerDidUpdateHeading?(manager: CLLocationManager, newHeading: CLHeading): void {
336-
337-
}
338-
339-
locationManagerDidUpdateToLocationFromLocation?(manager: CLLocationManager, newLocation: CLLocation, oldLocation: CLLocation): void {
340-
341-
}
342-
343-
locationManagerDidVisit?(manager: CLLocationManager, visit: CLVisit): void {
344-
345-
}
346-
347-
locationManagerMonitoringDidFailForRegionWithError?(manager: CLLocationManager, region: CLRegion, error: NSError): void {
348-
349-
}
350-
351-
locationManagerRangingBeaconsDidFailForRegionWithError?(manager: CLLocationManager, region: CLBeaconRegion, error: NSError): void {
352-
353-
}
354-
355-
locationManagerShouldDisplayHeadingCalibration?(manager: CLLocationManager): boolean {
356-
return false;
357-
}
358-
359-
360-
public locationManagerDidChangeAuthorizationStatus(manager: CLLocationManager, status: CLAuthorizationStatus)
361-
{
362-
let owner = this._owner.get();
363-
switch (status)
364-
{
365-
case CLAuthorizationStatus.kCLAuthorizationStatusAuthorizedAlways:
366-
console.log("Location AuthorizedAlways")
367-
owner.myLocationEnabled = true
368-
this.lm.startUpdatingLocation()
369-
370-
case CLAuthorizationStatus.kCLAuthorizationStatusAuthorizedWhenInUse:
371-
console.log("Location AuthorizedWhenInUse")
372-
owner.myLocationEnabled = true
373-
this.lm.startUpdatingLocation()
374-
375-
case CLAuthorizationStatus.kCLAuthorizationStatusDenied:
376-
console.log("Location Denied")
377-
owner.myLocationEnabled = false
378-
this.lm.stopUpdatingLocation()
379-
380-
case CLAuthorizationStatus.kCLAuthorizationStatusNotDetermined:
381-
console.log("Location NotDetermined")
382-
owner.myLocationEnabled = false
383-
this.lm.stopUpdatingLocation()
384-
385-
case CLAuthorizationStatus.kCLAuthorizationStatusRestricted:
386-
console.log("Location Restricted")
387-
owner.myLocationEnabled = false
388-
this.lm.stopUpdatingLocation()
389-
}
390-
}
391-
392-
public locationManagerDidUpdateLocations(manager: CLLocationManager, locations: NSArray<CLLocation> | CLLocation[])
393-
{
394-
let owner = this._owner.get();
395-
console.log(locations)
396-
/*if (locations.length > 0)
397-
{
398-
owner.gMap.camera = GMSCameraPosition.cameraWithTargetZoom(locations.coordinate, 10.0)
399-
owner.settings.myLocationButton = true
400-
}*/
401-
}
402-
}
403-
404278

405279

406280
export class MapView extends MapViewBase {
@@ -409,15 +283,13 @@ export class MapView extends MapViewBase {
409283

410284
public _delegate: MapViewDelegateImpl;
411285
private _indoorDelegate:IndoorDisplayDelegateImpl;
412-
//private _mapVCDelegate:MapVCDelegateImpl;
413286

414287
constructor() {
415288
super();
416289

417290
this.nativeView = GMSMapView.mapWithFrameCamera(CGRectZero, this._createCameraPosition());
418291
this._delegate = MapViewDelegateImpl.initWithOwner(new WeakRef(this));
419292
this._indoorDelegate = IndoorDisplayDelegateImpl.initWithOwner(new WeakRef(this));
420-
//this._mapVCDelegate = MapVCDelegateImpl.initWithOwner(new WeakRef(this));
421293
this.updatePadding();
422294
}
423295

0 commit comments

Comments
 (0)