【发布时间】:2019-06-27 04:21:47
【问题描述】:
enter image description here我想为我的项目添加谷歌地图。我正在尝试这样做然后我遇到了这个问题
public class DriverMapActivity extends FragmentActivity implements OnMapReadyCallback {
private GoogleMap mMap;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_driver_map3);
// 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);
xml
<?xml version="1.0" encoding="utf-8"?>
<fragment 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:id="@+id/map"
tools:context=".DriverMapActivity"
android:name="com.google.android.gms.maps.SupportMapFragment" />
【问题讨论】:
-
显示错误日志
-
显示堆栈跟踪。我认为这可能是您在 XML 中使用地图片段并在代码中使用 SupportMapFragment
-
@Ruwan - 请显示您的所有代码,以便我可以看到您为 SupportMapFragment 导入的类并显示 xml 文件代码。
标签: java android google-maps android-fragments