Пример #1
0
 /** Clear all schedules on the map */
 public void clearSchedules() {
   randomStudent = null;
   OverlayManager om = mapView.getOverlayManager();
   om.clear();
   scheduleOverlay.clear();
   buildingOverlay.removeAllItems();
   om.addAll(scheduleOverlay);
   om.add(buildingOverlay);
   mapView.invalidate();
 }
Пример #2
0
  private void plotAPlace(LatLon latLon, String title, String msg, int drawableToUse) {
    OverlayItem buildingItem =
        new OverlayItem(title, msg, new GeoPoint(latLon.getLatitude(), latLon.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);
  }
Пример #3
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);
  }
 public void clearExistingPath() {
   pathPointList.clear();
   pathOverlay.setPoints(pathPointList);
   pathIndicatorOverlays.removeAllItems();
   mapView.postInvalidate();
 }
  ///////////////////// THIS IS TO DISPLAY PATH WHEN A* ALGORITHM DETERMINES THE
  // PATH/////////////////////////////
  public void showPathForEdges(ArrayList<Edge> pathData) {
    if (pathData == null || pathData.size() == 0) return;

    // HERE WE OBTAIN THE POINTS WHICH TOGETHER REPRESENT THE PATH
    pathPointList.clear();
    ArrayList<GeoPoint> edgeContourList;
    int color = 0;
    Edge edge;

    for (int i = (pathData.size() - 1); i >= 0; i--) {
      edge = pathData.get(i);
      color = edge.getEdgeColor();
      pathPointList.add(
          new PathPoint(
              edge.getToNode().getLatE6(),
              edge.getToNode().getLongE6(),
              color)); // this is the destination node's coords

      edgeContourList = edge.getEdgeContourList(mContext.getContentResolver());
      if (edgeContourList != null) {
        for (GeoPoint p : edgeContourList) {
          pathPointList.add(new PathPoint(p.getLatitudeE6(), p.getLongitudeE6(), color));
        }
      }

      if (i == 0) {
        // add the data of the first point of the first node
        pathPointList.add(
            new PathPoint(edge.getFromNode().getLatE6(), edge.getFromNode().getLongE6(), color));
      }
    }

    // HERE WE GET THE PATH INDICATORS LIST
    pathIndicatorList.clear();
    pathIndicatorOverlays.removeAllItems();
    Node n;
    int currentType = Edge.TYPE_WALK;
    Resources r = mapView.getResources();
    int indicatorCount = 0;
    int prevEdgeType = -1;
    String title = "";
    for (int i = 0; i < pathData.size(); i++) {
      try {
        edge = pathData.get(i);

        if (edge.getEdgeType() == Edge.TYPE_WAIT) {
          // special case: if the final destination is a bus/tram stop
          // we add a final indicator for destination node
          if (i == (pathData.size() - 1)) { // last edge. must display destination
            n = edge.getToNode();
            indicatorCount++;
            OverlayItem item =
                new OverlayItem(
                    indicatorCount + ":path_indicator" + n.getID(),
                    null,
                    "Reach destination at " + n.getTitle(),
                    n.getGeoPoint(),
                    DrawableUtils.numberedPathDirectionDrawable(r, indicatorCount));
            item.setMarkerHotspot(HotspotPlace.BOTTOM_CENTER);
            pathIndicatorOverlays.addItem(item);
            break;
          }

          if (edge.getCostForEdge() > 0) title = edge.getFromNode().getTitle();
          continue;
        }

        if (i == 0) { // first edge. must display start point
          currentType = edge.getEdgeType();
          n = edge.getFromNode();
          if (n.getTitle() != null) title = n.getTitle();
          indicatorCount++;
          String descText = edge.getLineName();
          if (edge.getEdgeType() == Edge.TYPE_WALK) {
            if (edge.getCostForEdge() == Edge.DUMMY_EDGE_COST)
              descText = "Walk from your starting location";
            else descText = descText.replace("Alight", "Start").replace("#NODE_NAME#", title);
          } else {
            descText =
                descText
                    .replace("Board", "Start at " + title + " and board")
                    .replace("#NODE_NAME#", "");
          }

          OverlayItem item =
              new OverlayItem(
                  indicatorCount + ":path_indicator" + n.getID(),
                  null,
                  descText,
                  n.getGeoPoint(),
                  DrawableUtils.numberedPathDirectionDrawable(r, indicatorCount));
          item.setMarkerHotspot(HotspotPlace.BOTTOM_CENTER);
          pathIndicatorOverlays.addItem(item);
        } else {
          if (edge.getEdgeType() != currentType) {
            // if there is a change in the type of edge
            currentType = edge.getEdgeType();
            n = edge.getFromNode();
            if (n.getTitle() != null) title = n.getTitle();
            indicatorCount++;
            String descText = edge.getLineName();
            if (prevEdgeType != Edge.TYPE_WALK && edge.getEdgeType() != Edge.TYPE_WALK)
              descText = descText.replace("Board", "Alight and change to");
            descText = descText.replace("#NODE_NAME#", title);
            OverlayItem item =
                new OverlayItem(
                    indicatorCount + ":path_indicator" + n.getID(),
                    null,
                    descText,
                    n.getGeoPoint(),
                    DrawableUtils.numberedPathDirectionDrawable(r, indicatorCount));
            item.setMarkerHotspot(HotspotPlace.BOTTOM_CENTER);
            pathIndicatorOverlays.addItem(item);
          }
        }

        // add a final indicator for destination node
        if (i == (pathData.size() - 1)) { // last edge. must display destination
          n = edge.getToNode();
          indicatorCount++;
          OverlayItem item =
              new OverlayItem(
                  indicatorCount + ":path_indicator" + n.getID(),
                  null,
                  "Reach destination at " + n.getTitle(),
                  n.getGeoPoint(),
                  DrawableUtils.numberedPathDirectionDrawable(r, indicatorCount));
          item.setMarkerHotspot(HotspotPlace.BOTTOM_CENTER);
          pathIndicatorOverlays.addItem(item);
        }

        prevEdgeType = edge.getEdgeType();
      } catch (Exception ignore) {
        ignore.printStackTrace();
      }
    }

    pathOverlay.setPoints(pathPointList);
    mapView.postInvalidate();
  }
 // helper for displaying nodes. separated as this must be done on UI thread
 public void displayNodes(ArrayList<OverlayItem> overlayList) {
   markerPointsOverlay.removeAllItems();
   for (OverlayItem o : overlayList) {
     markerPointsOverlay.addItem(o);
   }
 }
 @Override
 public void removeAllItems() {
   super.removeAllItems();
   hideBubble();
 }