void DisableHeading()
        {
            NMapLocationManager lm = NMapLocationManager.SharedInstance;

            if (lm.HeadingAvailable)
            {
                lm.StopUpdatingHeading();
            }
            mapView.SetAutoRotateEnabled(false, true);
        }
        void DisableLocationUpdate()
        {
            NMapLocationManager lm = NMapLocationManager.SharedInstance;

            if (lm.IsUpdateLocationStarted)
            {
                lm.StopUpdateLocationInfo();
                lm.SetDelegate(null);
            }
            mapView.MapOverlayManager.ClearOverlays();
        }
        public void DidUpdateToLocation(NMapLocationManager locationManager, CLLocation location)
        {
            CLLocationCoordinate2D coordinate = location.Coordinate;
            NGeoPoint myLocation = new NGeoPoint();

            myLocation.Longitude = coordinate.Latitude;
            myLocation.Latitude  = coordinate.Latitude;
            var locationAccuracy = (float)location.HorizontalAccuracy;

            mapView.MapOverlayManager.SetMyLocation(myLocation, locationAccuracy);
            mapView.SetMapCenter(myLocation);
        }
        public void DidFailWithError(NMapLocationManager locationManager, NMapLocationManagerErrorType errorType)
        {
            string message = string.Empty;

            switch (errorType)
            {
            case NMapLocationManagerErrorType.Unknown:
            case NMapLocationManagerErrorType.Canceled:
                message = "일시적으로 내위치를 확인 할 수 없습니다.";
                break;

            case NMapLocationManagerErrorType.Denied:
                if (UIDevice.CurrentDevice.CheckSystemVersion(4, 0))
                {
                    message = "위치 정보를 확인 할 수 없습니다.\\n사용자의 위치 정보를 확인하도록 허용하시려면 위치서비스를 켜십시오.";
                }
                else
                {
                    message = "위치 정보를 확인 할 수 없습니다.";
                }
                break;

            case NMapLocationManagerErrorType.UnavailableArea:
                message = "현재 위치는 지도내에 표시 할 수 없습니다.";
                break;

            case NMapLocationManagerErrorType.Heading:
                message = "나침반 정보를 확인 할 수 없습니다.";
                break;
            }
            if (!string.IsNullOrEmpty(message))
            {
                UIAlertController alert = UIAlertController.Create("NMapViewer", message, UIAlertControllerStyle.Alert);
                UIAlertAction     ok    = UIAlertAction.Create("OK", UIAlertActionStyle.Default, null);

                alert.AddAction(ok);
                this.PresentViewController(alert, true, null);
                if (mapView.AutoRotateEnabled)
                {
                    mapView.SetAutoRotateEnabled(false, false);
                }
                mapView.MapOverlayManager.ClearMyLocationOverlay();
            }
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            // Create your application here
            if (USE_XML_LAYOUT)
            {
                SetContentView(Resource.Layout.Main);

                mMapView = FindViewById <NMapView>(Resource.Id.mapView);
            }
            else
            {
                // create map view
                mMapView = new NMapView(this);

                // create parent view to rotate map view
                mMapContainerView = new MapContainerView(this, this);
                mMapContainerView.AddView(mMapView);

                // set the activity content to the parent view
                SetContentView(mMapContainerView);
            }

            // set a registered Client Id for Open MapViewer Library
            mMapView.SetClientId(CLIENT_ID);

            // initialize map view
            mMapView.Clickable            = true;
            mMapView.Enabled              = true;
            mMapView.Focusable            = true;
            mMapView.FocusableInTouchMode = true;
            mMapView.RequestFocus();

            // register listener for map state changes
            //mMapView.SetOnMapStateChangeListener(onMapViewStateChangeListener);
            mMapView.MapInitHandler       += OnMapInit;
            mMapView.AnimationStateChange += OnAnimationStateChange;
            mMapView.MapCenterChange      += OnMapCenterChange;
            mMapView.ZoomLevelChange      += OnZoomLevelChage;
            //mMapView.MapCenterChangeFine += OnMapCenterChangeFine;

            //mMapView.SetOnMapViewTouchEventListener(onMapViewTouchEventListener);
            //이벤트 방식으로 구현시 약한 결합을 지원하므로 좀더 유연하게 핸드러를 구현할 수 있음(필요시에만 구현)
            //mMapView.LongPress += OnLongPress;
            //mMapView.LongPressCanceled += OnLongPressCanceled;
            //mMapView.SingleTapUp += OnSingleTapUp;
            //mMapView.TouchDown += OnTouchDown;
            //mMapView.TouchUp += OnTouchUp;
            //mMapView.Scroll += OnScroll;

            mMapView.SetOnMapViewDelegate(this);

            // use map controller to zoom in/out, pan and set map center, zoom level etc.
            mMapController = mMapView.MapController;

            // use built in zoom controls
            var lp = new NMapView.LayoutParams(ViewGroup.LayoutParams.WrapContent,
                                               ViewGroup.LayoutParams.WrapContent,
                                               NMapView.LayoutParams.BottomRight);

            mMapView.SetBuiltInZoomControls(true, lp);

            // create resource provider
            mMapViewerResourceProvider = new NMapViewerResourceProvider(this);

            // set data provider listener
            //base.SetMapDataProviderListener(onDataProviderListener);
            base.MapDataProvider += OnReverseGeocoderResponse;

            // create overlay manager
            mOverlayManager = new NMapOverlayManager(this, mMapView, mMapViewerResourceProvider);
            // register callout overlay listener to customize it.
            mOverlayManager.SetOnCalloutOverlayListener(this);
            // register callout overlay view listener to customize it.
            //mOverlayManager.SetOnCalloutOverlayViewListener(onCalloutOverlayViewListener);
            mOverlayManager.CalloutOverlayViewEvent = OnCreateCalloutOverlayView;

            // location manager
            mMapLocationManager = new NMapLocationManager(this);
            //mMapLocationManager.SetOnLocationChangeListener(onMyLocationChangeListener);
            mMapLocationManager.LocationChanged         += OnLocationChanged;
            mMapLocationManager.LocationUnavailableArea += OnLocationUnablableArea;
            mMapLocationManager.LocationUpdateTimeout   += OnLocationUpdateTimeout;

            // compass manager
            mMapCompassManager = new NMapCompassManager(this);

            // create my location overlay
            mMyLocationOverlay = mOverlayManager.CreateMyLocationOverlay(mMapLocationManager, mMapCompassManager);
        }
        public void DidUpdateHeading(NMapLocationManager locationManager, CLHeading heading)
        {
            var headingValue = heading.TrueHeading < 0.0 ? heading.MagneticHeading : heading.TrueHeading;

            SetCompassHeadingValue((float)headingValue);
        }