コード例 #1
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            // Perform any additional setup after loading the view, typically from a nib.
            mapView = new NMapView(View.Frame);
            NavigationController.NavigationBar.Translucent = false;
            // set the delegate for map view
            mapView.WeakDelegate = this;

            // set the application api key for Open MapViewer Library
            //[self.mapView setClientId:@"YOUR CLIENT ID"];
            mapView.SetClientId(AppSetting.CLIENT_ID);
            mapView.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight;

            View.AddSubview(mapView);
            currentState = State.Disabled;

            UIButton button = new UIButton(new CGRect(15, 30, 36, 36));
            var      image  = UIImage.FromBundle("v4_btn_navi_location_normal");

            button.SetImage(image, UIControlState.Normal);
            button.AddTarget(buttonClicked, UIControlEvent.TouchUpInside);
            changeStateButton = button;
            View.AddSubview(button);
        }
コード例 #2
0
        protected override void DrawCallout(Canvas canvas, NMapView mapView, bool shadow, long when)
        {
            AdjustTextBounds(mapView);

            StepAnimations(canvas, mapView, when);

            // Draw inner info window
            canvas.DrawRoundRect(MTempRectF, CALLOUT_ROUND_RADIUS_X, CALLOUT_ROUND_RADIUS_Y, mInnerPaint);

            // Draw border for info window
            canvas.DrawRoundRect(MTempRectF, CALLOUT_ROUND_RADIUS_X, CALLOUT_ROUND_RADIUS_Y, mBorderPaint);

            // Draw bottom tag
            if (CALLOUT_TAG_WIDTH > 0 && CALLOUT_TAG_HEIGHT > 0)
            {
                float x = MTempRectF.CenterX();
                float y = MTempRectF.Bottom;

                Path path = mPath;
                path.Reset();

                path.MoveTo(x - CALLOUT_TAG_WIDTH, y);
                path.LineTo(x, y + CALLOUT_TAG_HEIGHT);
                path.LineTo(x + CALLOUT_TAG_WIDTH, y);
                path.Close();

                canvas.DrawPath(path, mInnerPaint);
                canvas.DrawPath(path, mBorderPaint);
            }

            //  Draw title
            canvas.DrawText(MOverlayItem.Title, mOffsetX, mOffsetY, mTextPaint);
        }
コード例 #3
0
        /**
         * Fragment에 포함된 NMapView 객체를 반환함
         */
        private NMapView FindMapView(View v)
        {
            if (v is ViewGroup vg)
            {
                if (vg is NMapView vm)
                {
                    return(vm);
                }

                for (int i = 0; i < vg.ChildCount; i++)
                {
                    View child = vg.GetChildAt(i);
                    if (!(child is ViewGroup))
                    {
                        continue;
                    }

                    NMapView mapView = FindMapView(child);
                    if (mapView != null)
                    {
                        return(mapView);
                    }
                }
            }
            return(null);
        }
コード例 #4
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            // Perform any additional setup after loading the view, typically from a nib.
            // Perform any additional setup after loading the view, typically from a nib.
            mapView = new NMapView(View.Frame);
            NavigationController.NavigationBar.Translucent = false;
            // set the delegate for map view
            mapView.WeakDelegate = this;

            // set the application api key for Open MapViewer Library
            //[self.mapView setClientId:@"YOUR CLIENT ID"];
            mapView.SetClientId(AppSetting.CLIENT_ID);
            mapView.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight;

            // set delegate to use reverse geocoder API
            //WeakReverseGeocoderDelegate 를 직접 구현하는 방식과
            //Event를 구현하는 방식 모두 가능
            //https://docs.microsoft.com/en-us/xamarin/cross-platform/macios/binding/objective-c-libraries?tabs=vsmac#event-handlers-and-callbacks
            //mapView.WeakReverseGeocoderDelegate = this;
            mapView.DidFindPlacemark += OnDidFindPlacemark;
            mapView.DidFailWithError += OnDidFalWithError;

            View.AddSubview(mapView);
        }
コード例 #5
0
        protected override Rect GetBounds(NMapView mapView)
        {
            AdjustTextBounds(mapView);

            MTempRect.Set((int)MTempRectF.Left, (int)MTempRectF.Top, (int)MTempRectF.Right, (int)MTempRectF.Bottom);
            MTempRect.Union(MTempPoint.X, MTempPoint.Y);

            return(MTempRect);
        }
コード例 #6
0
        public void OnMapViewTouchesEnded(NMapView mapView, NSSet touches, UIEvent @event)
        {
            UITouch touch = touches.AnyObject as UITouch;

            if (touch != null)
            {
                var scrPoint = touch.LocationInView(mapView);
                RequestAddressByCoordination(mapView.FromPoint(scrPoint));
            }
        }
