У меня есть приложение для Android, которое я создаю, использующее Карты Google с помощью приемника местоположения. Когда карта сначала появляется, у меня есть масштабирование, установленное на 12 в приемнике местоположения, я довольно новичок в разработке Google Maps, поэтому мне было интересно, как я могу обновить местоположение, не влияя на масштаб, как только пользователь ущипнет, чтобы изменить масштаб? Ниже мой приемник.Как обновить маркер карты без изменения масштаба, который пользователь установил?
/**
*Mylocationlistener class will give the current GPS location
*with the help of Location Listener interface
*/
private class Mylocationlistener implements LocationListener {
@Override
public void onLocationChanged(Location location) {
if (location != null) {
// ---Get current location latitude, longitude---
Log.d("LOCATION CHANGED", location.getLatitude() + "");
Log.d("LOCATION CHANGED", location.getLongitude() + "");
currentLocation = new LatLng(location.getLatitude(), location.getLongitude());
currentLatLng = new LatLng(location.getLatitude(), location.getLongitude());
Marker currentLocationMarker = map.addMarker(new MarkerOptions().position(currentLocation).title("Current Location"));
// Move the camera instantly to hamburg with a zoom of 15.
map.moveCamera(CameraUpdateFactory.newLatLngZoom(currentLatLng, 15));
// Zoom in, animating the camera.
map.animateCamera(CameraUpdateFactory.zoomTo(12), 2000, null);
if (!firstPass){
currentLocationMarker.remove();
}
firstPass = false;
Toast.makeText(MapViewActivity.this,"Latitude = "+
location.getLatitude() + "" +"Longitude = "+ location.getLongitude(),
Toast.LENGTH_LONG).show();
}
}
Благодарим за это. Это сработало. – yams