我正在構建一個android應用程序並使用mapActivity。如何在android中使用MapActivity?
但是,問題是,當我運行我的應用程序時沒有顯示地圖。
這裏是我的活動代碼:
public class MainActivitytut extends FragmentActivity{
GoogleMap map;
private static MapController mMapController;
private static final LatLng GOLDEN_GATE_BRIDGE =
new LatLng(37.828891,-122.485884);
private static final LatLng APPLE =
new LatLng(37.3325004578, -122.03099823);
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_maintut);
map = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map)).getMap();
if (map == null) {
Toast.makeText(this, "Google Maps not available",
Toast.LENGTH_LONG).show();
}
}
這裏是我的xml:
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
xmlns:android="http://schemas.android.com/apk/res/android">
<fragment
android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.google.android.gms.maps.SupportMapFragment" />
<TextView
android:id="@+id/locinfo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="104dp"
android:layout_marginTop="113dp"
android:text="TextView" />
</RelativeLayout>
問題被更新爲最新的每個谷歌地圖需要。
謝謝Android Man我使用這個,但沒有顯示緯度和長。 – Test123 2014-11-14 15:01:49
@Sonam:你有沒有清理過這個項目?如果沒有請清潔它...請檢查我的代碼,我已經烤了latlng。 – 2014-11-14 15:03:40
謝謝這樣做的確存在我身邊的一些錯誤...... – Test123 2014-11-14 15:04:07