Google Place Api-位于多个位置

时间:2012-03-13 09:58:09

标签: ios4 google-places-api

我正在使用Google Place api在iphone中显示位置。我正在使用ClLocation管理器类来获取将作为api的参数传递的设备的当前位置。

但每次在多个设备的不同位置都不起作用。

任何帮助??

1 个答案:

答案 0 :(得分:0)

检查出来

  

http://code.google.com/apis/maps/documentation/places/#PlaceSearches

你可以 它是一个普通的Web服务,发布请求并获取XML / JSON列表

地方搜索请求是

的以下HTTP网址
  

https://maps.googleapis.com/maps/api/place/search/output?parameters

e.g

  

https://maps.googleapis.com/maps/api/place/search/json?location=-33.8670522,151.1957362&radius=500&types=food&name=harbour&sensor=false&key=AddYourOwnKeyHere

的形式获取JSON输出
{
  "html_attributions" : [
    "Listings by \u003ca href=\"http://www.yellowpages.com.au/\"\u003eYellow Pages\u003c/a\u003e"
  ],
  "results" : [
    {
      "geometry" : {
        "location" : {
          "lat" : -33.8719830,
          "lng" : 151.1990860
        }
      },
        "icon" : "http://maps.gstatic.com/mapfiles/place_api/icons/restaurant-71.png",
        "id" : "677679492a58049a7eae079e0890897eb953d79b",
        "name" : "Zaaffran Restaurant - BBQ and GRILL, Darling Harbour",
        "rating" : 3.90,
        "reference" : "CpQBjAAAAHDHuimUQATR6gfoWNmZlk5dKUKq_n46BpSzPQCjk1m9glTKkiAHH_Gs4xGttdOSj35WJJDAV90dAPnNnZK2OaxMgogdeHKQhIedh6UduFrW53wtwXigUfpAzsCgIzYNI0UQtCj38cr_DE56RH4Wi9d2bWbbIuRyDX6tx2Fmk2EQzO_lVJ-oq4ZY5uI6I75RnxIQJ6smWUVVIHup9Jvc517DKhoUidfNPyQZZIgGiXS_SwGQ1wg0gtc",
        "types" : [ "restaurant", "food", "establishment" ],
        "vicinity" : "Harbourside Centre 10 Darling Drive, Darling Harbour, Sydney"
    },
    {
      "geometry" : {
        "location" : {
          "lat" : -33.8722580,
          "lng" : 151.1986550
        }
      },
        "icon" : "http://maps.gstatic.com/mapfiles/place_api/icons/restaurant-71.png",
        "id" : "27ea39c8fed1c0437069066b8dccf958a2d06f19",
        "name" : "Criniti's Darling Harbour",
        "rating" : 3.60,
        "reference" : "CnRwAAAA-5kh5WZ3m1CMTO3LslvhRtAYsrOcQP7wB9AE1bV5R6Bd46NN5wB16MtImXWQ9eS1nWVbV_j-8iXYXRpU13Efp1t_d-Dp4WfEsFcYj-_g6db1SC1vAukyeCyotjS5xrwhzqWWAhgmA4qIliWeev2u1BIQprWzxl_hkj_w3QdTiUBYKxoUDVTjF4RugJdaJWkC4n6w6pSajKw",
        "types" : [ "restaurant", "food", "establishment" ],
        "vicinity" : "Shop 461, 2-10 Darling Drive, Harbourside Shopping Centre, DARLING HARBOUR"
    },
    ...additional results...
  ],
  "status" : "OK"
}

像这样获取XML

<?xml version="1.0" encoding="UTF-8"?>
<PlaceSearchResponse>
 <status>OK</status>
 <result>
  <name>Zaaffran Restaurant - BBQ and GRILL, Darling Harbour</name>
  <vicinity>Harbourside Centre 10 Darling Drive, Darling Harbour, Sydney</vicinity>
  <type>restaurant</type>
  <type>food</type>
  <type>establishment</type>
  <geometry>
   <location>
    <lat>-33.8719830</lat>
    <lng>151.1990860</lng>
   </location>
  </geometry>
  <rating>3.9</rating>
  <icon>http://maps.gstatic.com/mapfiles/place_api/icons/restaurant-71.png</icon>
  <reference>CpQBjAAAAJd_vFgeIo6ogU2gDLEe85XpxRi8LwIQXSVcPS5dxGIytvbNWic7gTlGIleeFRbrP-Rs4_V6AmCcF1RtaUXcb26_Oai6k6n34Ag17Cle3pnVl740CyNpp0VT48lOf7XkMngj75wKHqnApPZ9Bfcn0myuYeEZoKXw7c3pneO4Ty8FTxDqQyLiJk8CAkodTzSn5BIQj0ovOoMS5u-ds6_jygEGxRoUbKMNq2DBZdiS16jO3yku2DOBwNI</reference>
  <id>677679492a58049a7eae079e0890897eb953d79b</id>
 </result>
 <result>
  <name>Criniti's Darling Harbour</name>
  <vicinity>Shop 461, 2-10 Darling Drive, Harbourside Shopping Centre, DARLING HARBOUR</vicinity>
  <type>restaurant</type>
  <type>food</type>
  <type>establishment</type>
  <geometry>
   <location>
    <lat>-33.8722580</lat>
    <lng>151.1986550</lng>
   </location>
  </geometry>
  <rating>3.6</rating>
  <icon>http://maps.gstatic.com/mapfiles/place_api/icons/restaurant-71.png</icon>
  <reference>CnRwAAAAwE_vlF04Iix2hijlKQsJLhpvAj8hwpfXGxtc0ckpBe0d54-rk4dxn8d1ZbaPGxxYfytkf4WJ7l5UC4Zh8jFZg0MTu1S8d66BK4vb2ktpAsKkfb28i3Mrf77ORRPXXjWwRtA7PEEfMP07mjfX3Xdg-RIQwjSMECQHM5S9WAohBIVB0BoUAb4i1DW-fL9E6XbgiDnmyZKrzRE</reference>
  <id>27ea39c8fed1c0437069066b8dccf958a2d06f19</id>
 </result>
 ...additional results...
 <html_attribution>Listings by &lt;a href="http://www.yellowpages.com.au/"&gt;Yellow Pages&lt;/a&gt;</html_attribution>
</PlaceSearchResponse>