开发Android Maps App 基本流程
- 新建Android Maps Project
- 在AndroidManifest.xml加入相应的权限以及jar的引用
- 在布局文件中引入MapView
- 创建MapActivity视图
一、新建Android Maps Project
- File -------> Android Project
- 填写工程名:FirstAndroidMapApp
- 在Build Target中选择Google APIs (需要自己下载)
- 填写应用名称:FirstAndroidMapApp,包名:com.why.android, 去掉create activity前面的勾(这里可以先不创建Activity),填写版本7
二、在AndroidManifest.xml加入相应的权限以及jar的引用
- 权限:<uses-permission android:name="android.permission.INTERNET" /> 放在manifest节点下
- 包:<uses-library android:name="com.google.android.maps" /> 放在application节点下
三、在main.xml中引入MapView
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal" android:layout_width="fill_parent"
android:layout_height="fill_parent">
<com.google.android.maps.MapView
android:id="@+id/myMapView" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:layout_weight="1.0"
android:enabled="true" android:clickable="true"
android:apiKey="你申请的key" />
</LinearLayout>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal" android:layout_width="fill_parent"
android:layout_height="fill_parent">
<com.google.android.maps.MapView
android:id="@+id/myMapView" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:layout_weight="1.0"
android:enabled="true" android:clickable="true"
android:apiKey="你申请的key" />
</LinearLayout>
四、创建MainMapActivity
在包com.why.android下新建MainMapActivity让它继承MapActivity
package com.why.android
import android.os.Bundle;
public class MainMapActivity extends MapActivity{
@Override
protected void onCreate(Bundle bundle) {
super.onCreate(icicle);
this.setContentView(R.layout.main.xml);
protected void onCreate(Bundle bundle) {
super.onCreate(icicle);
this.setContentView(R.layout.main.xml);
}
@Override
protected boolean isRouteDisplayed() {
return true;
}
protected boolean isRouteDisplayed() {
return true;
}
}
完成后, 在AndroidManifest.xml中加<activity android:name=".MainMapActivity" />

本文详细介绍如何从零开始创建一个Android地图应用,包括设置项目、配置AndroidManifest.xml、引入MapView组件及创建MapActivity等步骤。
788

被折叠的 条评论
为什么被折叠?



