@Override
  public void updateLocationMarker(Location location) {
    if (locationChangedListener != null) {
      currentUserLocation = location;
      locationChangedListener.onLocationChanged(location);
    }

    // Update clickable area
    LatLng userPosition = getUserLocation(location);
    if (userPositionClickArea == null) {
      MarkerOptions markerOptions = new MarkerOptions();
      markerOptions.position(userPosition);
      markerOptions.anchor(0.4f, 0.4f); // strange google maps bug
      markerOptions.icon(BitmapDescriptorFactory.fromBitmap(clickableBitmap));
      userPositionClickArea = googleMap.addMarker(markerOptions);
    } else {
      userPositionClickArea.setPosition(userPosition);
    }
    if (userPositionClickArea2 == null) {
      MarkerOptions markerOptions = new MarkerOptions();
      markerOptions.position(userPosition);
      markerOptions.anchor(0.6f, 0.6f); // strange google maps bug
      markerOptions.icon(BitmapDescriptorFactory.fromBitmap(clickableBitmap));
      userPositionClickArea2 = googleMap.addMarker(markerOptions);
    } else {
      userPositionClickArea2.setPosition(userPosition);
    }
  }
 public void setCoordinate(ReadableMap coordinate) {
   position = new LatLng(coordinate.getDouble("latitude"), coordinate.getDouble("longitude"));
   if (marker != null) {
     marker.setPosition(position);
   }
   update();
 }
Exemple #3
0
  public void UpdateMarker() {
    marker.setTitle(
        (isInvoln() ? "Powered up " : "")
            + PlayerType.getTypeString(type)
            + " "
            + (local ? "You" : name));
    int drawableID = PlayerType.getDrawableID(type);

    Bitmap bmp = BitmapFactory.decodeResource(Game.getAppContext().getResources(), drawableID);

    if (bmp == null) {
      return;
    }

    double aspect = bmp.getWidth() / (double) bmp.getHeight();
    marker.setIcon(
        BitmapDescriptorFactory.fromBitmap(
            Bitmap.createScaledBitmap(bmp, (int) (100 * aspect), 100, false)));
    marker.setAlpha(isCooldown() ? 0.5f : 1f);
    marker.setVisible(true);
    marker.setPosition(new LatLng(latitude, longitude));
    marker.setSnippet("Score: " + score);
    accuracyCircle.setCenter(new LatLng(latitude, longitude));
    accuracyCircle.setRadius(accuracy);
  }
  @Override
  public void onLocationChanged(Location location) {
    if (mRefreshLocation) {
      mLocation = location;
      if (mLocation != null) {
        // Bug report: cached GeoPoint is being returned as the first value.
        // Wait for the 2nd value to be returned, which is hopefully not cached?
        ++mLocationCount;
        InfoLogger.geolog(
            "GeoPointMapActivity: "
                + System.currentTimeMillis()
                + " onLocationChanged("
                + mLocationCount
                + ") lat: "
                + mLocation.getLatitude()
                + " long: "
                + mLocation.getLongitude()
                + " acc: "
                + mLocation.getAccuracy());

        if (mLocationCount > 1) {
          mLocationStatus.setText(
              getString(
                  R.string.location_provider_accuracy,
                  mLocation.getProvider(),
                  truncateFloat(mLocation.getAccuracy())));
          mLatLng = new LatLng(mLocation.getLatitude(), mLocation.getLongitude());
          if (!mZoomed) {
            mZoomed = true;
            mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(mLatLng, 16));
          } else {
            mMap.animateCamera(CameraUpdateFactory.newLatLng(mLatLng));
          }

          // create a marker on the map or move the existing marker to the
          // new location
          if (mMarker == null) {
            mMarkerOption.position(mLatLng);
            mMarker = mMap.addMarker(mMarkerOption);
            mShowLocation.setClickable(true);
          } else {
            mMarker.setPosition(mLatLng);
          }

          // If location is accurate enough, stop updating position and make the marker draggable
          if (mLocation.getAccuracy() <= mLocationAccuracy) {
            stopGeolocating();
          }
        }

      } else {
        InfoLogger.geolog(
            "GeoPointMapActivity: "
                + System.currentTimeMillis()
                + " onLocationChanged("
                + mLocationCount
                + ") null location");
      }
    }
  }
