Пример #1
0
  private void showMapViewRoutes(List<GPSInfo> lstWgs84HashMap) {
    ArrayList<GeoPoint> lstWgs84GeoPoint = RoutesHelper.getWgs84GeoPoint(lstWgs84HashMap);

    // mRoutesOverlay
    if (mMapView != null) {
      try {
        if (mRoutesOverlay != null) {
          if (mMapView.getOverlays().contains(mRoutesOverlay)) {
            mMapView.getOverlays().remove(mRoutesOverlay);
            mRoutesOverlay = null;
          }
        }
        mRoutesOverlay = new RoutesOverlay(mPathActivity, mMapView);
        {
          mRoutesOverlay.setOnOverlayEventListener(this);

          mRoutesOverlay.setData(lstWgs84GeoPoint);
        }
        mMapView.getOverlays().add(0, mRoutesOverlay);
        mMapView.invalidate();
        mMapView.getController().animateTo(lstWgs84GeoPoint.get(0));
      } catch (Exception e) {
        e.printStackTrace();
      }
    }
  }
  @Override
  public void onClick(View v) {
    switch (v.getId()) {
      case R.id.btnAddress:
        mapView.getOverlays().clear(); // 清除公交站点的标识
        mapView.invalidate();
        GeoPoint geoPoint = new GeoPoint((int) (39.915 * 1e6), (int) (116.454 * 1e6));
        EditText tvAdr = (EditText) findViewById(R.id.etAddress);
        // 根据中心点geoPoint在1000半径内查询KFC
        mkSearch.poiSearchNearBy(tvAdr.getText().toString(), geoPoint, 5000);
        //			GeoPoint geoPoint=new GeoPoint(39904965, 116327764);
        //			mkSearch.reverseGeocode(geoPoint);
        break;
      case R.id.btnLine:
        mapView.getOverlays().clear(); // 清除公交站点的标识
        EditText etLine = (EditText) findViewById(R.id.etLine);
        mkSearch.poiSearchInCity("北京", etLine.getText().toString());
        //			EditText etadd=(EditText) findViewById(R.id.etAddress);
        //			mkSearch.geocode("北京", etadd.getText().toString());
        break;

      default:
        break;
    }
  }
 public void hideAllBalloons() {
   if (!isInflating) {
     List<Overlay> mapOverlays = mapView.getOverlays();
     if (mapOverlays.size() > 1) {
       hideOtherBalloons(mapOverlays);
     }
     hideBalloon();
   }
 }
Пример #4
0
  protected void onHandlerSuccess(Object obj) {
    mActionBar.setProgressBarVisibility(View.GONE);
    if (obj != null) {
      @SuppressWarnings("unchecked")
      List<GPSInfo> lstWgs84HashMap = (List<GPSInfo>) obj;
      if (lstWgs84HashMap.size() > 0) { // 至少得有一个点嘛(第一个,最后一个有没有可能一样呢?有的)
        showMapViewRoutes(lstWgs84HashMap);
      } else {
        ToastShow.show(mPathActivity, R.string.datetime_toast_nodata);

        if (mMapView.getOverlays().contains(mRoutesOverlay)) {
          mMapView.getOverlays().remove(mRoutesOverlay);
          // mRoutesOverlay.onDestroy();
          mRoutesOverlay = null;
        }
        // if (mMapView.getOverlays().contains(mMovingOverlay)) {
        // mMapView.getOverlays().remove(mMovingOverlay);
        // mMovingOverlay.onDestroy();
        // mMovingOverlay = null;
        // }
      }
    }
  }
Пример #5
0
  private void checkInitMap() {
    if (mMapView == null) {
      mMapView = (MapView) findViewById(R.id.path_mapview);
      // 设置是否启用内置的缩放控件
      mMapView.setBuiltInZoomControls(true);
      // 设置在缩放动画过程中也显示overlay,默认为不绘制
      mMapView.setDrawOverlayWhenZooming(true);
      // mMapView.getOverlays().clear();

      // 添加定位图层
      mMxLocationOverlay = new MxLocationOverlay(mPathActivity, mMapView);
      mMxLocationOverlay.setOnOverlayEventListener(this);
      mMapView.getOverlays().add(mMxLocationOverlay);

      // 添加汽车图层
      mCaricoOverlay = new BitmapOverlay(mPathActivity, mMapView);
      mCaricoOverlay.setBitmap("rmct_routes_car.png");
      mMapView.getOverlays().add(mCaricoOverlay);

      mBtnBegTime = (Button) findViewById(R.id.path_begtime);
      mBtnEndTime = (Button) findViewById(R.id.path_endtime);
      mBtnBegTime.setOnClickListener(this);
      mBtnEndTime.setOnClickListener(this);

      mActionBar = (ActionBar) findViewById(R.id.path_actionbar);
      mActionBar.setRootView(findViewById(R.id.path_main));
      mViewback = mActionBar.showBackButton();
      mViewback.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View v) {
              PathActivity.this.finish();
            }
          });
    }
  }
