예제 #1
0
  public void showBudburstSpeciesOnMap(boolean hasHandler) {

    // TODO Auto-generated method stub
    otDBH = new OneTimeDBHelper(MapViewMain.this);

    GeoPoint gPoint = new GeoPoint((int) (mLatitude * 1000000), (int) (mLongitude * 1000000));

    mMapView.setBuiltInZoomControls(true);
    mMapView.invalidate();

    if (getMyListsFromDB()) {
      Log.i("K", "Get species lists from the database");

      // add overlays on the map
      mMapView.getOverlays().clear();
      mMapView.getOverlays().add(new SpeciesMapOverlay(mMapView, mMarker, mPlantList));
      mMapView.getOverlays().add(mMyOverLay);

      titleBar.setText("Total number of species : " + mPlantList.size());

      mMapController.setCenter(gPoint);

      if (hasHandler) {
        mHandlerDone = true;
        mHandler.sendEmptyMessage(GET_MY_OBSERVED_LISTS);
        mMapController.setZoom(12);
      }
    } else {
      Toast.makeText(MapViewMain.this, "Please make your own observation", Toast.LENGTH_SHORT)
          .show();
      Log.i("K", "No species lists in the database.");
    }
  }
예제 #2
0
  // Set Map Center position
  public void setMapCenter(GeoPoint point) {
    MapController ctl = mapView.getController();
    if (point == null) {

      Location loc = mCurrentLocation;
      if (loc == null) {
        ctl.setCenter(mDefaultCurrentLocation);
      } else {
        ctl.setCenter(
            new GeoPoint((int) (loc.getLatitude() * 1e6), (int) (loc.getLongitude() * 1e6)));
      }
    } else {

      ctl.setCenter(point);
    }
  }
예제 #3
0
 @Override
 public void onStart() {
   super.onStart();
   mapController = mapView.getController();
   mapController.setCenter(homeLocation);
   mapOverlays = mapView.getOverlays();
   mapOverlays.add(new MapKeyOverlay(this, null, 0, null));
   mapView.invalidate();
 }
예제 #4
0
 protected void setPointerFromCursor(Cursor c, int zoomLevel) {
   final GeoPoint gp = MapsUtils.getGeoPoint(c);
   if (mCurrentPointer == null || !mCurrentPointer.equals(gp)) {
     setPointer(gp);
     mMapController.setCenter(gp);
     mMapController.setZoom(zoomLevel);
     mCurrentPointer = gp;
   }
 }
예제 #5
0
  private void inicializeMap() {
    mapView = (MapView) findViewById(R.id.map);
    mapView.setBuiltInZoomControls(true);
    mapController = mapView.getController();
    mapController.setZoom(16);
    if (latitud != 0 && longitud != 0) {
      int lat = (int) (latitud * 1E6);
      int lon = (int) (longitud * 1E6);

      mapController.animateTo(new GeoPoint(lat, lon));
      mapController.setCenter(new GeoPoint(lat, lon));
    }
    centerMyPosition();
  }
예제 #6
0
  @Override
  protected void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    setContentView(R.layout.activity_guidemap);

    guideMapView = (MapView) findViewById(R.id.guideMapView);
    guideMapView.setBuiltInZoomControls(true);

    Intent intent = getIntent();
    GeoPoint geoPoint = getGeoPoint(intent.getStringExtra("msg"));

    MapController mapController = guideMapView.getController();
    mapController.setCenter(geoPoint);
    mapController.setZoom(18);
  }
