Reputation: 3953
I am working on android application google map, I need to capture latitude and longitude when I am moving a map. Currently when I am clicking it is working, but I need coordinates when I am moving a map. My code is given below:
private void setUpMap() {
gMap.setOnMapClickListener(this);// add the listener for click for amap object
gMap.setOnMapClickListener(new GoogleMap.OnMapClickListener() {
@Override
public void onMapClick(LatLng latlng) {
// TODO Auto-generated method stub
latitude = latlng.latitude;
longitude = latlng.longitude;
address=GooglePlacesAutocompleteAdapter.getAddress(PickLocation.this,longitude,latitude);
edtAddressSearch.setFocusable(false);
edtAddressSearch.setFocusableInTouchMode(false);
edtAddressSearch.setText(address);
}
});
gMap.setOnCameraMoveListener(new GoogleMap.OnCameraMoveListener() {
@Override
public void onCameraMove() {
// Toast.makeText(getApplicationContext(),"map is moving",Toast.LENGTH_LONG).show();
}
});
}
Upvotes: 1
Views: 1210
Reputation: 7905
Obtain the LatLng
object from the CameraPosition
variable inside onCameraMove
:
@Override
public void onCameraMove() {
LatLng target = gMap.getCameraPosition().target;
}
Upvotes: 2