配置Google API SDK

如果要想进行Google Map或者说是定位服务的开发,那么肯定需要下载一个新的SDK的支持。

1、点击Android SDK Manager,下载SDK。

2、直接配置已经下载好的SDK到项目中。

配置完Google API SDK之后,那么下面就需要建立一个适合于Google的SDK的虚拟机。

LocationManager的使用

1、主要逻辑部分

/**
*
* @author Harvey
*
*
*/
public class MyGPSDemo extends Activity
{
private TextView msg = null; // 显示坐标信息
private LocationManager locationManager = null; // 位置管理 @Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
super.setContentView(R.layout.main); // 默认布局管理器 msg = (TextView) super.findViewById(R.id.msgTv); // 获得组件
locationManager = (LocationManager) super.getSystemService(Context.LOCATION_SERVICE); // 取得位置服务
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, // GPS定位提供者
1000, // 时间间隔设置为1秒
1, // 位置间隔设置为1米
new MyLocationListener()); // 设置位置监听
} private class MyLocationListener implements LocationListener
{ @Override
public void onLocationChanged(Location location)
{
// 设备位置发生改变时触发
msg.setText("用户位置发生改变,新的位置数据:\n" + "经度:" + location.getLongitude() + "\n" + "纬度:"
+ location.getLatitude() + "\n" + "数据精确度:" + location.getAccuracy() + "\n"
+ "时间:" + location.getTime() + "\n" + "速度:" + location.getSpeed() + "\n"
+ "方位:" + location.getBearing()); // 设置文本信息
} @Override
public void onProviderDisabled(String provider)
{
// 当数据提供者关闭时触发
} @Override
public void onProviderEnabled(String provider)
{
// 当数据提供者启用时触发
} @Override
public void onStatusChanged(String provider, int status, Bundle extras)
{
// 当位置信息状态更新时触发
}
}
}

2、布局文件main.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" > <TextView
android:id="@+id/msgTv"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/get_msg" /> </LinearLayout>

3、需要在AndroidManifest.xml文件中添加权限

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />

Google地图开发的更多相关文章

  1. Google地图开发总结

    我们经常使用地图查位置.看公交.看街景,同时地图还开放第三方的API给开发者.利用这些API进行地图的个性化的展示和控制,例如北京被水淹了,开发一个网页显示北京被淹的地图,地图上面标志被水淹的位置.严 ...

  2. Google地图

    Google地图开发总结 我们经常使用地图查位置.看公交.看街景,同时地图还开放第三方的API给开发者.利用这些API进行地图的个性化的展示和控制,例如北京被水淹了,开发一个网页显示北京被淹的地图,地 ...

  3. Google 地图 API V3 针对移动设备进行开发

    Google官方教程: Google 地图 API V3 使用入门 Google 地图 API V3 针对移动设备进行开发 Google 地图 API V3 之事件 Google 地图 API V3 ...

  4. 使用QT开发GoogleMap瓦片显示和下载工具(2)——Google地图瓦片投影和获取网址解析

    这篇主要说的是Google地图采用的投影方式,瓦片划分方式以及如何从给定的经纬度获取瓦片的数据的网址.所有资料均来自于网络,并亲自试验可行. Google地图投影 首先是地图投影问题,因为地球本身是一 ...

  5. 《ArcGIS Runtime SDK for Android开发笔记》——(13)、图层扩展方式加载Google地图

    1.前言 http://mt2.google.cn/vt/lyrs=m@225000000&hl=zh-CN&gl=cn&x=420&y=193&z=9& ...

  6. Google 地图 API V3 使用入门

    Google官方教程: Google 地图 API V3 使用入门 Google 地图 API V3 针对移动设备进行开发 Google 地图 API V3 之事件 Google 地图 API V3 ...

  7. Google 地图 API V3 之事件

    Google官方教程: Google 地图 API V3 使用入门 Google 地图 API V3 针对移动设备进行开发 Google 地图 API V3 之事件 Google 地图 API V3 ...

  8. Google 地图 API V3 之控件

    Google官方教程: Google 地图 API V3 使用入门 Google 地图 API V3 针对移动设备进行开发 Google 地图 API V3 之事件 Google 地图 API V3 ...

  9. Google 地图 API V3 之 叠加层

    Google官方教程: Google 地图 API V3 使用入门 Google 地图 API V3 针对移动设备进行开发 Google 地图 API V3 之事件 Google 地图 API V3 ...

随机推荐

  1. day3用户交互,格式化输出,数据类型,流程控制

    上节课复习: 1.运行python程序的三步骤:python test.py 1.先启动python解释器 2.将test.py的内容当作普通的字符读入内存 3.python解释器解释执行刚刚读入内存 ...

  2. Monkey and Banana (hdu 1069)

    http://acm.hdu.edu.cn/showproblem.php?pid=1069   题目描述: 给你n个箱子, 给你箱子的长宽高,箱子是可以无限使用的,问这些箱子摞起来最多能多高? 这些 ...

  3. [转]Android SQLite

    数据库操作SQLite Expert Personal 3 注:下载相关SQLite的文档在:http://www.sqlite.org/ 具体的sql语句不作长细介绍,在本博客中也有相关的文章. 一 ...

  4. Java学习介绍

    Java版本介绍 JavaME:微型版,用于开发小型设备.智能卡.移动终端应用(使用率较低) JavaSE:标准版,用于创建桌面应用(企业用JavaSE创建桌面应用较少) JavaEE:企业版,用于创 ...

  5. hdu 5084 前缀和预处理

    http://acm.hdu.edu.cn/showproblem.php?pid=5084 给出矩阵M,求M*M矩阵的r行c列的数,每个查询跟前一个查询的结果有关. 观察该矩阵得知,令ans = M ...

  6. jQuery插件初级练习1

    <!DOCTYPE html><html> <head> <meta charset="UTF-8"> <title>& ...

  7. CMUSphinx Learn - Before you start

    Before you start 开始之前 Before you start the development of the speech application, you need to consid ...

  8. 计算日期差(Python实现)

    class Solution: def Days(self,year,month,day): if (year%4==0 and year%100!=0) or year%400==0: monthl ...

  9. Delphi程序带参数运行

    程序1 program E1; uses Forms,Dialogs,SysUtils, EndM1 in 'EndM1.pas' {Form2}; {$R *.res} begin Applicat ...

  10. What makes for effective detection proposals? 论文解析

    1 介绍(INTRODUCTION) 本文主要对最近的 proposal 检测方法做一个总结和评价.主要是下面这些方法.  2 Detection Proposal 方法(DETECTION PROP ...