mirror of
				https://github.com/commons-app/apps-android-commons.git
				synced 2025-10-31 14:53:59 +01:00 
			
		
		
		
	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:
		
							parent
							
								
									c6a7a5ec48
								
							
						
					
					
						commit
						f68939975d
					
				
					 1 changed files with 34 additions and 0 deletions
				
			
		|  | @ -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 |      * For showing credits | ||||||
|      */ |      */ | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Jason Whitmore
						Jason Whitmore