Android Google Map Application Example
来源:互联网 发布:软件定制 猪八戒网 编辑:程序博客网 时间:2024/06/05 04:14
Android Google Maps Application
- To integrate with Google maps application you need to apply for a free Google Map API Key.
- To get the Google Map API Key you need to sign up for the Android Maps API.
- To sign up, you will need to provide the certificate’s fingerprint (MD5).
- If you have a certificate fingerprint (MD5) you can sign up here and get the API Key.
To get certificate fingerprint (MD5) follow the simple steps below:
- You need to get the keystore file for getting the certificate fingerprint (MD5).
- Your keystore file can be found at the following path
"C:/Documents and Settings/<username>/Local Settings/Application Data/Android"
(Or)
"C:/Documents and Settings/<username>/.android"
Keystore file name is "debug.keystore" file.
Copy the "debug.keystore" file to some other folder (ex: - "D:/Androidkeystore/") (its user friendly to use).
Open command Prompt and go to the Java installed directory. ("C:/Program Files/Java/<JDK_version_number>/bin")
Then type the below line (given in box) and press enter.
Now you will get a
certificate fingerprint (MD5). (see the below image).
Here the MD5 certificate fingerprint is"64:88:A2:FC:AA:9F:B1:B0:CA:E4:D0:24:A8:1E:77:FB"
Click here to go for sign up page to get Google Map API Key.
Enter the MD5 certificate fingerprint in the textbox and get the API Key (see below image)
After clicking the Generate API Key Button , you will get Google Map API Key (red circled).
Now the sample xml layout code to use the Google map application in Android is as specified below
Coding:-
To use Google map in your application, you need to add <uses-library>
element together with the <uses-
permission> in AndroidManifest.xml file.
Now your AndroidManifest.xml code looks like
01
<?
xml
version
=
"1.0? encoding="
utf-8??>
02
<
manifest
xmlns:android
=
"http://schemas.android.com/apk/res/android"
03
package
=
"pack.sample.map"
04
android:versionCode="1?
05
android:versionName="1.0?>
06
<
application
android:icon
=
"@drawable/icon"
android:label
=
"@string/app_name"
>
07
<
uses-library
android:name
=
"com.google.android.maps"
/>
08
<
activity
android:name
=
".SampleMapApplication"
09
android:label
=
"@string/app_name"
>
10
<
intent-filter
>
11
<
action
android:name
=
"android.intent.action.MAIN"
/>
12
<
category
android:name
=
"android.intent.category.LAUNCHER"
/>
13
</
intent-filter
>
14
</
activity
>
15
</
application
>
16
<
uses-permission
android:name
=
"android.permission.INTERNET"
/>
17
</
manifest
>
To display map in your application, modify the main.xml file. It is located in <project-folder>/res/layout.
Use <com.google.android.maps.MapView> element to display map.
Now your main.xml code looks like
01
<?xml version=
"1.0"
encoding=
"utf-8"
?>
02
<RelativeLayout xmlns:android=
"http://schemas.android.com/apk/res/android"
03
android:layout_width=
"fill_parent"
04
android:layout_height=
"fill_parent"
>
05
<com.google.android.maps.MapView
06
android:id=
"@+id/mapView"
07
android:layout_width=
"fill_parent"
08
android:layout_height=
"fill_parent"
09
android:enabled=
"true"
10
android:clickable=
"true"
11
android:apiKey=
"0U7-rnRk3Os0sPZnZF9iejONnHMsGRLxU0JbrBg"
/>
12
</RelativeLayout>
Now edit your Java class file as specified below
01
@Override
02
public
void
onCreate(Bundle savedInstanceState)
03
{
04
super
.onCreate(savedInstanceState);
05
setContentView(R.layout.main);
06
}
07
@Override
08
protected
boolean
isRouteDisplayed() {
09
return
false
;
10
}
Now run the application, you should be able to see the Google Map…
- Android Google Map Application Example
- google map javascript api example in android
- android GOOGLE MAP应用
- android google map
- android google map 气泡
- Android调用Google Map
- 使用Android Google Map
- Android Google map使用
- Android:Google Map学习
- android Google map 范例
- Android Google Map
- Android google map
- android google map开发
- android google map
- android google map v2
- Android调用Google Map
- android google map
- android google map v2
- java的多态与向上转型
- 接口,new,匿名内部类
- 创建高可用性的故障转移群集(未测试)
- 引用 PKU-DP列表
- 如果做好一个管理者的反思
- Android Google Map Application Example
- 解决oracle问题的方法
- DWR 3 反向Ajax试用
- CSND我来了
- gentoo iptables 服务配置使用
- 关于C# UDP协议NAT打洞技术问题
- Get the screen size in Android
- VMWare虚拟机中配置Windows Mobile模拟器连接Cellular Emulator
- 常用的快捷键