예제 #7
0
        @Override
        public void onReceive(Context context, Intent intent) {
          // TODO Auto-generated method stub
          Bundle extras = intent.getExtras();

          if (extras.getBoolean("signal")) {
            mLatitude = extras.getDouble("latitude");
            mLongitude = extras.getDouble("longitude");

            // convert points into GeoPoint
            GeoPoint gPoint = getPoint(mLatitude, mLongitude);

            // center the map
            if (mFirstGps) {
              mMapController.setCenter(gPoint);
              mFirstGps = false;
            }

            if (mDialog != null) {
              mDialog.dismiss();
            }
          }
          // if Gps signal is bad
          else {
            new AlertDialog.Builder(MapViewMain.this)
                .setTitle("Weak Gps Signal")
                .setMessage(
                    "Cannot get Gps Signal, Make sure you are in the good connectivity area")
                .setPositiveButton(
                    getString(R.string.Button_back),
                    new DialogInterface.OnClickListener() {

                      @Override
                      public void onClick(DialogInterface dialog, int which) {
                        // TODO Auto-generated method stub
                      }
                    })
                .show();
          }
        }
  private void setMapCenter(Location location) {

    gc = new Geocoder(this);

    String placename = "";

    try {
      List<Address> place = gc.getFromLocation(location.getLatitude(), location.getLongitude(), 1);
      placename = "Location found: " + place.get(0).getLocality();

    } catch (IOException e) {
      placename =
          String.format("Location found (%s, %s)", location.getLatitude(), location.getLongitude());
    } catch (IndexOutOfBoundsException ioobe) {

    }

    Toast.makeText(this, placename, Toast.LENGTH_SHORT).show();

    Log.d(
        TAG,
        String.format("Location found (%s, %s)", location.getLatitude(), location.getLongitude()));

    controller = myMap.getController();
    zoomMax = myMap.getMaxZoomLevel();
    controller.setCenter(
        new GeoPoint((int) (location.getLatitude() * 1E6), (int) (location.getLongitude() * 1E6)));
    controller.setZoom(zoomMax);

    // put an overlay on the map
    Drawable marker = getResources().getDrawable(R.drawable.sphero_marker);
    int markerWidth = marker.getIntrinsicWidth();
    int markerHeight = marker.getIntrinsicHeight();
    marker.setBounds(0, markerHeight, markerWidth, 0);
    SpheroOverlay spheroOverlay = new SpheroOverlay(marker);
    myMap.getOverlays().add(spheroOverlay);
    spheroOverlay.addItem(locationToGeoPoint(location), "Sphero!", "This is where you're at.");
  }
 /**
  * Search the geo-location and zoom the map to that point.
  *
  * @param addressEntered The address entered by the user to search.
  */
 private void goToLocation(final String addressEntered) {
   if (!TextUtils.isEmpty(addressEntered.trim())) {
     Geocoder geoCode = new Geocoder(this);
     try {
       // Get top 5 matched address for this location.
       final List<Address> foundAdresses = geoCode.getFromLocationName(addressEntered, 5);
       if (foundAdresses.isEmpty()) {
         // If no address found, show error through toast.
         Toast.makeText(this, getResources().getText(R.string.error_message), Toast.LENGTH_LONG)
             .show();
       } else { // Else display address on map and
         // store results as longitude and latitude.
         Address address = foundAdresses.get(ZERO_INDEX);
         Double latitude = address.getLatitude() * 1E6;
         Double longitude = address.getLongitude() * 1E6;
         GeoPoint point = new GeoPoint(latitude.intValue(), longitude.intValue());
         List<Overlay> mapOverlays = mMapView.getOverlays();
         Drawable drawable = this.getResources().getDrawable(R.drawable.marker);
         MapsMarkerOverlay itemizedoverlay =
             new MapsMarkerOverlay(drawable, getApplicationContext());
         OverlayItem overlayitem = new OverlayItem(point, null, null);
         itemizedoverlay.addOverlay(overlayitem);
         if (mapOverlays.size() > 0) {
           mapOverlays.remove(0);
         }
         mapOverlays.add(itemizedoverlay);
         mMapView.preLoad();
         // Show the location in the center of the map.
         mMapController.setCenter(point);
         mMapController.animateTo(point);
         mMapController.setZoom(LOCATION_ZOOM_LEVEL);
         mMapView.invalidate();
       }
     } catch (IOException e) {
       e.printStackTrace();
     }
   }
 }
