在百度地图基础上 自定义了一个弹出框 实现一些文字的介绍 页面的跳转 比如调到导航之类的
final View popupView = LayoutInflater.from(context).inflate(R.layout.baidu_popwindow, null); //自定义的布局 final InfoWindow mInfoWindow = new InfoWindow(popupView, pt, -80); //设置弹窗的偏移位置 mBaiduMap.setOnMarkerClickListener(new BaiduMap.OnMarkerClickListener() {//根据百度marker图标的点击来判断是否显示布局 @Override public boolean onMarkerClick(Marker marker) { if (popupView.isShown()) { mBaiduMap.hideInfoWindow(); //隐藏 } else { mBaiduMap.showInfoWindow(mInfoWindow);//显示 } return true; } }); RelativeLayout image_xx = (RelativeLayout) popupView.findViewById(R.id.ll_guanbi); TextView text_baidutell = (TextView) popupView.findViewById(R.id.text_baidutell); String tel = getIntent().getStringExtra("tel"); //创建一个 SpannableString对象 SpannableString msp = new SpannableString(tel); //设置字体前景色 msp.setSpan(new ForegroundColorSpan(Color.GREEN), 0, tel.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); //设置前景色 text_baidutell.setText(msp); TextView text_baidudizhi = (TextView) popupView.findViewById(R.id.text_baidudizhi); text_baidudizhi.setText(getIntent().getStringExtra("StationDesc")); TextView text_name = (TextView) popupView.findViewById(R.id.text_name); text_name.setText(getIntent().getStringExtra("name")); Button butnsss = (Button) popupView.findViewById(R.id.butnsss);
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:clipToPadding="true" android:fitsSystemWindows="true" android:gravity="center_horizontal" android:orientation="vertical"> <LinearLayout android:layout_width="250dp" android:layout_height="wrap_content" android:background="@drawable/actionsheet_single_normal" android:orientation="vertical"> <RelativeLayout android:id="@+id/ll_guanbi" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginBottom="3dp"> <ImageView android:id="@+id/image_xx" android:layout_width="15dp" android:layout_height="15dp" android:layout_alignParentRight="true" android:src="@mipmap/x" /> <TextView android:id="@+id/text_name" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginLeft="10dp" android:layout_marginTop="5dp" android:gravity="left" android:textColor="@color/green" android:textSize="18sp" /> </RelativeLayout> <View android:layout_width="match_parent" android:layout_height="1dp" android:layout_marginLeft="10dp" android:layout_marginRight="10dp" android:background="@color/grey" /> <RelativeLayout android:layout_width="match_parent" android:layout_height="wrap_content"> <TextView android:id="@+id/text_telll" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="10dp" android:layout_marginTop="3dp" android:text="电话:" android:textColor="@color/green" android:textSize="16sp" /> <TextView android:id="@+id/text_baidutell" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="10dp" android:layout_marginTop="3dp" android:layout_toRightOf="@+id/text_telll" android:autoLink="all" android:textColor="@color/btn_green_normal" android:textSize="16sp" /> <TextView android:id="@+id/text_dizhi" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@+id/text_telll" android:layout_marginBottom="5dp" android:layout_marginLeft="10dp" android:text="地址:" android:textColor="@color/green" android:textSize="16sp" /> <TextView android:id="@+id/text_baidudizhi" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@+id/text_telll" android:layout_marginBottom="5dp" android:layout_marginLeft="10dp" android:layout_toRightOf="@+id/text_dizhi" android:maxLines="3" android:textColor="@color/green" android:textSize="16sp" /> <Button android:id="@+id/butnsss" android:layout_width="170dp" android:layout_height="25dp" android:layout_below="@+id/text_baidudizhi" android:layout_centerHorizontal="true" android:layout_marginBottom="5dp" android:background="@drawable/btn_green_selector" android:text="到这去" /> </RelativeLayout> </LinearLayout> </LinearLayout>
效果如图
简单一点的问题提示 用自带的方法就行了
/* * 文字提示功能 位置在当前坐标下 * */ // 文字,在地图中也是一种覆盖物,开发者可利用相关的接口,快速实现在地图上书写文字的需求。实现方式如下: // 定义文字所显示的坐标点 LatLng llText = new LatLng(latx, laty); //文字显示的坐标 // 构建文字Option对象,用于在地图上添加文字 //rotate 偏移量 OverlayOptions textOption = new TextOptions().bgColor(0xAAFFFF00).fontSize(28).fontColor(0xFFFF00FF) .text("当前位置").rotate(0).position(llText); // 在地图上添加该文字对象并显示 mBaiduMap.addOverlay(textOption);