Android-Google的定位和地图-详细版

发布时间:2023-01-17 08:56:12   来源:文档文库   
字号:
Android——定位和地图
Location and Maps Quickview
你的应用程序可以利用Android提供的定位框架(location framework来确定设备的位置和方向,并且能够进行更新。
可以利用Google Maps外部类库来显示和管理地图数据
开发基于地理位置的服务可以使用 android.location类和Google Maps 外部类库来开发。
Location Services 可以利用android.location包来访问设备中的定位服务。Location framework的核心组件是LocationManager系统服务,该服务提供了确定位置的APIs和内置设备的方向(应该是电子罗盘了,如果可用的话
要获得一个LocationManager的实例,无需直接初始化,而是通过调 getSystemService(Context.LOCATION_SERVICE来获取一个实例。 一旦获得一个LocationManager的实例,你就可以在程序中做如下三件事:

Query for the list of all LocationProviders for the last known user location. 注册/解注册到一个定位提供商(specified either by criteria or name来周期性地更新用户的当前位置。
Register/unregister for a given Intent to be fired if the device comes within a given proximity (specified by radius in meters of a given lat/long. Google Maps External Library Google提供的地图外部类库——com.google.android.maps package. 这个包的类提供了内建的地图碎片的下载、翻译和缓存, 此外,还有很多显示选项和控制。

在这个类库中的核心类是com.google.android.maps.MapView, ViewGroup的子类。一个MapView显示从Google Maps服务获得的图形和数据。当MapView获得焦点的时候,它将捕捉用户按下的键和触摸姿势来显示和放缩地图,包括管理额外的地图标题的网络请求。它还包含了供用户控制地图的必须的UI元素。你的应用程序还能够使用MapView类提供的方法来编程控制MapView,并能够在地图上绘制一些覆盖的按钮等UI元素。
Google Maps外部类库不是标准的Android库的一部分,所以它可能并不包含在一些编译好的Android设备中,也不包含在Android SDK中。但是你能够使用
com.google.android.maps包中的类进行开发,Google Maps外部类库将会作为Android SDKGoogle APIs插件存在。
获取更多的Google Maps外部类库的信息,以及如何下载使用Google APIs插件,可以访问:
http://code.google.com/android/add-ons/google-apis For your convenience, the Google APIs add-on is also available as a downloadable component from the Android SDK and AVD Manager (see Adding SDK Components. Note: In order to display Google Maps data in a MapView, you must register with the Google Maps service and obtain a Maps API Key. For information about how to get a Maps API Key, see Obtaining a Maps API Key. Obtaining User Location Quickview
网络位置提供商提供好的位置数据而且需要GPS 获取用户位置会消耗大量的电力,所以要注意你能花费多长的时间来更新位置。
Key classes 1. 2. LocationManager LocationListener 要了解用户哪儿需要你的应用程序更加智能以传递更好的信息给用户。 当开发一个基于位置的应用程序时,你能够利用GPSAndroid的网络位置提供商来获取用户位置。尽管GPS是更加精确地,但它仅在户外使用,它也会快速地消耗大量的电量,并且不能尽快地返回位置信息。Android的网络位置提供商使用cell tower(基塔)和Wi-FI信令来确定用户的位置,不管用户在户内还是户外,提供用户的位置信息,而且速度更快,消耗电量更少。为了获取到用户位置,你的应用程序可以利用GPS和网络位置提供商,或者只是使用其中一个。
Challenges in Determining User Location 在一个移动设备上获取用户位置可能是结构复杂的。之所以读取用户位置出错或者不精确,有以下几方面的原因。

Multitude of location sources


本文来源:https://www.2haoxitong.net/k/doc/709a3e4ee45c3b3567ec8bff.html

《Android-Google的定位和地图-详细版.doc》
将本文的Word文档下载到电脑,方便收藏和打印
推荐度:
点击下载文档

文档为doc格式