Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void newPosition(Location location) {
- mMap.clear();
- // check distance between device (="Me") and targets
- for(MarkerOptions marker : targets) {
- Location markerLocation = new Location(LocationManager.GPS_PROVIDER);
- markerLocation.setLatitude(marker.getPosition().latitude);
- markerLocation.setLongitude(marker.getPosition().longitude);
- float distance = location.distanceTo(markerLocation);
- Log.d(TAG, "newPosition: distance to " + marker.getTitle() + ": " + distance);
- }
- for(MarkerOptions marker : targets) {
- mMap.addMarker(marker);
- }
- LatLng position = new LatLng(location.getLatitude(), location.getLongitude());
- myMarker = new MarkerOptions();
- myMarker.position(position)
- .title("Me")
- //.icon(BitmapDescriptorFactory.fromResource(R.drawable.pink_monster));
- .icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_MAGENTA));
- mMap.addMarker(myMarker);
- Log.d(TAG, "newPosition: New location: lat " + location.getLatitude()
- + ", long " + location.getLongitude());
- CameraUpdateFactory.newLatLng(new LatLng(location.getLatitude(), location.getLongitude()));
- }
Add Comment
Please, Sign In to add comment