Пример #1
0
  @Override
  public void run() {
    // TODO Auto-generated method stub
    try {
      btnBackMap = (Button) findViewById(R.id.btnBackMap);
      btnDirection = (Button) findViewById(R.id.btnDirection);
      // Get intent and receive data from the parent activity
      Intent intent = getIntent();
      Bundle bundle = intent.getExtras();
      respectLocation = (PlaceModel) bundle.getSerializable("currentplace");
      curLAT = bundle.getDouble("currentLatitude");
      curLNG = bundle.getDouble("currentLongitude");

      // Set the coordinate for from-point
      if (fromLocation == null) {
        fromLocation = new PlaceModel();
        fromLocation.setLat(curLAT);
        fromLocation.setLng(curLNG);
      }

      // zoom to current place
      zoomToCurrentPlace();
      // draw place
      drawPlace();

      // buttonOnClick, button Zoom on map
      setButtonClick();
      map.setBuiltInZoomControls(true);
      map.invalidate();
    } catch (Exception e) {
    }
    handler.sendEmptyMessage(0);
  }
Пример #2
0
  public void drawPlace() {
    // Prepare overlays: Center overlay and Details overlay
    Drawable marker = getResources().getDrawable(R.drawable.marker);
    Drawable centermarker = getResources().getDrawable(R.drawable.centermarker);
    centermarker.setBounds(0, 0, marker.getIntrinsicWidth(), marker.getIntrinsicHeight());
    centerOverlay = new SitesOverlay(centermarker);
    Drawable detailmarker = getResources().getDrawable(R.drawable.star);
    detailmarker.setBounds(0, 0, marker.getIntrinsicWidth(), marker.getIntrinsicHeight());
    detailOverlay = new SitesOverlay(detailmarker);

    // Add remain overlays into map
    centerOverlay.addItem(
        new OverlayItem(
            getPoint(curLAT, curLNG), "My Location", "My Location\n" + curLAT + " - " + curLNG));
    centerOverlay.completeToPopulate();

    // add user location
    map.getOverlays().add(centerOverlay);
    map.getOverlays().add(me);

    if (respectLocation != null) {
      // Draw position to map
      double detailLAT = respectLocation.getLat();
      double detailLNG = respectLocation.getLng();
      String address = "";
      address +=
          respectLocation.getHouse_number()
              + ", "
              + respectLocation.getStreet()
              + ", "
              + respectLocation.getWard()
              + ", "
              + respectLocation.getDistrict()
              + ", "
              + respectLocation.getCity();
      String des =
          respectLocation.getName() + "\n" + address + "\n" + detailLAT + " - " + detailLNG;
      detailOverlay.addItem(
          new OverlayItem(getPoint(detailLAT, detailLNG), respectLocation.getName(), des));
      detailOverlay.completeToPopulate();
      map.getOverlays().add(detailOverlay);

      // Get route direction and list route point to draw map
      fromLat = fromLocation.getLat();
      fromLng = fromLocation.getLng();
      try {
        ms.getRoute(respectLocation, fromLat, fromLng, "en");
        listRoutePoint = ms.getListPathPoint();
      } catch (Exception e) {
      }
      directionEN = ms.getDirection();
      statusDirection = ms.getStatusDirection();

      // can not find the direction, listRoutePoint == null
      if (!statusDirection.equals("OK")) {
        detailOverlay.addItem(
            new OverlayItem(getPoint(detailLAT, detailLNG), respectLocation.getName(), des));
        detailOverlay.completeToPopulate();
        map.getOverlays().add(detailOverlay);
      }
    }
  }
Пример #3
0
 public void zoomToCurrentPlace() {
   // zoom to Place location
   GeoPoint point = getPoint(respectLocation.getLat(), respectLocation.getLng());
   mc.setZoom(16);
   mc.setCenter(point);
 }