Facebook Friends Mapper Android ^hot^ -
private void addMarkerToMap(FriendLocation friend) { if (googleMap == null) return; LatLng position = new LatLng(friend.latitude, friend.longitude); MarkerOptions markerOptions = new MarkerOptions() .position(position) .title(friend.name) .snippet(friend.location) .icon(BitmapDescriptorFactory.defaultMarker( BitmapDescriptorFactory.HUE_AZURE )); Marker marker = googleMap.addMarker(markerOptions); friendMarkers.put(friend.name, friend); // Center map on first friend if (friendMarkers.size() == 1) { googleMap.moveCamera(CameraUpdateFactory.newLatLngZoom(position, 5)); } }
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <androidx.cardview.widget.CardView android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margin="8dp" app:cardElevation="4dp"> facebook friends mapper android
private void geocodeLocation(String locationName, String friendName) { Geocoder geocoder = new Geocoder(this); try { List<Address> addresses = geocoder.getFromLocationName(locationName, 1); if (!addresses.isEmpty()) { Address address = addresses.get(0); LatLng position = new LatLng(address.getLatitude(), address.getLongitude()); FriendLocation friend = new FriendLocation( friendName, locationName, position.latitude, position.longitude ); allFriends.add(friend); addMarkerToMap(friend); } } catch (Exception e) { e.printStackTrace(); } } LatLng position = new LatLng(friend.latitude
Leave a Reply