예제 #10
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.googlemaps);
    ActionBar actionBar = getActionBar();
    actionBar.setDisplayHomeAsUpEnabled(true);
    MapView mapView = (MapView) findViewById(R.id.mapview);
    mapView.setBuiltInZoomControls(true);
    MapController mapController = mapView.getController();
    GeoPoint point = new GeoPoint(42295938, -71297368);
    mapController.setCenter(point);
    mapController.setZoom(15);

    List<Overlay> mapOverlays = mapView.getOverlays();
    Drawable drawable = this.getResources().getDrawable(R.drawable.maparrow);
    MapItemizedOverlay itemizedoverlay = new MapItemizedOverlay(drawable, this);

    OverlayItem overlayitem =
        new OverlayItem(point, "Wellesley Books!", "82 Central St.\nWellesley, MA 02482");

    itemizedoverlay.addOverlay(overlayitem);
    mapOverlays.add(itemizedoverlay);
  }
예제 #11
0
  public void checkGpsIsOn() {
    // check if GPS is turned on...
    if (mLocManager.isProviderEnabled(android.location.LocationManager.GPS_PROVIDER)) {

      Location lastLoc = mLocManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
      if (lastLoc != null) {
        mLatitude = lastLoc.getLatitude();
        mLongitude = lastLoc.getLongitude();
        mMapController.setCenter(getPoint(mLatitude, mLongitude));
      }

      doBindService();
      // showBudburstSpeciesOnMap(false);
      getOtherUsersListsFromServer(GET_OTHERS_OBSERVATION);
    } else {

      new AlertDialog.Builder(MapViewMain.this)
          .setTitle("Turn On GPS")
          .setMessage(getString(R.string.Message_locationDisabledTurnOn))
          .setPositiveButton(
              getString(R.string.Button_yes),
              new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int whichButton) {
                  Intent intent = new Intent(Settings.ACTION_SECURITY_SETTINGS);
                  startActivityForResult(intent, 1);
                }
              })
          .setNegativeButton(
              getString(R.string.Button_no),
              new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int whichButton) {
                  finish();
                }
              })
          .show();
    }
  }
예제 #12
0
 public void zoomToCurrentPlace() {
   // zoom to Place location
   GeoPoint point = getPoint(respectLocation.getLat(), respectLocation.getLng());
   mc.setZoom(16);
   mc.setCenter(point);
 }
