コード例 #1
0
  public void addMarker(Airplane airplane) {
    AirplanePosition position = airplane.getLastPosition();
    LatLng location = new LatLng(position.getLatitude(), position.getLongitude());
    float angle = (float) airplane.getHead() - map.getCameraPosition().bearing;

    MarkerOptions options = new MarkerOptions();
    options.position(location);
    options.title(airplane.getHex());
    options.icon(BitmapDescriptorFactory.fromBitmap(getAirplaneIcon(angle)));
    options.anchor(0.5f, 0.5f);

    Marker marker = map.addMarker(options);
    markers.add(marker);
  }
コード例 #2
0
  public void updateMarker(Airplane airplane) {
    for (Marker m : markers) {
      boolean infoShow = m.isInfoWindowShown();
      if (m.getTitle().equals(airplane.getHex())) {
        AirplanePosition position = airplane.getLastPosition();
        LatLng location = new LatLng(position.getLatitude(), position.getLongitude());
        float angle = (float) airplane.getHead() + map.getCameraPosition().bearing;
        m.setPosition(location);
        m.setIcon(BitmapDescriptorFactory.fromBitmap(getAirplaneIcon(angle)));

        if (infoShow) m.showInfoWindow();
        break;
      }
    }
  }
コード例 #3
0
  public void addAirplaneTrack(Airplane airplane) {
    updaterService.doGetRouteFrom(airplane);
    List<AirplanePosition> track = airplane.getRoute();

    for (int i = 0; i < track.size() - 1; i++) {
      Log.i("DEBUG", "Criando linha para o avião");
      AirplanePosition pos1 = track.get(i);
      AirplanePosition pos2 = track.get(i + 1);
      Polyline line =
          map.addPolyline(
              new PolylineOptions()
                  .add(
                      new LatLng(pos1.getLatitude(), pos1.getLongitude()),
                      new LatLng(pos2.getLatitude(), pos2.getLongitude()))
                  .width(5)
                  .color(getColorFromAltitude((float) pos1.getAltitude())));

      currentPolyTrack.put(pos1.getId(), line);
    }
  }
コード例 #4
0
  public void updateAirplaneTrack(Airplane airplane) {
    if (currentAirplaneSelected != null
        && currentAirplaneSelected.getHex().equals(airplane.getHex())) {
      List<AirplanePosition> track = airplane.getRoute();

      for (int i = 0; i < track.size() - 1; i++) {
        AirplanePosition pos1 = track.get(i);
        AirplanePosition pos2 = track.get(i + 1);

        if (!currentPolyTrack.containsKey(pos1.getId())) {
          Log.i("DEBUG", "Atualizando linha para o avião");
          Polyline line =
              map.addPolyline(
                  new PolylineOptions()
                      .add(
                          new LatLng(pos1.getLatitude(), pos1.getLongitude()),
                          new LatLng(pos2.getLatitude(), pos2.getLongitude()))
                      .width(5)
                      .color(getColorFromAltitude((float) pos1.getAltitude())));
          currentPolyTrack.put(pos1.getId(), line);
        }
      }
    }
  }