コード例 #1
0
        // Implement IOnCalloutOverlayListener
        public NMapCalloutOverlay OnCreateCalloutOverlay(NMapOverlay itemOverlay, NMapOverlayItem overlayItem, Rect itemBounds)
        {
            // handle overlapped items
            if (itemOverlay is NMapPOIdataOverlay poiDataOverlay)
            {
                // check if it is selected by touch event
                if (!poiDataOverlay.IsFocusedBySelectItem)
                {
                    int countOfOverlappedItems = 1;

                    var poiData = poiDataOverlay.POIdata;
                    for (int i = 0; i < poiData.Count(); i++)
                    {
                        var poiItem = poiData.GetPOIitem(i);

                        // skip selected item
                        if (poiItem == overlayItem)
                        {
                            continue;
                        }

                        // check if overlapped or not
                        if (Rect.Intersects(poiItem.BoundsInScreen, overlayItem.BoundsInScreen))
                        {
                            countOfOverlappedItems++;
                        }
                    }

                    if (countOfOverlappedItems > 1)
                    {
                        var text = countOfOverlappedItems + " overlapped items for " + overlayItem.Title;
                        Toast.MakeText(this, text, ToastLength.Long).Show();
                        return(null);
                    }
                }
            }

            // use custom old callout overlay
            if (overlayItem is NMapPOIitem nMapPOIitem)
            {
                if (nMapPOIitem.ShowRightButton())
                {
                    return(new NMapCalloutCustomOldOverlay(itemOverlay, overlayItem, itemBounds, mMapViewerResourceProvider));
                }
            }

            // use custom callout overlay
            return(new NMapCalloutCustomOverlay(itemOverlay, overlayItem, itemBounds, mMapViewerResourceProvider));

            // set basic callout overlay
            //return new NMapCalloutBasicOverlay(itemOverlay, overlayItem, itemBounds);
        }
コード例 #2
0
        //OnCalloutOverlayViewListener
        View OnCreateCalloutOverlayView(NMapOverlay itemOverlay, NMapOverlayItem overlayItem, Rect itemBounds)
        {
            if (overlayItem != null)
            {
                // [TEST] 말풍선 오버레이를 뷰로 설정함
                String title = overlayItem.Title;
                if (title != null && title.Length > 5)
                {
                    return(new NMapCalloutCustomOverlayView(this, itemOverlay, overlayItem, itemBounds));
                }
            }

            // null을 반환하면 말풍선 오버레이를 표시하지 않음
            return(null);
        }
コード例 #3
0
        public NMapCalloutOverlayView(Context context, NMapOverlay itemOverlay, NMapOverlayItem item, Rect itemBounds) : base(context)
        {
            mOverlayItem     = item;
            mItemBounds      = itemBounds;
            mOnClickListener = null;
            mItemOverlay     = itemOverlay;

            int px = 0;
            int py = (int)(mItemBounds.Height() * mOverlayItem.AnchorYRatio);

            NMapView.LayoutParams lp = new NMapView.LayoutParams(NMapView.LayoutParams.WrapContent,
                                                                 NMapView.LayoutParams.WrapContent,
                                                                 mOverlayItem.Point, px, -py,
                                                                 NMapView.LayoutParams.BottomCenter);
            this.LayoutParameters = lp;

            mMarginX = NMapResourceProvider.ToPixelFromDIP(CALLOUT_MARGIN_X);
        }
コード例 #4
0
        public NMapCalloutBasicOverlay(NMapOverlay itemOverlay, NMapOverlayItem item, Rect itemBounds) : base(itemOverlay, item, itemBounds)
        {
            mInnerPaint = new Paint();
            mInnerPaint.SetARGB(225, 75, 75, 75); //gray
            mInnerPaint.AntiAlias = true;

            mBorderPaint = new Paint();
            mBorderPaint.SetARGB(255, 255, 255, 255);
            mBorderPaint.AntiAlias = true;
            mBorderPaint.SetStyle(Paint.Style.Stroke);
            mBorderPaint.StrokeWidth = 2;

            mTextPaint = new Paint();
            mTextPaint.SetARGB(255, 255, 255, 255);
            mTextPaint.AntiAlias = true;

            mPath = new Path();
            mPath.SetFillType(Path.FillType.Winding);
        }
