示例#1
0
 /*
 Given two buildings, filterout all places within given range
  */
 private void displayAllPlacesWithinRange(Building building1, Building building2, int range) {
   PlaceFactory places = PlaceFactory.getInstance();
   Set<Place> places1 = places.findPlacesWithinDistance(building1.getLatLon(), range);
   Set<Place> places2 = places.findPlacesWithinDistance(building2.getLatLon(), range);
   List<Place> placesWithinRange = new ArrayList<Place>();
   for (Place p : places1) {
     if (places2.contains(p)) {
       placesWithinRange.add(p);
     }
   }
   plotPlaces(placesWithinRange);
 }
示例#2
0
  /**
   * Plot a building onto the map
   *
   * @param building The building to put on the map
   * @param title The title to put in the dialog box when the building is tapped on the map
   * @param msg The message to display when the building is tapped
   * @param drawableToUse The icon to use. Can be R.drawable.ic_action_place (or any icon in the
   *     res/drawable directory)
   */
  private void plotABuilding(Building building, String title, String msg, int drawableToUse) {
    // CPSC 210 Students: You should not need to touch this method
    OverlayItem buildingItem =
        new OverlayItem(
            title,
            msg,
            new GeoPoint(building.getLatLon().getLatitude(), building.getLatLon().getLongitude()));

    // Create new marker
    Drawable icon = this.getResources().getDrawable(drawableToUse);

    // Set the bounding for the drawable
    icon.setBounds(
        0 - icon.getIntrinsicWidth() / 2,
        0 - icon.getIntrinsicHeight(),
        icon.getIntrinsicWidth() / 2,
        0);

    // Set the new marker to the overlay
    buildingItem.setMarker(icon);
    buildingOverlay.addItem(buildingItem);
  }