コード例 #1
0
 @Override
 public boolean onMarkerClick(Marker arg0) {
   if (isClickStart) {
     arg0.setSnippet("点击此处选择为起点");
   } else if (isClickTarget) {
     arg0.setSnippet("点击此处选择为终点");
   }
   arg0.showInfoWindow();
   return false;
 }
コード例 #2
0
  /** 设置点击Marker的InfoWindow事件 */
  @Override
  public void onInfoWindowClick(Marker arg0) {
    if (isClickStart) {
      startTextView.setText(arg0.getTitle());
      startPoint = convertToLatLonPoint(arg0.getPosition());
      isClickStart = false;
      isClickTarget = true;

    } else if (isClickTarget) {
      endTextView.setText(arg0.getTitle());
      endPoint = convertToLatLonPoint(arg0.getPosition());
      isClickStart = true;
      isClickTarget = false;
    }
    arg0.hideInfoWindow();
  }
コード例 #3
0
  /** 添加驾车路线添加到地图上显示。 */
  public void addToMap() {
    initPolylineOptions();
    try {
      if (mAMap == null) {
        return;
      }

      if (mWidth == 0 || drivePath == null) {
        return;
      }
      mLatLngsOfPath = new ArrayList<LatLng>();
      tmcs = new ArrayList<TMC>();
      List<DriveStep> drivePaths = drivePath.getSteps();
      mPolylineOptions.add(startPoint);
      for (DriveStep step : drivePaths) {
        List<LatLonPoint> latlonPoints = step.getPolyline();
        List<TMC> tmclist = step.getTMCs();
        tmcs.addAll(tmclist);
        // addDrivingStationMarkers(step, convertToLatLng(latlonPoints.get(0)));
        for (LatLonPoint latlonpoint : latlonPoints) {
          mPolylineOptions.add(convertToLatLng(latlonpoint));
          mLatLngsOfPath.add(convertToLatLng(latlonpoint));
        }
      }
      mPolylineOptions.add(endPoint);
      if (startMarker != null) {
        startMarker.remove();
        startMarker = null;
      }
      if (endMarker != null) {
        endMarker.remove();
        endMarker = null;
      }
      //            addStartAndEndMarker();
      //            addThroughPointMarker();
      if (isColorfulline && tmcs.size() > 0) {
        colorWayUpdate(tmcs);
      } else {
        showPolyline();
      }

    } catch (Throwable e) {
      e.printStackTrace();
    }
  }
コード例 #4
0
  @Override
  public View getInfoWindow(final Marker marker) {
    View view = getLayoutInflater().inflate(R.layout.poikeywordsearch_uri, null);
    TextView title = (TextView) view.findViewById(R.id.title);
    title.setText(marker.getTitle());

    TextView snippet = (TextView) view.findViewById(R.id.snippet);
    snippet.setText(marker.getSnippet());
    ImageButton button = (ImageButton) view.findViewById(R.id.start_amap_app);
    // 调起高德地图app导航功能
    button.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View v) {
            startAMapNavi(marker);
          }
        });
    return view;
  }
コード例 #5
0
 /** 去掉DriveLineOverlay上的线段和标记。 */
 public void removeFromMap() {
   try {
     if (startMarker != null) {
       startMarker.remove();
     }
     if (endMarker != null) {
       endMarker.remove();
     }
     for (Marker marker : stationMarkers) {
       marker.remove();
     }
     for (Polyline line : allPolyLines) {
       line.remove();
     }
     if (this.throughPointMarkerList != null && this.throughPointMarkerList.size() > 0) {
       for (int i = 0; i < this.throughPointMarkerList.size(); i++) {
         this.throughPointMarkerList.get(i).remove();
       }
       this.throughPointMarkerList.clear();
     }
   } catch (Throwable e) {
     e.printStackTrace();
   }
 }
コード例 #6
0
 /** 调起高德地图导航功能,如果没安装高德地图,会进入异常,可以在异常中处理,调起高德地图app的下载页面 */
 public void startAMapNavi(Marker marker) {
   // 构造导航参数
   NaviPara naviPara = new NaviPara();
   // 设置终点位置
   naviPara.setTargetPoint(marker.getPosition());
   // 设置导航策略,这里是避免拥堵
   naviPara.setNaviStyle(AMapUtils.DRIVING_AVOID_CONGESTION);
   try {
     // 调起高德地图导航
     AMapUtils.openAMapNavi(naviPara, getApplicationContext());
   } catch (com.amap.api.maps.AMapException e) {
     // 如果没安装会进入异常,调起下载页面
     AMapUtils.getLatestAMapApp(getApplicationContext());
   }
 }
コード例 #7
0
 @Override
 public boolean onMarkerClick(Marker marker) {
   marker.showInfoWindow();
   return false;
 }
コード例 #8
0
 @Override
 public View getInfoWindow(Marker arg0) {
   return getInfoView(context, arg0.getTitle());
 }