我正在Android Studio中开发Android Google Map项目。我有一个MapActivtity可以显示位置(吹漏代码:)
RecyclerView
我的布局是这样的:
public class MapsActivity extends FragmentActivity implements OnMapReadyCallback {
private GoogleMap mMap;
private LatLng marker;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_maps);
// Obtain the SupportMapFragment and get notified when the map is ready to be used.
SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
.findFragmentById(R.id.map);
mapFragment.getMapAsync(this);
}
@Override
public void onMapReady(GoogleMap googleMap) {
mMap = googleMap;
mMap.setMapType(GoogleMap.MAP_TYPE_HYBRID);
// Add a marker in Sydney and move the camera
LatLng iran = new LatLng(29, 52);
mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(iran, 5.0f));
addMarker(29.1,52.2,"ssss");
}
public void addMarker(double Lat,Double Lng, String Title){
marker=new LatLng(Lat,Lng);
mMap.addMarker(new MarkerOptions().position(marker).title(Title));
mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(marker, 10.0f));
//mMap.moveCamera(CameraUpdateFactory.newLatLng(marker));
}