【问题标题】:Google maps using android studio使用 android studio 的谷歌地图
【发布时间】:2015-02-05 07:15:58
【问题描述】:

我正在开发一个应用程序,它需要将用户的当前位置标记到谷歌地图上。我已经有了在当前位置设置标记的代码。

private void handleNewLocation(Location location) {
        Log.d(TAG, location.toString());

   //get the new latitude and longitude
        double currentLatitude = location.getLatitude();
        double currentLongitude = location.getLongitude();


        //create object to store them
        LatLng latLng = new LatLng(currentLatitude, currentLongitude);

        //create marker with the new position
        MarkerOptions options = new MarkerOptions()
                .position(latLng)
                .title("I am here!");

        //add marker to the map

        mMap.addMarker(options);

        //move camera to current location

        mMap.moveCamera(CameraUpdateFactory.newLatLng(latLng));
    }

编译时没有显示错误。但是在模拟器上运行时,它显示“MapActivity 已停止工作”。

我正在使用 Nexus 5 API 21x86 android 虚拟设备来运行应用程序。

请帮忙!!!!!!!

【问题讨论】:

  • 请发布您的 Logcat 。要查找您的 Logcat,请参考here
  • 请检查下面发布的答案并指导我。非常感谢!

标签: google-maps android-studio


【解决方案1】:

我觉得有很多问题,请参考here,一步一步做,你会得到地图。

另外,关于标记部分,请参考here

【讨论】:

  • 感谢您的链接 :) 我在 logcat 上没有显示任何错误,并且我的应用程序不再崩溃。不幸的是,更改地图类型、当前位置和放大/缩小等功能不起作用。只显示地图:(我该怎么办。
  • 你关注第二个link了吗?我跟着,它成功了,有什么问题?顺便说一句,你可以编辑你的问题,你不需要把 logcat 放在答案中
  • 我使用了谷歌地图路线的视频教程,但是当我按下“获取路线/路线”按钮时,它会转到原始谷歌地图应用程序并显示路线。我的意图是从谷歌地图数据库/API 中检索路线,并在我的应用程序上而不是在谷歌地图上显示路线
猜你喜欢
  • 2017-08-16
  • 1970-01-01
  • 1970-01-01
  • 2021-11-10
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-07-13
相关资源
最近更新 更多