示例#1
0
 /** 对marker标注点点击响应事件 */
 @Override
 public boolean onMarkerClick(Marker marker) {
   // TODO Auto-generated method stub
   /// 如果点击当前点,则不响应.
   /// 如果是其他的点,则跳转到该点的详细界面
   if (marker.getId().equals(marker_id)) {
     ToastUtil.show(this, "你点击的是主marker " + marker.getId());
     onMarkerClick();
   } else {
     ToastUtil.show(this, "你点击的是辅marker " + marker.getId());
     onAssistMarkerClick(marker.getId());
   }
   return false;
 }
示例#2
0
 /** 监听自定义infowindow窗口的infowindow事件回调 */
 @Override
 public View getInfoWindow(Marker marker) {
   // TODO Auto-generated method stub
   View infoWindow;
   if (marker.getId().equals(marker_id))
     infoWindow = getLayoutInflater().inflate(R.layout.main_info_window, null);
   else infoWindow = getLayoutInflater().inflate(R.layout.main_info_window_2, null);
   render(marker, infoWindow);
   return infoWindow;
 }
示例#3
0
 /** 监听自定义infowindow窗口的infocontents事件回调 */
 @Override
 public View getInfoContents(Marker marker) {
   // TODO Auto-generated method stub
   View infoContent;
   if (marker.getId().equals(marker_id))
     infoContent = getLayoutInflater().inflate(R.layout.main_info_contents, null);
   else infoContent = getLayoutInflater().inflate(R.layout.main_info_contents, null);
   render(marker, infoContent);
   return infoContent;
 }
示例#4
0
 /** 添加辅助marker LatLng 要显示的位置 View marker的图标 */
 private String drawAssistMarkers(LatLng latlng, View view) {
   Marker marker =
       aMap.addMarker(
           new MarkerOptions()
               .position(latlng) // 设置当前MarkerOptions 对象的经纬度。
               .icon(BitmapDescriptorFactory.fromView(view))
               .draggable(true) // 设标记是否可被拖动
           );
   marker.showInfoWindow(); // 设置默认显示一个infowinfow
   return marker.getId();
 }
示例#5
0
 /** 自定义infowinfow窗口, 设置title 和 snippet 的内容 */
 public void render(Marker marker, View view) {
   if (!marker.getId().equals(marker_id)) return;
   String title = marker.getTitle();
   TextView titleUi = ((TextView) view.findViewById(R.id.main_infowindow_textview_title_id));
   if (title != null) {
     SpannableString titleText = new SpannableString(title);
     titleUi.setText(titleText);
     Log.e("title", titleText.toString());
   } else {
     titleUi.setText("");
   }
   if (marker.getId().equals(marker_id)) {
     String snippet = marker.getSnippet();
     TextView snippetUi = ((TextView) view.findViewById(R.id.main_infowindow_textview_snippet_id));
     if (snippet != null) {
       SpannableString snippetText = new SpannableString(snippet);
       snippetUi.setText(snippetText);
       Log.e("snippet", snippetText.toString());
     } else {
       titleUi.setText("");
     }
   }
 }
示例#6
0
 /** 绘制系统默认的1种marker 背景图片 LatLng 要显示的坐标位置 title Marker标题的内容 snippet Marker标题snippet的内容 */
 private void drawMainMarkers(LatLng latlng, String title, String snippet) {
   Marker marker =
       aMap.addMarker(
           new MarkerOptions()
               .position(latlng) // 设置当前MarkerOptions 对象的经纬度。
               .title(title) // 设置 Marker 的标题
               .snippet(snippet) // 设置 Marker 上的 snippet
               .icon(
                   BitmapDescriptorFactory.fromResource(
                       R.drawable.main_map_position)) // 设置marker 图标
               .draggable(true) // 设标记是否可被拖动
           );
   marker_id = marker.getId();
   marker.showInfoWindow(); // 设置默认显示一个infowinfow
 }