Exemple #5
0
  public void updateFriendMarker(UserObject u) {
    if (!friend1.isVisible()) {
      friend1.setVisible(true);
    }
    friend1.setSnippet(u.getUsername());

    friend1.setPosition(new LatLng(u.getLast_lat_double(), u.getLast_long_double()));
    Log.i(
        TAG,
        " updating friend location..... " + u.getLast_lat_double() + " " + u.getLast_long_double());
  }
 private Marker setMarker(Marker marker, double lat, double lng, int resourceId) {
   if (marker != null) {
     marker.setPosition(new LatLng(lat, lng));
     return marker;
     // marker.remove();
   }
   MarkerOptions options =
       new MarkerOptions()
           .position(new LatLng(lat, lng))
           .anchor(0.5f, 0.5f)
           .draggable(true)
           .icon(BitmapDescriptorFactory.fromResource(resourceId));
   return mMap.addMarker(options);
 }
    @Override
    public void onAnimationUpdate(ValueAnimator valueAnimator) {
      float fraction = valueAnimator.getAnimatedFraction();
      double lat = (to.latitude - from.latitude) * fraction + from.latitude;
      double lngDelta = to.longitude - from.longitude;

      // Take the shortest path across the 180th meridian.
      if (Math.abs(lngDelta) > 180) {
        lngDelta -= Math.signum(lngDelta) * 360;
      }
      double lng = lngDelta * fraction + from.longitude;
      LatLng position = new LatLng(lat, lng);
      marker.setPosition(position);
    }
 @Override
 public void onMapLongClick(LatLng latLng) {
   if (mMarker == null) {
     mMarkerOption.position(latLng);
     mMarker = mMap.addMarker(mMarkerOption);
     mShowLocation.setClickable(true);
   } else {
     mMarker.setPosition(latLng);
   }
   mLatLng = latLng;
   mIsDragged = true;
   stopGeolocating();
   mMarker.setDraggable(true);
 }
  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;
      }
    }
  }
  public void updateMarkerLocation(double lat, double lng) {
    LatLng location = new LatLng(lat, lng);

    if (marker == null) {
      markerOptions = new MarkerOptions();
      markerOptions.visible(true);
      markerOptions.position(location);
      markerOptions.draggable(draggable);
      marker = googleMap.addMarker(markerOptions);
    }

    CameraPosition cameraPosition =
        new CameraPosition.Builder().target(location).zoom(zoomLevel).bearing(0).tilt(45).build();
    googleMap.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
    marker.setPosition(location);
  }
Exemple #11
0
  private void updateMarker(Location loc) {
    myLatLng = new LatLng(loc.getLatitude(), loc.getLongitude());

    if (you == null) {
      you =
          map.addMarker(
              new MarkerOptions()
                  .position(myLatLng)
                  .title("Your here")
                  .snippet("What do you want to do")
                  .icon(BitmapDescriptorFactory.fromResource(R.drawable.marker_user)));
      map.moveCamera(CameraUpdateFactory.newLatLngZoom(myLatLng, 15));

    } else {
      you.setPosition(myLatLng);
    }
  }
    @Override
    protected void onPostExecute(Bitmap bitmapResult) {

      super.onPostExecute(bitmapResult);
      if (bitmapResult == null || cancelAsyncTasks || !isAdded() || map == null) {
        return;
      }
      Marker marker = markerMap.get(email);
      Boolean isNew = false;
      if (marker != null) {
        Log.d(TAG, "onPostExecute - updating marker: " + email);
        marker.setPosition(latLng);
        marker.setSnippet(time);
        marker.setIcon(BitmapDescriptorFactory.fromBitmap(bitmapResult));

      } else {
        Log.d(TAG, "onPostExecute - creating marker: " + email);
        marker =
            map.addMarker(
                new MarkerOptions()
                    .position(latLng)
                    .title(email)
                    .snippet(time)
                    .icon(BitmapDescriptorFactory.fromBitmap(bitmapResult)));
        Log.d(TAG, "onPostExecute - marker created");
        markerMap.put(email, marker);
        Log.d(TAG, "onPostExecute - marker in map stored. markerMap: " + markerMap.size());
        isNew = true;
      }

      if (marker.getTitle().equals(MainApplication.emailBeingTracked)) {
        marker.showInfoWindow();
        Log.d(TAG, "onPostExecute - showInfoWindow open");
        if (isNew) {
          map.moveCamera(CameraUpdateFactory.newLatLngZoom(marker.getPosition(), 16));
        } else {
          map.moveCamera(CameraUpdateFactory.newLatLng(marker.getPosition()));
        }
      } else if (firstTimeZoom
          && MainApplication.emailBeingTracked == null
          && MainApplication.userAccount != null
          && marker.getTitle().equals(MainApplication.userAccount)) {
        firstTimeZoom = false;
        map.moveCamera(CameraUpdateFactory.newLatLngZoom(marker.getPosition(), 16));
      }
    }
  private Marker setMarker(Marker marker, double lat, double lng, String title) {
    if (marker != null) {
      marker.setPosition(new LatLng(lat, lng));
      if (title != null) {
        marker.setTitle(title);
      }

      return marker;
      // marker.remove();
    }
    MarkerOptions options =
        new MarkerOptions()
            .position(new LatLng(lat, lng))
            .anchor(0.5f, 0.5f)
            .draggable(true)
            .icon(BitmapDescriptorFactory.fromResource(R.drawable.current_location_blue));
    return mMap.addMarker(options);
  }
