Google Service Location API是否需要互联网? [英] Google Service Location API needs internet?

查看:226
本文介绍了Google Service Location API是否需要互联网?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在学习Google Maps API V2,现在正在阅读有关Location API的信息,文档说它将client连接到Service:

I am learning the Google Maps API V2 and now I am reading about the Location API, the documents says it connects a client to the Service:

位置服务通过以下方式将当前位置发送到您的应用程序: location客户端,它是Location Services类的实例 LocationClient.所有对位置信息的请求都将通过此过程 客户.

Location Services sends the current location to your app through a location client, which is an instance of the Location Services class LocationClient. All requests for location information go through this client.

这是否意味着Google将会获得我应用程序所在的所有位置?我知道如果已经下载了Google地图,那么Google地图可以在离线模式下工作,但是位置服务是否只能在线运行?

Does this means that Google will be getting all the positions where my app is? I know Google Maps can work in offline mode if the maps are already downloaded, but does the Location services only function online?

我需要控制我的应用程序中的互联网流量,因此是一个问题.

I need to control the internet traffic in my app, so hence the question.

推荐答案

工作方式:

这种方式使用服务提供商的网络连接来确定您的位置.返回的经度和纬度绝对不是最准确,但是,以我的经验,它们可以使您达到10-15%的准确度.

This way uses your service providers Network connection to figure out where you are. The Longitude and Latitude returned are most definitely not the most accurate however, they get you to with 10-15% accuracy (in my experience).

以下是说明此问题的代码段(直接从Android网站中拉出)

Here is a snippet of code that illustrates this (pulled directly of the Android website)

// Acquire a reference to the system Location Manager
LocationManager locationManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE);

// Define a listener that responds to location updates
LocationListener locationListener = new LocationListener() {
    public void onLocationChanged(Location location) {
      // Called when a new location is found by the network location provider.
      makeUseOfNewLocation(location);
    }

    public void onStatusChanged(String provider, int status, Bundle extras) {}

    public void onProviderEnabled(String provider) {}

    public void onProviderDisabled(String provider) {}
  };

// Register the listener with the Location Manager to receive location updates
locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, locationListener);

方式2:Wifi连接.必须在线.

此方法比以前的方法准确得多.但是,缺点是您必须在线并连接到Internet.此方法使用与在任何网络浏览器上找到的JavaScript版本的Google地图相同的理论.此方法返回的经度和纬度几乎是准确的.

Way 2: Wifi Connection. Have to be online.

This method is much more accurate than the previous one. However the drawback is that you have to be online and connected to the internet. This method uses the same theory as your JavaScript version of Google maps found on any web browser. The Longitude and Latitude returned by this method are almost exact.

GPS最为精确,它只能在户外工作,它会很快消耗电池电量,并且不会像用户想要的那样迅速返回位置.但是,GPS不需要连接到Internet或移动数据.它通过向公共卫星发出请求来获取您的位置.

GPS is most accurate, it only works outdoors, it quickly consumes battery power, and doesn't return the location as quickly as users want. However GPS requires no connection to the internet or Mobile data. It gets your location via a request to public satellites.

这是您需要的两个功能. getLatitude()和getLongitude().

Here are the two functions you need. getLatitude() and getLongitude().

请记住,这很有趣.但是google maps api v2具有简单的功能

Keep in mind this is all fun and stuff. But the google maps api v2 has a simple function

mMap.setMyLocationEnabled(true);

会考虑所有三种可能的方法以获取您的位置.

which considers all three possibilities t get your location.

这篇关于Google Service Location API是否需要互联网?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