public void InitOverlay() { /** * 创建自定义overlay */ mOverlay = new MyOverlay(this, Resources.GetDrawable(Resource.Drawable.icon_marka), mMapView); /** * 准备overlay 数据 */ GeoPoint p1 = new GeoPoint((int)(mLat1 * 1E6), (int)(mLon1 * 1E6)); OverlayItem item1 = new OverlayItem(p1, "覆盖物1", ""); /** * 设置overlay图标,如不设置,则使用创建ItemizedOverlay时的默认图标. */ item1.Marker = Resources.GetDrawable(Resource.Drawable.icon_marka); GeoPoint p2 = new GeoPoint((int)(mLat2 * 1E6), (int)(mLon2 * 1E6)); OverlayItem item2 = new OverlayItem(p2, "覆盖物2", ""); item2.Marker = Resources.GetDrawable(Resource.Drawable.icon_markb); GeoPoint p3 = new GeoPoint((int)(mLat3 * 1E6), (int)(mLon3 * 1E6)); OverlayItem item3 = new OverlayItem(p3, "覆盖物3", ""); item3.Marker = Resources.GetDrawable(Resource.Drawable.icon_markc); GeoPoint p4 = new GeoPoint((int)(mLat4 * 1E6), (int)(mLon4 * 1E6)); OverlayItem item4 = new OverlayItem(p4, "覆盖物4", ""); item4.Marker = Resources.GetDrawable(Resource.Drawable.icon_gcoding); /** * 将item 添加到overlay中 * 注意: 同一个itme只能add一次 */ mOverlay.AddItem(item1); mOverlay.AddItem(item2); mOverlay.AddItem(item3); mOverlay.AddItem(item4); /** * 保存所有item,以便overlay在reset后重新添加 */ mItems = new List<OverlayItem>(); mItems.AddRange(mOverlay.AllItem); // 初始化 ground 图层 mGroundOverlay = new GroundOverlay(mMapView); GeoPoint leftBottom = new GeoPoint((int)(mLat5 * 1E6), (int)(mLon5 * 1E6)); GeoPoint rightTop = new GeoPoint((int)(mLat6 * 1E6), (int)(mLon6 * 1E6)); Drawable d = Resources.GetDrawable(Resource.Drawable.ground_overlay); Bitmap bitmap = ((BitmapDrawable)d).Bitmap; mGround = new Ground(bitmap, leftBottom, rightTop); /** * 将overlay 添加至MapView中 */ mMapView.Overlays.Add(mOverlay); mMapView.Overlays.Add(mGroundOverlay); mGroundOverlay.AddGround(mGround); /** * 刷新地图 */ mMapView.Refresh(); mResetBtn.Enabled = false; mClearBtn.Enabled = true; /** * 向地图添加自定义View. */ viewCache = LayoutInflater.Inflate(Resource.Layout.custom_text_view, null); popupInfo = viewCache.FindViewById<View>(Resource.Id.popinfo); popupLeft = viewCache.FindViewById<View>(Resource.Id.popleft); popupRight = viewCache.FindViewById<View>(Resource.Id.popright); popupText = viewCache.FindViewById<TextView>(Resource.Id.textcache); button = new Button(this); button.SetBackgroundResource(Resource.Drawable.popup); /** * 创建一个popupoverlay */ IPopupClickListener popListener = new IPopupClickListenerImpl(this); pop = new PopupOverlay(mMapView, popListener); }
/** * 创建弹出泡泡图层 */ public void CreatePaopao() { ////泡泡点击响应回调 IPopupClickListener popListener = new IPopupClickListenerImpl(); pop = new PopupOverlay(mMapView, popListener); }