Exemple #14
0
 public void updateLocation(Location location) {
   currentLocation = location;
   double latitude = currentLocation.getLatitude();
   double longitude = currentLocation.getLongitude();
   LatLng coord = new LatLng(latitude, longitude);
   // for changing the center of the map
   map.moveCamera(CameraUpdateFactory.newLatLngZoom(coord, 12.0f));
   MarkerOptions markerOptions =
       new MarkerOptions()
           .position(coord)
           .title("My Location")
           .icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_ORANGE));
   if (currentLocationMarker == null) {
     currentLocationMarker = map.addMarker(markerOptions);
   } else {
     currentLocationMarker.setPosition(coord);
   }
 }
 @Override
 public void onMyLocationChange(Location location) {
   if (myposition == null) {
     MarkerOptions markerOptions = new MarkerOptions();
     markerOptions.position(new LatLng(location.getLatitude(), location.getLongitude()));
     markerOptions.title("Yo");
     myposition = map.addMarker(markerOptions);
     CameraPosition cameraPosition =
         new CameraPosition.Builder()
             .target(new LatLng(location.getLatitude(), location.getLongitude()))
             .zoom(15)
             .build();
     map.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
     myposition.showInfoWindow();
   } else {
     myposition.setPosition(new LatLng(location.getLatitude(), location.getLongitude()));
   }
 }
Exemple #16
0
  public void updatePosition(long deltaT) {
    synchronized (this) {
      if (targets.size() > 0) {
        // reset
        if (targets.size() > 0 && currentStep == null || currentStepTime > currentStep.duration) {
          currentStep = targets.poll();
          currentStepTime = 0;
          deltaLat = currentStep.position.latitude - position.latitude;
          deltaLng = currentStep.position.longitude - position.longitude;
        }

        // interpolate position
        currentStepTime += deltaT;

        final double stepLat = deltaLat / currentStep.duration * deltaT;
        final double stepLng = deltaLng / currentStep.duration * deltaT;

        position = new LatLng(position.latitude + stepLat, position.longitude + stepLng);
        marker.setPosition(position);
      }
    }
  }
 void refresh() {
   int count = markers.size();
   if (count == 0) {
     removeVirtual();
   } else if (count < strategy.getMinMarkersCount()) {
     removeVirtual();
     for (DelegatingMarker m : markers) {
       m.changeVisible(true);
     }
   } else {
     for (DelegatingMarker m : markers) {
       m.changeVisible(false);
     }
     LatLng position = calculateClusterPosition();
     if (virtual == null || lastCount != count) {
       removeVirtual();
       lastCount = count;
       virtual = strategy.createMarker(new ArrayList<Marker>(markers), position);
     } else {
       virtual.setPosition(position);
     }
   }
 }
 /**
  * Update an existing marker on the map with the current vehicle status
  *
  * @param m Marker to update
  * @param l Location to add the marker at
  * @param isRealtime true if the marker shown indicate real-time info, false if it should
  *     indicate schedule
  * @param status real-time status of the vehicle
  * @param response response containing the provided status
  */
 private void updateMarker(
     Marker m,
     Location l,
     boolean isRealtime,
     ObaTripStatus status,
     ObaTripsForRouteResponse response) {
   boolean showInfo = m.isInfoWindowShown();
   m.setIcon(getVehicleIcon(isRealtime, status, response));
   // Update Hashmap with newest status - needed to show info when tapping on marker
   mVehicles.put(m, status);
   // Update vehicle position
   Location markerLoc = MapHelpV2.makeLocation(m.getPosition());
   // If its a small distance, animate the movement
   if (l.distanceTo(markerLoc) < MAX_VEHICLE_ANIMATION_DISTANCE) {
     AnimationUtil.animateMarkerTo(m, MapHelpV2.makeLatLng(l));
   } else {
     // Just snap the marker to the new location - large animations look weird
     m.setPosition(MapHelpV2.makeLatLng(l));
   }
   // If the info window was shown, make sure its open (changing the icon could have closed it)
   if (showInfo) {
     m.showInfoWindow();
   }
 }
