我的Java代码:
package com.readytogo;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.MapFragment;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.Marker;
import com.google.android.gms.maps.model.MarkerOptions;
import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
public class Hotel3MapActivity extends Activity{
private GoogleMap map;
private LatLng point = new LatLng(-19.91906 , -43.93857);
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_hotel3mapa);
map = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap();
Marker pointTest = map.addMarker(new MarkerOptions().position(point).title("Promenade Ianelli"));
map.moveCamera(CameraUpdateFactory.newLatLngZoom(point, 15));
map.animateCamera(CameraUpdateFactory.zoomTo(10), 2000, null);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// TODO Auto-generated method stub
return super.onCreateOptionsMenu(menu);
}
}
我的XML文件:
<?xml version="1.0" encoding="utf-8"?>
<fragment
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:name="com.google.android.gms.maps.MapFragment" />
答案 0 :(得分:0)