예제 #13
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);

    this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.custom);

    mEdit = (EditText) findViewById(R.id.input_text_main);
    getLinearLayout = (LinearLayout) findViewById(R.id.overview);

    Bundle extras = getIntent().getExtras();
    String value = "";
    String eventTitle = "";
    String eventTime = "";
    String description = "";
    String urlImage = "";
    String price = "";
    String add1 = "";
    String add2 = "";
    String latitude = "";
    String longitude = "";
    String venueName = "";

    if (extras != null) {
      value = extras.getString("EVENT_ID");
      eventTitle = extras.getString("EVENTNAME");
      eventTime = extras.getString("TIME");
      description = extras.getString("DESCRIPTION");
      urlImage = extras.getString("IMAGEURL");
      price = extras.getString("PRICE");
      add1 = extras.getString("ADD1");
      add2 = extras.getString("ADD2");
      latitude = extras.getString("LAT");
      longitude = extras.getString("LONG");
      venueName = extras.getString("VENUENAME");
      venueID = extras.getString("VENUEID");
    }

    TextView eventNameText = (TextView) findViewById(R.id.customEventName);
    eventNameText.setText(eventTitle);
    TextView eventTimeText = (TextView) findViewById(R.id.customEventTime);
    eventTimeText.setText(eventTime);
    TextView eventDesText = (TextView) findViewById(R.id.customEventDescription);
    eventDesText.setText(description);
    TextView eventPriceText = (TextView) findViewById(R.id.customEventPrice);
    eventPriceText.setText(price);
    TextView eventAdd1Text = (TextView) findViewById(R.id.customAdd1);
    eventAdd1Text.setText(add1);
    TextView eventAdd2Text = (TextView) findViewById(R.id.customAdd2);
    eventAdd2Text.setText(add2);
    p1_button = (Button) findViewById(R.id.customEventVenue);
    p1_button.setText(venueName);

    ImageView image = (ImageView) findViewById(R.id.customEventImage);
    if (!urlImage.equals("")) {

      // imageLoader.DisplayImage(imageUrl, image);
      Bitmap bimage = getBitmapFromURL(urlImage);
      image.setImageBitmap(bimage);
    } else image.setImageResource(R.drawable.m);

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

    Drawable marker = getResources().getDrawable(android.R.drawable.star_big_on);
    int markerWidth = marker.getIntrinsicWidth();
    int markerHeight = marker.getIntrinsicHeight();
    marker.setBounds(0, markerHeight, markerWidth, 0);

    MyItemizedOverlay myItemizedOverlay = new MyItemizedOverlay(marker);
    mapView.getOverlays().add(myItemizedOverlay);
    //      30.268149,-97.742829
    String coordinates[] = {latitude, longitude};
    double lat = Double.parseDouble(coordinates[0]);
    double lng = Double.parseDouble(coordinates[1]);

    GeoPoint p = new GeoPoint((int) (lat * 1E6), (int) (lng * 1E6));
    GeoPoint myPoint1 = new GeoPoint(0 * 1000000, 0 * 1000000);
    myItemizedOverlay.addItem(p, "myPoint1", "myPoint1");
    GeoPoint myPoint2 = new GeoPoint(50 * 1000000, 50 * 1000000);
    MapController mapController = mapView.getController();
    mapController.setCenter(p);
    mapController.setZoom(14);

    pixButton = (ImageButton) findViewById(R.id.takePic);
    pixButton.setOnClickListener(
        new View.OnClickListener() {
          public void onClick(View v) {
            // Perform action on click
            Intent intent1 = new Intent(getBaseContext(), TakePix.class);
            Log.d("venue id ", venueID);
            intent1.putExtra("VENUEID", venueID);
            startActivity(intent1);
          }
        });

    p1_button = (Button) findViewById(R.id.customEventVenue);

    p1_button.setBackgroundColor(Color.LTGRAY);
    p1_button.setOnClickListener(
        new View.OnClickListener() {
          public void onClick(View v) {
            new CountDownTimer(450, 400) {

              public void onTick(long millisUntilFinished) {
                p1_button.setBackgroundColor(Color.WHITE);
                Log.d("seconds remaining: ", "" + millisUntilFinished / 1000);
              }

              public void onFinish() {
                p1_button.setBackgroundColor(Color.LTGRAY);
                Log.d("done!", "");
              }
            }.start();
            // Perform action on click
            Intent intent1 = new Intent(getBaseContext(), VenueViewActivity.class);
            Log.d("venue id ", venueID);
            intent1.putExtra("VENUEID", venueID);
            startActivity(intent1);
          }
        });
  }
 @Override
 public void setCenter(GeoPointImpl geoPoint) {
   mapController.setCenter((GeoPoint) geoPoint);
 }
