Beispiel #1
0
  @Override
  protected void onPostExecute(Void result) {
    super.onPostExecute(result);

    MainActivity.map.getOverlays().clear();

    final ArrayList<OverlayItem> items = new ArrayList<OverlayItem>();

    // if (MainActivity.my_lat != 0 && MainActivity.my_lon != 0) {
    OverlayItem myLocationOverlayItem =
        new OverlayItem(
            "Here", "Current Position", new GeoPoint(MainActivity.my_lat, MainActivity.my_lon));
    myLocationOverlayItem.setMarker(MainActivity.myCurrentLocationMarker);
    items.add(myLocationOverlayItem);
    // }

    for (int i = 0; i < MainActivity.drones.size(); i++) {
      OverlayItem droneOverlayItem =
          new OverlayItem(
              "Here",
              "Current Position",
              new GeoPoint(
                  MainActivity.drones.get(i).getLat(), MainActivity.drones.get(i).getLon()));
      droneOverlayItem.setMarker(MainActivity.droneMarker);
      items.add(droneOverlayItem);
    }

    MainActivity.addMarkersOnMap(items);

    DroneAnimation animation = new DroneAnimation();
    animation.execute();
  }
  /**
   * @see com.brantapps.polaris.api.Mappable#addMarker(com.brantapps.polaris.api.MapMarkerOptions)
   */
  @Override
  public MapMarker<?> addMarker(final MapMarkerOptions<?> mapMarkerOptions) {
    if (itemisedOverlay == null) {
      itemisedOverlay =
          new ItemizedOverlayWithFocus<OverlayItem>(
              new ArrayList<OverlayItem>(), this, getResourceProxy());
      itemisedOverlay.setFocusItemsOnTap(true);
      mapView.setUseSafeCanvas(false);
      mapView.getOverlays().add(itemisedOverlay);
    }

    final Marker marker = (Marker) mapMarkerOptions.get();
    final OverlayItem item =
        new OverlayItem(
            marker.title,
            marker.snippet,
            new org.osmdroid.util.GeoPoint(marker.latitude, marker.longitude));
    if (marker.bitmap != null) {
      item.setMarker(new BitmapDrawable(mapView.getResources(), marker.bitmap));
    } else if (marker.icon != 0) {
      item.setMarker(mapView.getResources().getDrawable(marker.icon));
    }
    if (marker.anchor == Marker.Anchor.CENTER) {
      item.setMarkerHotspot(OverlayItem.HotspotPlace.CENTER);
    }

    itemisedOverlay.addItem(item);
    final MapMarker<Marker> osmMapMarker = new OpenStreetMapMarker(marker);
    overlayItemToMarker.put(item, osmMapMarker);
    return osmMapMarker;
  }
  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);
  }
  /**
   * 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 setLocation(GeoPoint location) {
   mOverlayItem = new OverlayItem("cast", "", location);
   mOverlayItem.setMarker(getDefaultMarker());
   removeAllItems();
   addItem(mOverlayItem);
 }