コード例 #5
0
        public NMapCalloutCustomOverlayView(Context context, NMapOverlay itemOverlay, NMapOverlayItem item, Rect itemBounds) : base(context, itemOverlay, item, itemBounds)
        {
            string         infService = Context.LayoutInflaterService;
            LayoutInflater li         = (LayoutInflater)Context.GetSystemService(infService);

            li.Inflate(Resource.Layout.Callout_Overlay_View, this, true);

            mCalloutView = FindViewById(Resource.Id.callout_overlay);
            mCalloutText = mCalloutView.FindViewById <TextView>(Resource.Id.callout_text);
            mRightArrow  = FindViewById(Resource.Id.callout_rightArrow);

            mCalloutView.SetOnClickListener(this);
            //mCalloutView.Click += OnClick;

            mCalloutText.Text = item.Title;

            if (item is NMapPOIitem mapItem)
            {
                if (!mapItem.HasRightAccessory)
                {
                    mRightArrow.Visibility = ViewStates.Gone;
                }
            }
        }
コード例 #6
0
        public NMapCalloutCustomOldOverlay(NMapOverlay itemOverlay, NMapOverlayItem item, Rect itemBounds,
                                           IResourceProvider resourceProvider) : base(itemOverlay, item, itemBounds)
        {
            mTextPaint.AntiAlias = true;
            // set font style
            mTextPaint.Color = Color.ParseColor(CALLOUT_TEXT_COLOR);
            // set font size
            mTextPaint.TextSize = CALLOUT_TEXT_SIZE * NMapResourceProvider.ScaleFactor;
            // set font type
            if (CALLOUT_TEXT_TYPEFACE != null)
            {
                mTextPaint.SetTypeface(CALLOUT_TEXT_TYPEFACE);
            }

            mMarginX          = NMapResourceProvider.ToPixelFromDIP(CALLOUT_MARGIN_X);
            mPaddingX         = NMapResourceProvider.ToPixelFromDIP(CALLOUT_PADDING_X);
            mPaddingOffset    = NMapResourceProvider.ToPixelFromDIP(CALLOUT_PADDING_OFFSET);
            mPaddingY         = NMapResourceProvider.ToPixelFromDIP(CALLOUT_PADDING_Y);
            mMinimumWidth     = NMapResourceProvider.ToPixelFromDIP(CALLOUT_MIMIMUM_WIDTH);
            mTotalHeight      = NMapResourceProvider.ToPixelFromDIP(CALLOUT_TOTAL_HEIGHT);
            mBackgroundHeight = NMapResourceProvider.ToPixelFromDIP(CALLOUT_BACKGROUND_HEIGHT);
            mItemGapY         = NMapResourceProvider.ToPixelFromDIP(CALLOUT_ITEM_GAP_Y);

            mTailGapX = NMapResourceProvider.ToPixelFromDIP(CALLOUT_TAIL_GAP_X);
            mTailText = item.TailText;

            mTitleOffsetY = NMapResourceProvider.ToPixelFromDIP(CALLOUT_TITLE_OFFSET_Y);

            if (resourceProvider == null)
            {
                throw new IllegalArgumentException(
                          "NMapCalloutCustomOverlay.ResourceProvider should be provided on creation of NMapCalloutCustomOverlay.");
            }

            mBackgroundDrawable = resourceProvider.GetCalloutBackground(item);

            bool hasRightAccessory = false;

            mDrawableRightButton = resourceProvider.GetCalloutRightAccessory(item);
            if (mDrawableRightButton != null && mDrawableRightButton.Length > 0)
            {
                hasRightAccessory = true;

                mRightButtonText = null;
            }
            else
            {
                mDrawableRightButton = resourceProvider.GetCalloutRightButton(item);
                mRightButtonText     = resourceProvider.GetCalloutRightButtonText(item);
            }

            if (mDrawableRightButton != null)
            {
                if (hasRightAccessory)
                {
                    mCalloutRightButtonWidth  = mDrawableRightButton[0].IntrinsicWidth;
                    mCalloutRightButtonHeight = mDrawableRightButton[0].IntrinsicHeight;
                }
                else
                {
                    mCalloutRightButtonWidth  = NMapResourceProvider.ToPixelFromDIP(CALLOUT_RIGHT_BUTTON_WIDTH);
                    mCalloutRightButtonHeight = NMapResourceProvider.ToPixelFromDIP(CALLOUT_RIGHT_BUTTON_HEIGHT);
                }

                mRightButtonRect = new Rect();

                base.ItemCount = mCalloutButtonCount;
            }
            else
            {
                mCalloutRightButtonWidth  = 0;
                mCalloutRightButtonHeight = 0;
                mRightButtonRect          = null;
            }

            mTitleTruncated      = null;
            mWidthTitleTruncated = 0;
        }