예제 #15
0
  public void init() {

    LogManager.d("init");

    geoBeijing = new GeoPoint((int) (39.932 * 1000000), (int) (116.461 * 1000000));
    mDefaultCurrentLocation =
        new GeoPoint((int) (41.892910 * 1000000), (int) (12.48251990 * 1000000));

    mapView = (MapView) findViewById(R.id.map_view);
    map_view_enable = findViewById(R.id.map_view_enable);
    mapView.getLayoutParams().height = BaseActivity.screen_height * 1 / 2;
    map_view_enable.getLayoutParams().height = BaseActivity.screen_height * 1 / 2;
    mapView.setOnTouchListener(this);
    mapView.setSaveEnabled(true);
    mapView.setBuiltInZoomControls(false);

    mapCon = mapView.getController();
    mapCon.setZoom(defaultZoom);

    // geo = new Geocoder(getContext(), Locale.CHINA);
    mapCon.setCenter(mDefaultCurrentLocation);
    mapView.setTraffic(false);
    mapView.setSatellite(false);

    mPopView = (ViewGroup) mapActivity.getLayoutInflater().inflate(R.layout.map_popover, null);

    // MapActivity mapActivity = (MapActivity)getContext();
    // WindowManager windowManager = mapActivity.getWindowManager();
    // int width = windowManager.getDefaultDisplay().getWidth();

    mapView.addView(
        mPopView,
        new MapView.LayoutParams(
            LayoutParams.WRAP_CONTENT,
            LayoutParams.WRAP_CONTENT,
            null,
            MapView.LayoutParams.TOP_LEFT));
    mPopView.setVisibility(View.GONE);
    overlays = mapView.getOverlays();

    Drawable currentLocationMarker =
        this.getContext().getResources().getDrawable(R.drawable.user_location);
    mCurrentLocationOverlay = new MapItemizedOverlay(currentLocationMarker, this);
    mCurrentLocationOverlay.showPop = false;
    Drawable search = this.getContext().getResources().getDrawable(R.drawable.pin);

    bankOverlay = new MapItemizedOverlay(search, this);

    overlays.add(mCurrentLocationOverlay);
    overlays.add(bankOverlay);

    locationManager = (LocationManager) getContext().getSystemService(Context.LOCATION_SERVICE);

    mLocationListener1 =
        new LocationListener() {
          public void onLocationChanged(Location location) {
            Log.e(
                "Location",
                "GPSListener  "
                    + "latitude:"
                    + Double.toString(location.getLatitude())
                    + " longtitude:"
                    + Double.toString(location.getLongitude())
                    + " from:"
                    + location.getProvider());
            if (isBetterLocation(location, mCurrentLocation)) {
              setCurrentLocation(location);
              if (mMapShowingForLocationUpdate) {
                addCurrentLocationOverlay();
              }
            }
          }

          public void onStatusChanged(String provider, int status, Bundle extras) {}

          public void onProviderEnabled(String provider) {}

          public void onProviderDisabled(String provider) {}
        };

    mLocationListener2 =
        new LocationListener() {
          private boolean mFirstLaunch;

          public void onLocationChanged(Location location) {
            Log.e(
                "Location",
                "NetworkListener  "
                    + "latitude:"
                    + Double.toString(location.getLatitude())
                    + " longtitude:"
                    + Double.toString(location.getLongitude())
                    + " from:"
                    + location.getProvider());
            if (isBetterLocation(location, mCurrentLocation)) {
              setCurrentLocation(location);
              if (mMapShowingForLocationUpdate) {
                addCurrentLocationOverlay();
              }
            }
            if (mFirstLaunch == true) {
              mFirstLaunch = false;
              locationManager.removeUpdates(mLocationListener2);
            }
          }

          public void onStatusChanged(String provider, int status, Bundle extras) {}

          public void onProviderEnabled(String provider) {}

          public void onProviderDisabled(String provider) {}
        };
    myLocation = (ImageButton) findViewById(R.id.my_location);
    mapLayer = (ImageButton) findViewById(R.id.map_layer);
    showItems = (ImageButton) findViewById(R.id.show_items);
    searchButton = (ImageButton) findViewById(R.id.search_btn);
    searchEdt = (EditText) findViewById(R.id.search_input);
    distance_input = (EditText) findViewById(R.id.distance_input);
    if (App.app.initValue) {

      searchEdt.setText("05387");

      searchEdt.setText("via del tintoretto,200,roma");
    }

    searchButton.setOnClickListener(
        new View.OnClickListener() {

          @Override
          public void onClick(View v) {
            // BaseMapActivity baseactivity = (BaseMapActivity)getContext();
            // baseactivity.hideKeyboard(searchButton);
            KeyBoardUtils.hideSoftInputFromWindow(mapActivity, searchEdt.getWindowToken());
            ProgressOverlay progressOverlay = new ProgressOverlay(getContext());
            progressOverlay.show(
                "searching...",
                new OnProgressEvent() {

                  @Override
                  public void onProgress() {

                    // Locale locale =
                    // getResources().getConfiguration().locale;

                    final String keyText = searchEdt.getText().toString();
                    searchGeoPoint = searchLocation(keyText);
                    if (searchGeoPoint != null) {
                      searchBarch(keyText);
                    }
                  }
                });
          }
        });

    mapLayer.setOnClickListener(
        new OnClickListener() {

          int i;

          @Override
          public void onClick(View v) {

            i++;
            int value = i % 2;
            switch (value) {
              case 0:
                mapView.setTraffic(false);
                mapView.setSatellite(false);
                break;
              case 1:
                mapView.setTraffic(false);
                mapView.setSatellite(true);

                break;
            }
          }
        });
    showItems.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            if (enter_distance_layout.getVisibility() == View.VISIBLE) {
              enter_distance_layout.setVisibility(View.GONE);
            } else {

              enter_distance_layout.setVisibility(View.VISIBLE);
            }
          }
        });
    myLocation.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            goToMyLocation();
          }
        });
    handler = new Handler();
    enter_distance_layout = (ViewGroup) findViewById(R.id.enter_distance_layout);
  }