コード例 #7
0
        public bool IsCalloutViewInVisibleBounds(NMapView mapView)
        {
            if (this.Visibility == ViewStates.Visible)
            {
                Rect boundsVisible = mapView.MapController.BoundsVisible;
                Rect bounds        = GetBounds(mapView);

                return(Rect.Intersects(boundsVisible, bounds));
            }

            return(false);
        }
コード例 #8
0
        private Rect GetBounds(NMapView mapView)
        {
            //  First determine the screen coordinates of the selected MapLocation
            mapView.MapProjection.ToPixels(mOverlayItem.PointInUtmk, mTempPoint);

            mTempRect.Left   = this.Left;
            mTempRect.Top    = this.Top;
            mTempRect.Right  = this.Right;
            mTempRect.Bottom = this.Bottom;

            mTempRect.Union(mTempPoint.X, mTempPoint.Y);

            return(mTempRect);
        }
コード例 #9
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            SetContentView(Resource.Layout.Fragments);
            mMapView = FindViewById <NMapView>(Resource.Id.mapView);

            // initialize map view
            mMapView.Clickable            = true;
            mMapView.Enabled              = true;
            mMapView.Focusable            = true;
            mMapView.FocusableInTouchMode = true;
            mMapView.RequestFocus();
        }
コード例 #10
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            // Perform any additional setup after loading the view, typically from a nib.
            mapView = new NMapView()
            {
                Frame = View.Frame,
            };

            //// set the delegate for map view
            mapView.WeakDelegate = this;//new NMapViewNPOIdataOverlayDelegate();

            mapView.SetClientId(AppSetting.CLIENT_ID);
            View.AddSubview(mapView);
        }
コード例 #11
0
        private NMapView mMapView;           // 지도 화면 View

        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            mMapView = new NMapView(this);
            SetContentView(mMapView);
            mMapView.SetClientId(AppSetting.CLIENT_ID); // 클라이언트 아이디 값 설정
            mMapView.Clickable            = true;
            mMapView.Enabled              = true;
            mMapView.Focusable            = true;
            mMapView.FocusableInTouchMode = true;
            mMapView.RequestFocus();
            //var controller = mMapView.MapController;
            //controller.SetZoomLevel(13);
        }
コード例 #12
0
        public override void OnActivityCreated(Bundle savedInstanceState)
        {
            base.OnActivityCreated(savedInstanceState);

            // Fragment에 포함된 NMapView 객체 찾기
            NMapView mapView = FindMapView(base.View);

            if (mapView == null)
            {
                throw new IllegalArgumentException("NMapFragment dose not have an instance of NMapView.");
            }

            // NMapActivity를 상속하지 않는 경우에는 NMapView 객체 생성후 반드시 setupMapView()를 호출해야함.
            mMapContext.SetupMapView(mapView);
        }
コード例 #13
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            // Perform any additional setup after loading the view, typically from a nib.
            mapView = new NMapView(View.Frame);
            NavigationController.NavigationBar.Translucent = false;
            // set the delegate for map view
            mapView.WeakDelegate = this;

            // set the application api key for Open MapViewer Library
            //[self.mapView setClientId:@"YOUR CLIENT ID"];
            mapView.SetClientId(AppSetting.CLIENT_ID);
            mapView.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight;

            View.AddSubview(mapView);
        }
コード例 #14
0
        void AdjustTextBounds(NMapView mapView)
        {
            //  Determine the screen coordinates of the selected MapLocation
            mapView.MapProjection.ToPixels(MOverlayItem.PointInUtmk, MTempPoint);

            var title = MOverlayItem.Title;

            mTextPaint.GetTextBounds(title, 0, title.Length, MTempRect);

            //  Setup the callout with the appropriate size & location
            MTempRectF.Set(MTempRect);
            MTempRectF.Inset(-CALLOUT_TEXT_PADDING_X, -CALLOUT_TEXT_PADDING_Y);
            mOffsetX = MTempPoint.X - MTempRect.Width() / 2;
            mOffsetY = MTempPoint.Y - MTempRect.Height() - MItemBounds.Height() - CALLOUT_TEXT_PADDING_Y;
            MTempRectF.Offset(mOffsetX, mOffsetY);
        }
