Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/google-maps/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android googlemapv2中的googlemap类_Android_Google Maps - Fatal编程技术网

Android googlemapv2中的googlemap类

Android googlemapv2中的googlemap类,android,google-maps,Android,Google Maps,我目前在谷歌地图v2上工作。问题是我不能使用“googlemap”类,因为它显示了一个错误。我使用的是谷歌api 4.2。我如何使用这个类。xml文件代码如下所示 <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/too

我目前在谷歌地图v2上工作。问题是我不能使用“googlemap”类,因为它显示了一个错误。我使用的是谷歌api 4.2。我如何使用这个类。xml文件代码如下所示

 <?xml version="1.0" encoding="utf-8"?>
 <RelativeLayout 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"
tools:context=".MainActivity" >

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

 </RelativeLayout> 

如果您使用

class="com.google.android.gms.maps.SupportMapFragment"
然后,您必须在活动中使用SupportMapFragment类。 例如:


希望对您有所帮助

您需要在android项目中引用Google Play服务并导入

import com.google.android.gms.maps.GoogleMap;

你可以跟着

和参考


哪个错误?你把Google Play服务库添加到你的项目中了吗?你能指定错误吗?我不能在我的项目中使用Googlemap类activity@user1057197您是否引用过GooglePlay服务?是的,我正在使用GooglePlay服务,因为如果他试图在活动中强制转换类,则会弹出错误(正如他所说,在活动中会发生这种情况)。这件事上周发生在我身上。这可能不是原因,但我不能在其他人的帖子上发表评论=/你是对的,他说他不能特别使用这个类,不能得到片段。我读错了。很抱歉
import com.google.android.gms.maps.GoogleMap;