Guest User

Untitled

a guest
May 21st, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.29 KB | None | 0 0
  1. private void newPosition(Location location) {
  2.  
  3. mMap.clear();
  4.  
  5. // check distance between device (="Me") and targets
  6. for(MarkerOptions marker : targets) {
  7.  
  8. Location markerLocation = new Location(LocationManager.GPS_PROVIDER);
  9. markerLocation.setLatitude(marker.getPosition().latitude);
  10. markerLocation.setLongitude(marker.getPosition().longitude);
  11.  
  12. float distance = location.distanceTo(markerLocation);
  13.  
  14. Log.d(TAG, "newPosition: distance to " + marker.getTitle() + ": " + distance);
  15.  
  16. }
  17.  
  18.  
  19.  
  20. for(MarkerOptions marker : targets) {
  21. mMap.addMarker(marker);
  22. }
  23.  
  24. LatLng position = new LatLng(location.getLatitude(), location.getLongitude());
  25. myMarker = new MarkerOptions();
  26. myMarker.position(position)
  27. .title("Me")
  28. //.icon(BitmapDescriptorFactory.fromResource(R.drawable.pink_monster));
  29. .icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_MAGENTA));
  30. mMap.addMarker(myMarker);
  31.  
  32. Log.d(TAG, "newPosition: New location: lat " + location.getLatitude()
  33. + ", long " + location.getLongitude());
  34.  
  35. CameraUpdateFactory.newLatLng(new LatLng(location.getLatitude(), location.getLongitude()));
  36. }
Add Comment
Please, Sign In to add comment