コード例 #1
0
        protected override void SetBounds(Drawable marker, int markerId, NMapOverlayItem item)
        {
            // check shape of the marker to set bounds correctly.
            if (NMapPOIflagType.IsBoundsCentered(markerId))
            {
                if (marker.Bounds.IsEmpty)
                {
                    NMapOverlayItem.BoundCenter(marker);
                }

                if (null != item)
                {
                    item.SetAnchorRatio(0.5f, 0.5f);
                }
            }
            else
            {
                if (marker.Bounds.IsEmpty)
                {
                    NMapOverlayItem.BoundCenterBottom(marker);
                }

                if (null != item)
                {
                    item.SetAnchorRatio(0.5f, 1.0f);
                }
            }
        }
コード例 #2
0
        public Drawable getDrawable(int markerId, bool focused, NMapOverlayItem item)
        {
            Drawable marker = null;

            int resourceId = FindResourceIdForMarker(markerId, focused);

            if (resourceId > 0)
            {
                marker = ContextCompat.GetDrawable(MContext, resourceId);//MContext.Resources.GetDrawable(resourceId);
            }
            else
            {
                resourceId = 4 * markerId;
                if (focused)
                {
                    resourceId += 1;
                }

                marker = GetDrawableForMarker(markerId, focused, item);
            }

            // set bounds
            if (marker != null)
            {
                SetBounds(marker, markerId, item);
            }

            return(marker);
        }
コード例 #3
0
 public override int[] GetCalloutTextColors(NMapOverlayItem p0)
 {
     int[] colors = new int[4];
     colors[0] = Color.ParseColor(CALLOUT_TEXT_COLOR_NORMAL).ToArgb();
     colors[1] = Color.ParseColor(CALLOUT_TEXT_COLOR_PRESSED).ToArgb();
     colors[2] = Color.ParseColor(CALLOUT_TEXT_COLOR_SELECTED).ToArgb();
     colors[3] = Color.ParseColor(CALLOUT_TEXT_COLOR_FOCUSED).ToArgb();
     return(colors);
 }
コード例 #4
0
        public override string GetCalloutRightButtonText(NMapOverlayItem item)
        {
            if (item is NMapPOIitem poiItem)
            {
                if (poiItem.ShowRightButton())
                {
                    return(MContext.Resources.GetString(Resource.String.str_done));
                }
            }

            return(null);
        }
コード例 #5
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);
        }
コード例 #6
0
        public Bitmap GetBitmap(int markerId, bool focused, NMapOverlayItem item)
        {
            Bitmap bitmap = null;

            Drawable marker = getDrawable(markerId, focused, item);

            if (marker != null)
            {
                bitmap = GetBitmap(marker);
            }

            return(bitmap);
        }
コード例 #7
0
        public Drawable getDrawableWithAlphabet(int resourceId, string strAlphabet, int fontColor, float fontSize)
        {
            Bitmap textBitmap = GetBitmapWithText(resourceId, strAlphabet, fontColor, fontSize, POI_FONT_OFFSET_ALPHABET);

            // set bounds
            Drawable marker = new BitmapDrawable(MContext.Resources, textBitmap);

            if (marker != null)
            {
                NMapOverlayItem.BoundCenterBottom(marker);
            }

            return(marker);
        }
コード例 #8
0
        public override Drawable GetCalloutBackground(NMapOverlayItem item)
        {
            if (item is NMapPOIitem poiItem)
            {
                if (poiItem.ShowRightButton())
                {
                    //Drawable drawable = ContextCompat.GetDrawable(MContext, Resource.Drawable.bg_speech);//mContext.getResources().getDrawable(R.drawable.bg_speech);
                    return(ContextCompat.GetDrawable(MContext, Resource.Drawable.bg_speech));
                }
            }

            //Drawable drawable = mContext.getResources().getDrawable(R.drawable.pin_ballon_bg);
            return(ContextCompat.GetDrawable(MContext, Resource.Drawable.pin_ballon_bg));
        }
コード例 #9
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);
        }
コード例 #10
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);
        }