Пример #6
0
  @Override
  public void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    mBMapMan = new BMapManager(getApplication());
    mBMapMan.init("C852FAE280E276186DE82EB547721866666283B0", null);
    super.initMapActivity(mBMapMan);

    mapView = (MapView) findViewById(R.id.mapview);
    mapView.setBuiltInZoomControls(true);

    mapOverlays = mapView.getOverlays();

    // first overlay
    drawable = getResources().getDrawable(R.drawable.marker);
    itemizedOverlay = new CustomItemizedOverlay<CustomOverlayItem>(drawable, mapView);

    GeoPoint point = new GeoPoint((int) (39.90923 * 1E6), (int) (116.397428 * 1E6));
    CustomOverlayItem overlayItem =
        new CustomOverlayItem(
            point,
            "Tomorrow Never Dies (1997)",
            "(M gives Bond his mission in Daimler car)",
            "http://ia.media-imdb.com/images/M/MV5BMTM1MTk2ODQxNV5BMl5BanBnXkFtZTcwOTY5MDg0NA@@._V1._SX40_CR0,0,40,54_.jpg");
    itemizedOverlay.addOverlay(overlayItem);

    GeoPoint point2 = new GeoPoint((int) (39.9022 * 1E6), (int) (116.3922 * 1E6));
    CustomOverlayItem overlayItem2 =
        new CustomOverlayItem(
            point2,
            "GoldenEye (1995)",
            "(Interiors Russian defence ministry council chambers in St Petersburg)",
            "http://ia.media-imdb.com/images/M/MV5BMzk2OTg4MTk1NF5BMl5BanBnXkFtZTcwNjExNTgzNA@@._V1._SX40_CR0,0,40,54_.jpg");
    itemizedOverlay.addOverlay(overlayItem2);

    mapOverlays.add(itemizedOverlay);

    // second overlay
    drawable2 = getResources().getDrawable(R.drawable.marker2);
    itemizedOverlay2 = new CustomItemizedOverlay<CustomOverlayItem>(drawable2, mapView);

    GeoPoint point3 = new GeoPoint((int) (39.917723 * 1E6), (int) (116.3722 * 1E6));
    CustomOverlayItem overlayItem3 =
        new CustomOverlayItem(point3, "Sliding Doors (1998)", "(interiors)", null);
    itemizedOverlay2.addOverlay(overlayItem3);

    GeoPoint point4 = new GeoPoint((int) (51.51738 * 1E6), (int) (-0.08186 * 1E6));
    CustomOverlayItem overlayItem4 =
        new CustomOverlayItem(
            point4,
            "Mission: Impossible (1996)",
            "(Ethan & Jim cafe meeting)",
            "http://ia.media-imdb.com/images/M/MV5BMjAyNjk5Njk0MV5BMl5BanBnXkFtZTcwOTA4MjIyMQ@@._V1._SX40_CR0,0,40,54_.jpg");
    itemizedOverlay2.addOverlay(overlayItem4);

    mapOverlays.add(itemizedOverlay2);

    final MapController mc = mapView.getController();
    mc.animateTo(point2);
    mc.setZoom(16);
  }
  /**
   * Creates and displays the balloon overlay by recycling the current balloon or by inflating it
   * from xml.
   *
   * @return true if the balloon was recycled false otherwise
   */
  private boolean createAndDisplayBalloonOverlay() {
    boolean isRecycled;
    if (balloonView == null) {
      balloonView = createBalloonOverlayView();
      clickRegion = balloonView.findViewById(R.id.balloon_inner_layout);
      clickRegion.setOnTouchListener(createBalloonTouchListener());
      closeRegion = balloonView.findViewById(R.id.balloon_close);
      if (closeRegion != null) {
        if (!showClose) {
          closeRegion.setVisibility(View.GONE);
        } else {
          closeRegion.setOnClickListener(
              new OnClickListener() {
                @Override
                public void onClick(View v) {
                  hideBalloon();
                }
              });
        }
      }
      if (showDisclosure && !showClose) {
        View v = balloonView.findViewById(R.id.balloon_disclosure);
        if (v != null) {
          v.setVisibility(View.VISIBLE);
        }
      }
      isRecycled = false;
    } else {
      isRecycled = true;
    }

    balloonView.setVisibility(View.GONE);

    List<Overlay> mapOverlays = mapView.getOverlays();
    if (mapOverlays.size() > 1) {
      hideOtherBalloons(mapOverlays);
    }

    if (currentFocusedItem != null) {
      balloonView.setData(currentFocusedItem);
    }

    GeoPoint point = currentFocusedItem.getPoint();
    MapView.LayoutParams params =
        new MapView.LayoutParams(
            LayoutParams.WRAP_CONTENT,
            LayoutParams.WRAP_CONTENT,
            point,
            MapView.LayoutParams.BOTTOM_CENTER);
    params.mode = MapView.LayoutParams.MODE_MAP;

    balloonView.setVisibility(View.VISIBLE);

    if (isRecycled) {
      balloonView.setLayoutParams(params);
    } else {
      mapView.addView(balloonView, params);
    }

    return isRecycled;
  }