예제 #16
0
  public void drawPath(int time) {
    // Check if from address is MyLocation
    String fromStr = editFrom.getText().toString();
    String toStr = editTo.getText().toString();
    if (fromStr.length() == 0 || fromStr == "") {
      buildAlertMessageNoAddr("Enter From Address.", editFrom);
      return;
    }
    if (toStr.length() == 0 || toStr == "") {
      buildAlertMessageNoAddr("Enter To Address.", editTo);
      return;
    }

    if (fromStr.equalsIgnoreCase("My Location")) {
      fromPt =
          new GeoPoint(
              Double.valueOf(myLoc.getLatitude() * 1E6).intValue(),
              Double.valueOf(myLoc.getLongitude() * 1E6).intValue());
    } else {
      fromPt = getPointFromAddr(fromStr); // User entered from address
    }

    toPt = getPointFromAddr(toStr);
    if (fromPt == null) {
      buildAlertMessageNoAddr("From address invalid.", editFrom);
      return;
    }
    if (toPt == null) {
      buildAlertMessageNoAddr("To address invalid.", editTo);
      return;
    }

    mapOverlays = mapView.getOverlays();
    mapOverlays.clear();
    drawable = getApplicationContext().getResources().getDrawable(R.drawable.pin);
    endmarker = getApplicationContext().getResources().getDrawable(R.drawable.marker);

    itemizedoverlay = new CustomItemizedOverlay(drawable, NavScreenActivity.this);
    itemizedoverlay1 = new CustomItemizedOverlay(endmarker, NavScreenActivity.this);
    String fromtemp = null;
    if (fromStr.equalsIgnoreCase("My Location")) {
      fromtemp =
          getFormattedAddrFromPt(
              fromPt.getLatitudeE6() / 1E6 + "," + fromPt.getLongitudeE6() / 1E6);
    } else {
      fromtemp = fromStr;
    }
    OverlayItem overlayfrom = new OverlayItem(fromPt, "From Address: ", fromtemp);
    OverlayItem overlayto = new OverlayItem(toPt, "To Address: ", toStr);
    itemizedoverlay.addOverlay(overlayfrom);
    itemizedoverlay1.addOverlay(overlayto);

    mapOverlays.add(itemizedoverlay);
    mapOverlays.add(itemizedoverlay1);

    // call google webservice
    googlePointsArr = getPointsFromGoogle(fromPt, toPt);

    // add all google points to path overlay as two-point pairs
    PathOverlay googlePath = new PathOverlay(googlePointsArr, Color.BLUE);
    mapOverlays.add(googlePath);

    // call clearpath web service
    cpPointsArr = getPointsFromClearPath(fromPt, toPt, time, deporarr);

    // add all clearpath points to path overlay as two-point pairs
    PathOverlay clearPath = new PathOverlay(cpPointsArr, Color.GREEN);
    mapOverlays.add(clearPath);

    // mapController.animateTo(fromPt);
    mapController.setCenter(
        new GeoPoint(
            (fromPt.getLatitudeE6() + toPt.getLatitudeE6()) / 2,
            (fromPt.getLongitudeE6() + toPt.getLongitudeE6()) / 2));
    // for auto zoom scaling //swapnil.c
    int latSpan = (int) Math.round(Math.abs((fromPt.getLatitudeE6() - toPt.getLatitudeE6())));
    int lonSpan = (int) Math.round(Math.abs((fromPt.getLongitudeE6() - toPt.getLongitudeE6())));
    if (latSpan > 10000 && lonSpan > 10000) {
      latSpan += 100000;
      lonSpan += 100000;
    }
    mapController.zoomToSpan(latSpan, lonSpan);

    // add travel time for google
    tvgoogtime.setText("Google Travel Time: " + googtime);

    // add travel time for CP
    tvcptime.setText("ClearPath Travel Time: " + cptime + " mins");

    // add to and from to recents
    addToRecent(toStr);
    if (!fromStr.equalsIgnoreCase("My Location")) {
      addToRecent(fromStr);
    }
  }