コード例 #11
0
        public override Drawable[] GetCalloutRightButton(NMapOverlayItem item)
        {
            if (item is NMapPOIitem poiItem)
            {
                if (poiItem.ShowRightButton())
                {
                    Drawable[] drawable = new Drawable[3];

                    drawable[0] = ContextCompat.GetDrawable(MContext, Resource.Drawable.btn_green_normal);
                    drawable[1] = ContextCompat.GetDrawable(MContext, Resource.Drawable.btn_green_pressed);
                    drawable[2] = ContextCompat.GetDrawable(MContext, Resource.Drawable.btn_green_highlight);

                    return(drawable);
                }
            }

            return(null);
        }
コード例 #12
0
        public Drawable GetDrawableWithNumber(int resourceId, string strNumber, float offsetY, int fontColor, float fontSize)
        {
            Bitmap textBitmap = GetBitmapWithText(resourceId, strNumber, fontColor, fontSize, offsetY);

            //Log.i(LOG_TAG, "getDrawableWithNumber: width=" + textBitmap.getWidth() + ", height=" + textBitmap.getHeight() + ", density=" + textBitmap.getDensity());

            // set bounds
            Drawable marker = new BitmapDrawable(MContext.Resources, textBitmap);

            if (marker != null)
            {
                NMapOverlayItem.BoundCenter(marker);
            }

            //Log.i(LOG_TAG, "getDrawableWithNumber: width=" + marker.getIntrinsicWidth() + ", height=" + marker.getIntrinsicHeight());

            return(marker);
        }
コード例 #13
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);
        }
コード例 #14
0
        protected override Drawable GetDrawableForMarker(int markerId, bool focused, NMapOverlayItem item)
        {
            Drawable drawable = null;

            if (markerId >= NMapPOIflagType.NUMBER_BASE && markerId < NMapPOIflagType.NUMBER_END)
            { // Direction Number icons
                int resourceId = (focused) ? Resource.Drawable.ic_map_no_02 : Resource.Drawable.ic_map_no_01;
                int fontColor  = (focused) ? int.Parse(POI_FONT_COLOR_ALPHABET.Replace("#", string.Empty), System.Globalization.NumberStyles.HexNumber)
                                               : int.Parse(POI_FONT_COLOR_NUMBER.Replace("#", string.Empty), System.Globalization.NumberStyles.HexNumber);

                string strNumber = (markerId - NMapPOIflagType.NUMBER_BASE).ToString();

                drawable = GetDrawableWithNumber(resourceId, strNumber, 0.0F, fontColor, POI_FONT_SIZE_NUMBER);
            }
            else if (markerId >= NMapPOIflagType.CUSTOM_BASE && markerId < NMapPOIflagType.CUSTOM_END)
            { // Custom POI icons
            }

            return(drawable);
        }
コード例 #15
0
        protected override Drawable GetDrawable(int rank, int itemState)
        {
            if (mDrawableRightButton != null && mDrawableRightButton.Length >= 3)
            {
                int idxDrawable = 0;
                if (NMapOverlayItem.IsPressedState(itemState))
                {
                    idxDrawable = 1;
                }
                else if (NMapOverlayItem.IsSelectedState(itemState))
                {
                    idxDrawable = 2;
                }
                else if (NMapOverlayItem.IsFocusedState(itemState))
                {
                    idxDrawable = 2;
                }
                Drawable drawable = mDrawableRightButton[idxDrawable];
                return(drawable);
            }

            return(null);
        }
コード例 #16
0
        public override Drawable[] GetCalloutRightAccessory(NMapOverlayItem item)
        {
            if (item is NMapPOIitem poiItem)
            {
                if (poiItem.HasRightAccessory && (poiItem.RightAccessoryId > 0))
                {
                    Drawable[] drawable = new Drawable[3];

                    switch (poiItem.RightAccessoryId)
                    {
                    case NMapPOIflagType.CLICKABLE_ARROW:
                        drawable[0] = ContextCompat.GetDrawable(MContext, Resource.Drawable.pin_ballon_arrow);
                        drawable[1] = ContextCompat.GetDrawable(MContext, Resource.Drawable.pin_ballon_on_arrow);
                        drawable[2] = ContextCompat.GetDrawable(MContext, Resource.Drawable.pin_ballon_on_arrow);
                        break;
                    }

                    return(drawable);
                }
            }

            return(null);
        }
コード例 #17
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;
                }
            }
        }
コード例 #18
0
 public override Drawable GetDrawableForInfoLayer(NMapOverlayItem p0)
 {
     return(null);
 }
コード例 #19
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;
        }