配置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. kettle之时间字段默认值为空或’0000-00-00’问题

    今天使用kettle从mysql导数到oracle,发现只导了7行后,数据传输就终止了,查看日志信息,报错如下: 报:Couldn't get row from result set问题. 发现从这行 ...

  2. poj 3278 Catch That Cow(bfs+队列)

    Description Farmer John has been informed of the location of a fugitive cow and wants to catch her i ...

  3. python advanced programming (Ⅲ)

    IO编程 IO在计算机中指Input/Output.由于程序和运行时数据是在内存中驻留,由CPU来执行,涉及到数据交换的地方,通常是磁盘.网络等,就需要IO接口. IO编程中,Stream(流)是一个 ...

  4. Java类、属性、方法、构造方法、块、内部类的基本概念

    类 概念:类相当于一个模板,里面定义了多个对象共同的属性和方法 基本结构:属性.方法.构造方法.块.内部类 声明形式:[访问权限修饰符][修饰符] class 类名 { 类体 } 属性 概念:存放对象 ...

  5. QT5.4.0安装以及与VS2010整合安装---64bit操作系统解决方案

    QT5.4.0安装以及与VS2010整合安装---64bit操作系统解决方案 注意,目前QT官网不能下载,必须提供注册,然后才可以下载. 网上不同版本安装的细节有差异,特将我的安装相关操作贴出来,希望 ...

  6. bootstrap table 前端搜索

    1.bootstrap-table对于前端的搜索可以通过官网设置,但发现前端搜索出现bug,网上找到一个bootstrap-table的扩充js  bootstrap-table-mytoolbar. ...

  7. 为什么要使用Entity Framework

    本文介绍从DDD(Domain-Driven Design[领域驱动设计])的角度来说说为什么要使用Entity Framework(以下都会简称为EF),同时也看出类似Drapper之类的简陋ORM ...

  8. Could not find installable ISAM

    程序中去读EXCEL文档,以前一直参考<Asp.net读取Excel文件 2>http://www.cnblogs.com/insus/archive/2011/05/05/2037808 ...

  9. 1月第2周业务风控关注|“扫黄打非”部门查处互动作业、纳米盒等20多个学习类App

    易盾业务风控周报每周呈报值得关注的安全技术和事件,包括但不限于内容安全.移动安全.业务安全和网络安全,帮助企业提高警惕,规避这些似小实大.影响业务健康发展的安全风险. 1.全国"扫黄打非&q ...

  10. [leetcode.com]算法题目 - Plus One

    Given a number represented as an array of digits, plus one to the number. class Solution { public: v ...