예제 #17
0
파일: MapUtil.java 프로젝트: alexvezeau/STL
 public static void zoomTo(MapController mc, GeoPoint gp, int zoomLevel) {
   mc.setCenter(gp);
   mc.setZoom(zoomLevel);
 }
  public void showPlace(Place place) {

    if (place != null) {
      this.currentPlace = place;
      // create place name.
      TextView name = (TextView) findViewById(R.id.place_name);
      if (name != null) {
        name.setText(place.getName());
      }

      // create PLACE description.
      TextView description = (TextView) findViewById(R.id.place_description);
      if (description != null) {
        String descStr = place.getDescription();

        if (descStr != null && !descStr.isEmpty() && !descStr.equals("null")) {
          description.setText(descStr);
        } else {
          description.setVisibility(View.GONE);
        }
      }

      if (place.getImage() != null && !place.getImage().isEmpty()) {
        // place image
        ImageView image = (ImageView) findViewById(R.id.place_image);
        if (image != null) {
          DataManager.getSingleton().downloadBitmap(place.getImage(), image);
        }
      }

      // place location
      Location location = place.getLocation();
      if (location != null) {
        TextView placeLocation = (TextView) findViewById(R.id.place_location);
        if (placeLocation != null) {
          placeLocation.setText(location.getAddress());
        }

        // place distance.
        TextView distance = (TextView) findViewById(R.id.place_distance);
        if (distance != null) {
          float[] distanceResults = new float[1];
          android.location.Location currentLocation = AppLocationManager.getCurrentLocation();
          DecimalFormat df = new DecimalFormat("#.#");

          if (currentLocation != null) {
            android.location.Location.distanceBetween(
                currentLocation.getLatitude(),
                currentLocation.getLongitude(),
                Double.valueOf(location.getLatitude()),
                Double.valueOf(location.getLongitude()),
                distanceResults);
            double miles = distanceResults[0] / 1609.34; // i mile =
            // 1.60934km
            distance.setText(df.format(miles) + "mi");
          } else {
            distance.setText("--");
          }
        }

        MapView map = (MapView) findViewById(R.id.mapview);
        if (map != null) {
          MapController mc = map.getController();
          if (mc != null) {

            List<Overlay> mapOverlaysList = map.getOverlays();
            Drawable drawable = this.getResources().getDrawable(R.drawable.red_pointer_icon);

            // creating an ItemizedOverlayActivity object so we can
            // have multiple overlays
            // added to a list to show them in a map
            ItemizedOverlayActivity itemizedoverlay = new ItemizedOverlayActivity(drawable, this);

            GeoPoint geoPoint =
                new GeoPoint(
                    (int) (Double.valueOf(location.getLatitude()) * 1E6),
                    (int) (Double.valueOf(location.getLongitude()) * 1E6));

            // Creates an overlay item with a geopoint to show in
            // the map
            OverlayItem overlayitem = new OverlayItem(geoPoint, "Place", place.getName());

            itemizedoverlay.addOverlay(overlayitem);
            mapOverlaysList.add(itemizedoverlay);

            mc.setCenter(geoPoint);
            mc.setZoom(17);
          }
        }

        showEventList(place.getEventsAtPlace());
      }
    }
  } // end showPlace
