Example #1
0
        void OnMarkerClick(object sender, BaiduMap.MarkerClickEventArgs e)
        {
            if (!string.IsNullOrEmpty(e.P0.Title))
            {
                TextView view = new TextView(Context);
                view.SetPadding(20, 20, 20, 20);
                view.SetBackgroundColor(Color.White.ToAndroid());
                view.Background.SetAlpha(100);
                view.Text = e.P0.Title;

                NativeMap.Map.ShowInfoWindow(
                    new InfoWindow(view, e.P0.Position, -e.P0.Icon.Bitmap.Height)
                    );
            }

            Map.Pins.Find(e.P0)?.SendClicked();
        }
Example #2
0
        /// <summary>
        /// 标注点击时
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnMarkerClick(object sender, BaiduMap.MarkerClickEventArgs e)
        {
            try
            {
                if (!string.IsNullOrEmpty(e.P0.Title))
                {
                    var pin = Map.Pins.Find(e.P0);
                    if (pin?.Terminal != null)
                    {
                        var color = pin?.Terminal?.RankColor ?? "#4a89dc";

                        //cardView
                        var cardView = new CardView(Context)
                        {
                            Radius = 15
                        };
                        cardView.SetCardBackgroundColor(Color.FromHex(color).ToAndroid());

                        //布局
                        var layout = new LinearLayout(Context)
                        {
                            Orientation = Orientation.Vertical
                        };
                        layout.SetPadding(10, 10, 10, 10);

                        //Title
                        var tview = new TextView(Context);
                        tview.SetPadding(10, 10, 10, 10);
                        tview.SetTextColor(Color.White.ToAndroid());
                        tview.TextSize = 12;
                        tview.Text     = e.P0.Title;

                        //Button
                        var param = new LayoutParams(LayoutParams.MatchParent, LayoutParams.MatchParent)
                        {
                            Height = 45
                        };
                        var button = new Android.Widget.Button(Context);
                        button.Text             = "去拜访";
                        button.TextSize         = 10;
                        button.LayoutParameters = param;
                        button.SetBackgroundResource(Resource.Drawable.roundShape);
                        button.SetTextColor(Color.White.ToAndroid());
                        button.Click += (sender, ar) =>
                        {
                            var pin = Map.Pins.Find(e.P0);
                            pin?.SendClicked(pin?.Terminal);
                        };

                        layout.AddView(tview);
                        layout.AddView(button);

                        cardView.AddView(layout);

                        var window = new InfoWindow(cardView, e.P0.Position, -e.P0.Icon.Bitmap.Height);
                        NativeMap.Map.ShowInfoWindow(window);
                    }
                }
            }
            catch (Exception)
            {
            }
        }
Example #3
0
 private void Map_MarkerClick(object sender, BaiduMap.MarkerClickEventArgs e)
 {
     System.Diagnostics.Debug.Print(e.P0.Title);
 }