Exemple #19
0
 public void onLocationChanged(Location location) {
   polozenie_ja = new LatLng(location.getLatitude(), location.getLongitude());
   marker_ja.setPosition(polozenie_ja);
 }
Exemple #20
0
 /**
  * Update position.
  *
  * @param yaw Float variable.
  * @param coord LatLng variable.
  */
 private void updatePosition(float yaw, LatLng coord) {
   droneMarker.setPosition(coord);
   droneMarker.setRotation(yaw);
   droneMarker.setVisible(true);
 }
 private void updatePosition(LatLng latLng) {
   map.animateCamera(CameraUpdateFactory.newLatLng(latLng));
   marker.setPosition(latLng);
 }
 // mapCombiner update: gets called when the map combiner gets an update of the pin location
 @Override
 public void onUpdate() {
   Location newLoc = (Location) mapCombiner.getMap().values().toArray()[0];
   LatLng loc = new LatLng(newLoc.getLatitude(), newLoc.getLongitude());
   pinMarker.setPosition(loc);
 }
  @Override
  public void onLocationReceived(LatLng latlong) {
    if (googleMap == null) {
      return;
    }

    if (markerClient_d_location == null) {
      if (requestDetail.getClient_d_latitude() != null
          && requestDetail.getClient_d_longitude() != null) {
        markerClient_d_location =
            googleMap.addMarker(
                new MarkerOptions()
                    .position(
                        new LatLng(
                            Double.parseDouble(requestDetail.getClient_d_latitude()),
                            Double.parseDouble(requestDetail.getClient_d_longitude())))
                    .icon(BitmapDescriptorFactory.fromResource(R.drawable.pin_client))
                    .title("Destination"));
      }
    }

    if (markerClientLocation == null) {
      markerClientLocation =
          googleMap.addMarker(
              new MarkerOptions()
                  .position(
                      new LatLng(
                          Double.parseDouble(requestDetail.getClientLatitude()),
                          Double.parseDouble(requestDetail.getClientLongitude())))
                  .icon(BitmapDescriptorFactory.fromResource(R.drawable.pin_client)));

      if (jobStatus == AndyConstants.IS_WALK_COMPLETED) {
        markerClientLocation.setTitle(
            mapActivity.getResources().getString(R.string.job_start_location));
      } else {
        markerClientLocation.setTitle(
            mapActivity.getResources().getString(R.string.client_location));
      }
    }

    if (latlong != null) {
      if (googleMap != null) {
        if (markerDriverLocation == null) {
          markerDriverLocation =
              googleMap.addMarker(
                  new MarkerOptions()
                      .position(new LatLng(latlong.latitude, latlong.longitude))
                      .icon(BitmapDescriptorFactory.fromResource(R.drawable.pin_driver))
                      .title(getResources().getString(R.string.my_location)));
          googleMap.animateCamera(
              CameraUpdateFactory.newLatLngZoom(
                  new LatLng(latlong.latitude, latlong.longitude), 16));
        } else {
          markerDriverLocation.setPosition(new LatLng(latlong.latitude, latlong.longitude));
          if (jobStatus == AndyConstants.IS_WALK_COMPLETED) {
            drawTrip(new LatLng(latlong.latitude, latlong.longitude));

            // distance = decimalFormat.format(distanceMeter / (1000
            // * 1.62));

            // tvJobDistance.setText(decimalFormat
            // .format(preferenceHelper.getDistance()
            // / (1000 * 1.62))
            // + " "
            // + mapActivity.getResources().getString(
            // R.string.text_miles));

            tvJobDistance.setText(
                decimalFormat.format(
                        preferenceHelper.getDistance()
                        // / (1000 * 1.62))
                        )
                    + " "
                    + preferenceHelper.getUnit());
          }
        }
        // getDistance();
      }
    }
  }
 @Override
 public void onMapClick(LatLng position) {
   mMarker.setPosition(position);
   mMarker.showInfoWindow();
 }
 public static void update(Marker marker, Gcp gcp) {
   marker.setPosition(gcp.coord);
   marker.setTitle(String.valueOf(0));
   marker.setIcon(getIcon(gcp));
 }