Android Google Maps API V2.0 - Including MapView i

2019-07-23 18:02发布

问题:

I am trying to insert a MapView into a Fragment however I can't find the correct class to cast the MapView object to.

I am inserting the MapView into my fragment like so.

<com.google.android.gms.MapView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/map_view_track"/>

However, I inevitably get a ClassCastException.

Is it possible to insert a MapView this way? I'm pretty sure it is.

回答1:

com.google.android.gms.Maps does not exist as a class, AFAIK. Try com.google.android.gms.maps.MapView.