コード例 #15
0
 public void OnMapView(NMapView mapView, NMapError error)
 {
     //base.OnMapView(mapView, error);
     if (error == null)
     {
         //[self.mapView setMapCenter:NGeoPointMake(126.978371, 37.5666091) atLevel:11];
         //[self.mapView setMapEnlarged:YES mapHD:YES];
         var location = new NGeoPoint()
         {
             Latitude  = 37.5666091,
             Longitude = 126.978391
         };
         mapView.SetMapCenter(location, 11);
         mapView.SetMapEnlarged(true, true);
     }
     else
     {
         Debug.WriteLine("OnMapView:initHandler:" + error.Description);
     }
 }
コード例 #16
0
 public void OnMapView(NMapView mapView, NMapError error)
 {
     //base.OnMapView(mapView, error);
     if (error == null)
     {
         var location = new NGeoPoint
         {
             Longitude = 126.978391,
             Latitude  = 37.5666091,
         };
         mapView.SetMapCenter(location, 11);
         mapView.SetMapEnlarged(true, true);
         mapView.SetMapViewMode(NMapViewMode.Vector);
         hasInit = true;
     }
     else
     {
         Debug.WriteLine("OnMapView:initHandler:" + error.Description);
     }
 }
コード例 #17
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            mapView = new NMapView(View.Frame)
            {
                //set the delegate for map view
                WeakDelegate = this
            };
            // set the application api key for Open MapViewer Library
            mapView.SetClientId(AppSetting.CLIENT_ID);
            mapView.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight;
            View.InsertSubview(mapView, 0);

            // set min and max level for range in the UIStepper
            InitStepper(mapView.MaxZoomLevel(), mapView.MinZoomLevel(), 11);
            View.BringSubviewToFront(levelSetpper);

            mapView.SetBuiltInAppControl(true);
            mapView.Layer.AddAnimation(new Animation(this), "mapViewAnimation");
        }
コード例 #18
0
        void AdjustTextBounds(NMapView mapView)
        {
            //  First determine the screen coordinates of the selected MapLocation
            mapView.MapProjection.ToPixels(MOverlayItem.PointInUtmk, MTempPoint);

            int mapViewWidth = mapView.MapController.ViewFrameVisibleWidth;

            if (mTitleTruncated == null || mWidthTitleTruncated != mapViewWidth)
            {
                mWidthTitleTruncated = mapViewWidth;
                float maxWidth = mWidthTitleTruncated - 2 * mMarginX - 2 * mPaddingX;
                if (DEBUG)
                {
                    Log.Info(LOG_TAG, "adjustTextBounds: maxWidth=" + maxWidth + ", mMarginX=" + mMarginX + ", mPaddingX="
                             + mPaddingX);
                }

                if (mDrawableRightButton != null)
                {
                    maxWidth -= mPaddingX + mCalloutRightButtonWidth;
                }

                if (mTailText != null)
                {
                    mTextPaint.GetTextBounds(mTailText, 0, mTailText.Length, MTempRect);
                    mTailTextWidth = MTempRect.Width();

                    maxWidth -= mTailGapX + mTailTextWidth;
                }

                var title = TextUtils.Ellipsize(MOverlayItem.Title, mTextPaint, maxWidth,
                                                TextUtils.TruncateAt.End).ToString();

                mTitleTruncated = title;

                if (DEBUG)
                {
                    Log.Info(LOG_TAG, "adjustTextBounds: mTitleTruncated=" + mTitleTruncated + ", length="
                             + mTitleTruncated.Length);
                }
            }

            mTextPaint.GetTextBounds(mTitleTruncated, 0, mTitleTruncated.Length, MTempRect);

            if (mDrawableRightButton != null)
            {
                MTempRect.Right += (int)(mPaddingX + mCalloutRightButtonWidth);
            }

            if (mTailText != null)
            {
                MTempRect.Right += (int)(mTailGapX + mTailTextWidth);
            }

            if (DEBUG)
            {
                Log.Info(LOG_TAG, "adjustTextBounds: mTempRect.width=" + MTempRect.Width() + ", mTempRect.height="
                         + MTempRect.Height());
            }

            //  Setup the callout with the right size & location
            MTempRectF.Set(MTempRect);
            var dy = (mBackgroundHeight - MTempRect.Height()) / 2;

            MTempRectF.Inset(-mPaddingX, -dy);
            //mTempRectF.inset(-mPaddingX, -mPaddingY);

            // set minimum size
            if (MTempRectF.Width() < mMinimumWidth)
            {
                var dx = (mMinimumWidth - MTempRectF.Width()) / 2;
                MTempRectF.Inset(-dx, 0);
            }

            // set position
            float left = MTempPoint.X - (int)(MTempRectF.Width() * MOverlayItem.AnchorXRatio);
            float top  = MTempPoint.Y - (int)(MItemBounds.Height() * MOverlayItem.AnchorYRatio) - mItemGapY - mTotalHeight;

            MTempRectF.Set(left, top, left + MTempRectF.Width(), top + MTempRectF.Height());
        }
