简体   繁体   English

如何使用谷歌地方API

[英]How to use google places API

I'm new to android programming and I want to ask how to get started with google places API. 我是android编程的新手,我想问一下如何开始使用google places API。 I've already searched so much on https://developers.google.com/places/training/basic-place-search and I'm not able to get a clear and organised result. 我已经在https://developers.google.com/places/training/basic-place-search上搜索了很多内容,但我无法获得清晰有序的结果。 Please help. 请帮忙。

To use the Places API from a Java/Android application, you'll need to do the following: 要使用Java / Android应用程序中的Places API,您需要执行以下操作:

  1. Get a Places API key from Google. 从Google获取Places API密钥。
  2. Make HTTP requests to the API, using something like Apache's HttpClient class that are included in the Android SDK. 使用Android SDK中包含的Apache的HttpClient类向API发出HTTP请求。 JSON-formatted data will be easier to work with than XML. JSON格式的数据比XML更容易使用。
  3. Take the response string, parse it using the JSONObject class, and then drill down into these JSONObject and JSONArray objects to get at the data that you want. 获取响应字符串,使用JSONObject类对其进行解析,然后深入查看这些JSONObjectJSONArray对象以获取所需的数据。

A Google search for "google places api android" turns up a handful of tutorials, such as this one: http://karnshah8890.blogspot.com/2013/03/google-places-api-tutorial.html Google搜索“google places api android”会出现一些教程,例如: http//karnshah8890.blogspot.com/2013/03/google-places-api-tutorial.html

You may also be interested in a library like this third-party offering on GitHub , which wraps the HTTP API calls into a more friendly object-oriented interface. 您可能也对像GitHub上的第三方产品这样的库感兴趣,它将HTTP API调用包装成更友好的面向对象的接口。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM