使用FusedLocationProviderApi& amp;获取用户在后台服务上的位置。 Google Places API

时间:2015-11-18 08:21:30

标签: android google-maps google-places-api

我当前的代码使用FusedLocationProviderApi来获取用户当前的城市/地区。此代码位于我的Service

                try {
                    Geocoder gcd = new Geocoder(LocationUpdateService.this, Locale.getDefault());
                    List<Address> addresses = gcd.getFromLocation(location.getLatitude(), location.getLongitude(), 1);
                    if (addresses.size() > 0)
                    {
                        txtStation.setText("Locality : " + addresses.get(0).getLocality() + " Sublocal : " + addresses.get(0).getSubLocality());
                    }
                }catch (Exception e) {
                    Toast.makeText(LocationUpdateService.this, e.getMessage(), Toast.LENGTH_LONG).show();
                }

但是我需要显示用户更具体的地方(公交车站,加油站等),我想我必须使用Places API

如何将Places API与我当前的代码(使用FusedLocationProviderApi)进行整合?

我现在想的是使用FusedLocationProviderApi获取基本的latitude&amp; longitude,然后将Places API与这些坐标一起使用。

请帮助我/给我一些线索

非常感谢你的帮助

1 个答案:

答案 0 :(得分:2)

PlaceDetectionApi怎么样?