예제 #19
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.maps);

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

    mapOverlays = mapView.getOverlays();
    drawable = this.getResources().getDrawable(R.drawable.museum_48);
    itemizedOverlay = new MuseumItemizedOverlay(drawable);

    me = new MyLocationOverlay(this, mapView);

    me.runOnFirstFix(
        new Runnable() {
          public void run() {
            mapView.getController().animateTo(me.getMyLocation());
          }
        });

    mapView.getOverlays().add(me);

    GeoPoint point01 = new GeoPoint((int) (39.9581389 * 1E6), (int) (-75.1726281 * 1E6));
    OverlayItem overlayitem01 =
        new OverlayItem(
            point01, "Franklin Institute", "222 North 20th Street, Philadelphia, PA 19103");

    GeoPoint point03 = new GeoPoint((int) (39.9497575 * 1E6), (int) (-75.1916742 * 1E6));
    OverlayItem overlayitem03 =
        new OverlayItem(
            point03,
            "Univerity of Pennsylvania Museum of Archaeology and Anthropology",
            "3260 South Street, Philadelphia, PA 19104");

    GeoPoint point06 = new GeoPoint((int) (39.9794632 * 1E6), (int) (-75.2091515 * 1E6));
    OverlayItem overlayitem06 =
        new OverlayItem(
            point06, "Please Touch Museum", "4231 North Concourse Drive, Philadelphia, PA 19131");

    GeoPoint point10 = new GeoPoint((int) (39.957262 * 1E6), (int) (-75.171129 * 1E6));
    OverlayItem overlayitem10 =
        new OverlayItem(
            point10,
            "Academy of Natural Sciences",
            "1900 Benjamin Franklin Parkway, Philadelphia, PA 19103");

    GeoPoint point11 = new GeoPoint((int) (39.952994 * 1E6), (int) (-75.176783 * 1E6));
    OverlayItem overlayitem11 =
        new OverlayItem(
            point11,
            "The College of Physicians of Philadelphia - Mutter Museum",
            "19 S. 22nd St., Philadelphia, PA 19103-3097");

    GeoPoint point18 = new GeoPoint((int) (40.09285 * 1E6), (int) (-75.223924 * 1E6));
    OverlayItem overlayitem18 =
        new OverlayItem(
            point18,
            "Morris Arboretum of the University of Pennsylvania",
            "00 Northwestern Avenue, Philadelphia, PA 19118");

    GeoPoint point24 = new GeoPoint((int) (39.938816 * 1E6), (int) (-75.158121 * 1E6));
    OverlayItem overlayitem24 =
        new OverlayItem(
            point24, "The Insectarium", "8046 Frankford Avenue, Philadelphia, PA 19136");

    itemizedOverlay.addOverlay(overlayitem01);
    itemizedOverlay.addOverlay(overlayitem03);
    itemizedOverlay.addOverlay(overlayitem06);
    itemizedOverlay.addOverlay(overlayitem10);
    itemizedOverlay.addOverlay(overlayitem11);
    itemizedOverlay.addOverlay(overlayitem18);
    itemizedOverlay.addOverlay(overlayitem24);

    mapOverlays.add(itemizedOverlay);

    MapController mapControl = mapView.getController();
    mapControl.setCenter(itemizedOverlay.getCenter());
    mapControl.zoomToSpan(itemizedOverlay.getLatSpanE6(), itemizedOverlay.getLonSpanE6());
  }