读完本文请接着看看http://blog.csdn.net/woshishuoshuoa/article/details/9775091哦,会有不一样的收获哦
前言:本文只是简单地写了一个简单的google地图的基本流程,简单地下载了一个世界地图而已,希望喜欢安卓的亲们会喜欢,不过,只是简单地入门哦~~~欢迎有想法的亲们提出更好的建议哦~~~
1,工作目录问题:在做谷歌地图项目时,一定要记得把Myeclipse的工作目录和自己的SDK(即android-sdk-windows文件夹)放在同一目录下;
2,打开sdk manager 在extras中安装 android support library, google play services,google market billing google market licensing;,
3,引入google-play-services_lib项目到myeclipse( file-import-android-existing android code into workspace 浏览到sdk项目对应的目录);
4,新建项目,选择带有google api的sdk,自己建的项目的工作包一定要和自己申请的api key对应;
注:若不会申请google Maps API key(用于开发和debug),可参阅http://blog.csdn.net/woshishuoshuoa/article/details/9774491
5,在新建项目的manifest中 加入
a、在application的子标签加入:
<meta-data android:name="com.google.android.maps.v2.API_KEY" android:value="自己的apikey"/>
b 、在mainifest跟标签下加入:<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
<!-- The following two permissions are not required to use Google Maps Android API v2, but are recommended. -->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<!-- opengl es -->
<uses-feature android:glEsVersion="0x00020000" android:required="true"/>
6,打开activity_main.xml
清空里面的内容
填入:
<?xml version="1.0" encoding="utf-8"?>
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.google.android.gms.maps.SupportMapFragment"/>;
7,打开Activity 修改继承MainActivity extends FragmentActivity ;
,8,引入google-play-services_lib:
右击自己的项目,选择 proprties->左侧, 选择android ,在右侧library一栏, 点击add 浏览到google-play-services_lib
这个项目 点击apply
注意:不要勾选is library;运行项目前 必须在自己的安卓手机上安装 google play services 和google play store
这个小案例只是简单地让大家熟悉了一下android google maps开发的流程,比较浅显,只是简单地得到了世界地图而已。。。会持续更新的哦~~~~