Ho trovato due modi per farlo:
1) Il modo più semplice, il primo è utilizzando la proprietà di destinazione nel Map CameraPosition oggetto
LatLng center = mMap.getCameraPosition().target;
2) Il secondo utilizza un oggetto VisibleRegion:
VisibleRegion visibleRegion = mMap.getProjection()
.getVisibleRegion();
Point x = mMap.getProjection().toScreenLocation(
visibleRegion.farRight);
Point y = mMap.getProjection().toScreenLocation(
visibleRegion.nearLeft);
Point centerPoint = new Point(x.x/2, y.y/2);
LatLng centerFromPoint = mMap.getProjection().fromScreenLocation(
centerPoint);
ho confrontato entrambe le risposte:
Log.d("MapFragment: ", "Center From camera: Long: " + center.longitude
+ " Lat" + center.latitude);
Log.d("Punto x", "x:" + x.x + "y:" + x.y);
Log.d("Punto y", "y:" + y.x + "y:" + y.y);
Log.d("MapFragment: ", "Center From Point: Long: "
+ centerFromPoint.longitude + " Lat"
+ centerFromPoint.latitude);
Grazie, non mi ero reso conto che GeoPoint non era disponibile nella v2. Stavo per usare l'oggetto VisibleRegion per calcolare il punto intermedio tra i quattro angoli della visualizzazione della mappa. –
Ha funzionato. Grazie –
@Radu Comaneci Come fare lo stesso con html javascript? Qualsiasi idea –