我正在基於locaton提醒應用程序,我想知道如何添加標記當前location..i我用下面的代碼,我想沒有任何代碼來放大地圖視圖..如何將標記添加到谷歌地圖v2上的當前位置?
public void onMapReady(GoogleMap googleMap) {
mMap = googleMap;
mMap.setMapType(googleMap.MAP_TYPE_NORMAL);
LatLng sydney = new LatLng(-34, 151);
mMap.addMarker(new MarkerOptions().position(sydney).title("Sydney"));
mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(sydney, 10f));
//Add a marker in Sydney, Australia, and move the camera.
mMap.setOnMapClickListener(new GoogleMap.OnMapClickListener() {
@Override
public void onMapClick(LatLng latLng) {
mMap.clear();
locationLat = latLng.latitude;
locationLong = latLng.longitude;
AddLocationActivity.this.addMarker(new LatLng(locationLat,locationLong), AddLocationActivity.locationName);
mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(locationLat,locationLong), 10.9f));
AddLocationActivity.this.mainClass.locationName = address;
Log.i("AddLocationActivity",""+AddLocationActivity.this.mainClass.locationName);
}
});
}
看一看他們的文檔:https://developers.google.com/maps/documentation/android- API /標記。 – chRyNaN