[color=green][b]首先,在配置清单文件中需要 引入
<uses-library android:name="com.google.android.maps"/>
<uses-permission android:name="android.permission.INTERNET"/>
然后在layout布局文件中
可以引用 com.google.android.maps.MapView控件,因为它不是android基本包下, 所以需要加入前缀。
<com.google.android.maps.MapView
android:layout_height="fill_parent"
android:layout_wighth="fill_parent"
android:clockable="true"
android:enabled="true"
android:id="@+id/mapView_display"
android:apiKey="............"
这个ApiKey 需要在现在google中申请一个账号。然后在windows下的preference中的debug中找到keystore 然后启动cmd命令输入keytool -list -alias androiddebugkey -keystore "路径" -storepass android -keypass android
这样就能够拿到md5编码。然后到google上就可以拿到apikey了。
然后继承MapActivity。创建MapView 和MapController
MapController 通过MapView.getController()得到。
MapView.setsatelite()设置卫星云图
MapView.setStreet()设置街道
MapView.setTraffic()设置交通
MapView.setBuiltInZoomControls()设置多点触摸
MapController.animateTo()或者setCenter()的方式 显示指定的坐标
坐标通常是通过 经度和纬度来进行计算的。里面的参数是GeoPoint,在GeoPoint我们需要加入经纬度。
然后就可以调用 GoogleMap了。
[/b][/color]
<uses-library android:name="com.google.android.maps"/>
<uses-permission android:name="android.permission.INTERNET"/>
然后在layout布局文件中
可以引用 com.google.android.maps.MapView控件,因为它不是android基本包下, 所以需要加入前缀。
<com.google.android.maps.MapView
android:layout_height="fill_parent"
android:layout_wighth="fill_parent"
android:clockable="true"
android:enabled="true"
android:id="@+id/mapView_display"
android:apiKey="............"
这个ApiKey 需要在现在google中申请一个账号。然后在windows下的preference中的debug中找到keystore 然后启动cmd命令输入keytool -list -alias androiddebugkey -keystore "路径" -storepass android -keypass android
这样就能够拿到md5编码。然后到google上就可以拿到apikey了。
然后继承MapActivity。创建MapView 和MapController
MapController 通过MapView.getController()得到。
MapView.setsatelite()设置卫星云图
MapView.setStreet()设置街道
MapView.setTraffic()设置交通
MapView.setBuiltInZoomControls()设置多点触摸
MapController.animateTo()或者setCenter()的方式 显示指定的坐标
坐标通常是通过 经度和纬度来进行计算的。里面的参数是GeoPoint,在GeoPoint我们需要加入经纬度。
然后就可以调用 GoogleMap了。
[/b][/color]