LocationPickerActivity.java: add methods to easily move the map center

Before this change, any time the map center had to move, several lines of code had to be written.

This change creates several methods which move the map center to a specified location. By using these new methods,
moving the map center only takes one simple method call.
This commit is contained in:
Jason Whitmore 2024-05-28 17:52:44 -07:00
parent c6a7a5ec48
commit f68939975d

View file

@ -249,6 +249,40 @@ public class LocationPickerActivity extends BaseActivity implements
}
}
/**
* Moves the center of the map to the specified coordinates
*
*/
private void moveMapTo(double latitude, double longitude){
if(mapView != null && mapView.getController() != null){
GeoPoint point = new GeoPoint(latitude, longitude);
mapView.getController().setCenter(point);
mapView.getController().animateTo(point);
}
}
/**
* Moves the center of the map to the specified coordinates
* @param point The GeoPoint object which contains the coordinates to move to
*/
private void moveMapTo(GeoPoint point){
moveMapTo(point.getLatitude(), point.getLongitude());
}
/**
* Moves the center of the map to the media's location (likely EXIF data), if that data
* is available.
*/
private void moveMapToMediaLocation(){
if(cameraPosition != null){
double latitude = cameraPosition.getLatitude();
double longitude = cameraPosition.getLongitude();
moveMapTo(latitude, longitude);
}
}
/**
* For showing credits
*/