Facebook Friends Mapper Android __full__ -
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_friends_mapper); initializeViews(); setupMap(); setupFacebookLogin(); }
<fragment android:id="@+id/map" android:name="com.google.android.gms.maps.SupportMapFragment" android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" />
<?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 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)); } }
// Helper class private static class FriendLocation { String name; String location; double latitude; double longitude; FriendLocation(String name, String location, double lat, double lng) { this.name = name; this.location = location; this.latitude = lat; this.longitude = lng; } } } res/layout/activity_friends_mapper.xml ?xml version="1.0" encoding="utf-8"?>
private void initializeViews() { progressBar = findViewById(R.id.progressBar); statusText = findViewById(R.id.statusText); searchFilter = findViewById(R.id.searchFilter); loginButton = findViewById(R.id.loginButton); filterButton = findViewById(R.id.filterButton); filterButton.setOnClickListener(v -> filterFriendsByName()); }
private void setupMap() { SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map); mapFragment.getMapAsync(this); } LatLng position = new LatLng(friend.latitude
public class FacebookFriendsMapperActivity extends AppCompatActivity implements OnMapReadyCallback {