【问题标题】:Camera Update Factory is Not Initiliaze in Google Map谷歌地图中未初始化相机更新工厂
【发布时间】:2015-06-16 23:17:02
【问题描述】:

我在我的 android 应用程序中有一个地图.....我和我的朋友正在研究他创建了一个地图,它显示在他的 emalutor 中......当我在我的 Eclipse 中导入相同的项目时......nd运行它给我的错误是相机更新工厂不是 initilze ......但我的伙伴正在同一张地图上工作......我无法理解我的 emalutor 或 eclipse 中的问题是什么或任何其他原因......如果有人知道那么帮帮我

我的xml文件是

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >    

<fragment
    android:id="@+id/map"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    class="com.google.android.gms.maps.SupportMapFragment" />

 </LinearLayout>

我从我的地图活动中调用了这个

MapsInitializer.initialize(this);
getLayoutInflater().inflate(R.layout.activity_main_map, frameLayout);
googleMap = supportMapFragment.getMap();
googleMap.animateCamera(CameraUpdateFactory.zoomTo(20.0f));
googleMap.setMapType(GoogleMap.MAP_TYPE_TERRAIN);
googleMap.getUiSettings().setZoomGesturesEnabled(true);

【问题讨论】:

  • 朋友们我需要你的帮助....
  • 你是否关注Getting Started 公会并设置了所有的东西,包括Installing the Android SDK. 和Configuring the app to use Google Play services.. 这听起来像我的问题

标签: android eclipse google-maps android-camera google-maps-android-api-2


【解决方案1】:

getMap() 方法是异步的,你的下一行将在地图准备好之前执行,这样做:

 supportMapFragment.getMapAsync(new OnMapReadyCallback() {
        @Override
        public void onMapReady(GoogleMap googleMap) {
          googleMap.animateCamera(CameraUpdateFactory.zoomTo(20.0f));
          googleMap.setMapType(GoogleMap.MAP_TYPE_TERRAIN);
          googleMap.getUiSettings().setZoomGesturesEnabled(true);
        }
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-06-26
    • 1970-01-01
    • 1970-01-01
    • 2013-06-12
    • 1970-01-01
    相关资源
    最近更新 更多