コード例 #19
0
        protected override void DrawCallout(Canvas canvas, NMapView mapView, bool shadow, long when)
        {
            AdjustTextBounds(mapView);

            StepAnimations(canvas, mapView, when);

            DrawBackground(canvas);

            float left, top;

            // draw title
            mOffsetX  = MTempPoint.X - MTempRect.Width() / 2;
            mOffsetX -= mPaddingOffset;
            mOffsetY  = MTempRectF.Top + mPaddingY + mTextPaint.TextSize + mTitleOffsetY;
            canvas.DrawText(mTitleTruncated, mOffsetX, mOffsetY, mTextPaint);

            // draw right button
            if (mDrawableRightButton != null)
            {
                left = MTempRectF.Right - mPaddingX - mCalloutRightButtonWidth;
                top  = MTempRectF.Top + (mBackgroundHeight - mCalloutRightButtonHeight) / 2;

                // Use background drawables depends on current state
                mRightButtonRect.Left   = (int)(left + 0.5F);
                mRightButtonRect.Top    = (int)(top + 0.5F);
                mRightButtonRect.Right  = (int)(left + mCalloutRightButtonWidth + 0.5F);
                mRightButtonRect.Bottom = (int)(top + mCalloutRightButtonHeight + 0.5F);

                int      itemState = base.GetItemState(0);
                Drawable drawable  = GetDrawable(0, itemState);
                if (drawable != null)
                {
                    drawable.Bounds = mRightButtonRect;
                    drawable.Draw(canvas);
                }

                if (mRightButtonText != null)
                {
                    mTextPaint.GetTextBounds(mRightButtonText, 0, mRightButtonText.Length, MTempRect);

                    left = mRightButtonRect.Left + (mCalloutRightButtonWidth - MTempRect.Width()) / 2;
                    top  = mRightButtonRect.Top + (mCalloutRightButtonHeight - MTempRect.Height()) / 2 + MTempRect.Height() + mTitleOffsetY;
                    canvas.DrawText(mRightButtonText, left, top, mTextPaint);
                }
            }

            // draw tail text
            if (mTailText != null)
            {
                if (mRightButtonRect != null)
                {
                    left = mRightButtonRect.Left;
                }
                else
                {
                    left = MTempRectF.Right;
                }
                left -= mPaddingX + mTailTextWidth;
                top   = mOffsetY;

                canvas.DrawText(mTailText, left, top, mTextPaint);
            }
        }
コード例 #20
0
        public void AdjustBounds(NMapView mapView, bool animate, bool adjustToCenter)
        {
            if (adjustToCenter)
            {
                NGeoPoint pt = mOverlayItem.Point;
                if (animate)
                {
                    mapView.MapController.AnimateTo(pt, true);
                }
                else
                {
                    mapView.MapController.MapCenter = pt;
                }
            }
            else
            {
                Rect boundsVisible = mapView.MapController.BoundsVisible;
                Rect bounds        = GetBounds(mapView);

                int marginX = MarginX;

                if (!boundsVisible.Contains(bounds))
                {
                    int centerX = 0;
                    if (bounds.Width() >= boundsVisible.Width())
                    {
                        centerX = bounds.CenterX();
                    }
                    else
                    {
                        if (bounds.Left < boundsVisible.Left)
                        {
                            centerX = boundsVisible.Left - bounds.Left + marginX;
                        }
                        else if (bounds.Right > boundsVisible.Right)
                        {
                            centerX = boundsVisible.Right - bounds.Right - marginX;
                        }
                        centerX = boundsVisible.CenterX() - centerX;
                    }

                    int centerY = 0;
                    if (bounds.Top < boundsVisible.Top)
                    {
                        centerY = boundsVisible.Top - bounds.Top + marginX;
                    }
                    else if (bounds.Bottom > boundsVisible.Bottom)
                    {
                        centerY = boundsVisible.Bottom - bounds.Bottom - marginX;
                    }
                    centerY = boundsVisible.CenterY() - centerY;

                    NGeoPoint pt = mapView.MapProjection.FromPixels(centerX, centerY);
                    if (animate)
                    {
                        mapView.MapController.AnimateTo(pt, true);
                    }
                    else
                    {
                        mapView.MapController.MapCenter = pt;
                    }
                }
            }

            if (animate)
            {
                AnimateCallout();
            }
        }
コード例 #21
0
 public bool OnMapViewIsGPSTracking(NMapView mapView)
 {
     return(NMapLocationManager.SharedInstance.IsTrackingEnabled);
 }
コード例 #22
0
        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);
        }