Folks, I built a fragment that has a SupportMapFragment I want to be able to drag the map and detect new "area" the camera is showing so I can load my markers within that area.
((SupportMapFragment) getChildFragmentManager().findFragmentById(R.id.map)).getMapAsync(this);
On the mapReadycall back I added a onCameraChangeListener:
@Override
public void onMapReady(GoogleMap googleMap) {
googleMap.getUiSettings().setZoomControlsEnabled(false);
googleMap.getUiSettings().setMyLocationButtonEnabled(true);
googleMap.setOnCameraChangeListener(new GoogleMap.OnCameraChangeListener() {
@Override
public void onCameraChange(CameraPosition cameraPosition) {
showItemsinMap(cameraPosition.target.latitude, cameraPosition.target.longitude);
}
});
}
I have another feature on my map that I can drag a polygon on top of it and get the markers within an area by using the getProjection method:
LatLng latLng = map.getProjection().fromScreenLocation(x_y_points);
where x_y_points are the x,y coordinates on the screen then I create a polygon and add get SW, SE, NW and NE points to get an area to search for markers.
What would be the best approach to handle a new area on the map?