簡體   English   中英

Yelp搜索API沒有業務協調

[英]Yelp Search API no coordinate for a business

我正在使用Search YELP API開發移動應用程序。 我想在Google地圖上顯示幾家公司。 但不幸的是,我沒有收到企業中所有的坐標對象。

    "location":{  
      "neighborhoods":[  
         "West Ham",
         "Stratford"
      ],
      "state_code":"XGL",
      "display_address":[  
         "409 High Street",
         "West Ham",
         "London E15 4QZ",
         "UK"
      ],
      "coordinate":{  
         "longitude":-2.16E-4,
         "latitude":51.53907
      },
      "address":[  
         "409 High Street"
      ],
      "postal_code":"E15 4QZ",
      "geo_accuracy":5,
      "country_code":"GB",
      "city":"London"
   },

我應該如何面對這個問題? 無論如何,是否有任何解決方案可在地圖上顯示我的業務?

我剛剛找到問題的答案。

在如果不提供的坐標的情況下,我可以使用地理編碼提供

谷歌地圖API

在格式化我的請求是這樣的:

// Replace the API key below with a valid API key.
GeoApiContext context = new GeoApiContext().setApiKey("AIza...");
GeocodingResult[] results =  GeocodingApi.geocode(context,
    "1600 Amphitheatre Parkway Mountain View, CA 94043").await();
System.out.println(results[0].formattedAddress);

類似於: https : //maps.googleapis.com/maps/api/geocode/json?address=54+Frith+Street,+London,+GB

API向我返回JSON:

{
   "results" : [
      {
         "address_components" : [
            {
               "long_name" : "54",
               "short_name" : "54",
               "types" : [ "street_number" ]
            },
            {
               "long_name" : "Frith Street",
               "short_name" : "Frith St",
               "types" : [ "route" ]
            },
            {
               "long_name" : "Soho",
               "short_name" : "Soho",
               "types" : [ "neighborhood", "political" ]
            },
            {
               "long_name" : "Soho",
               "short_name" : "Soho",
               "types" : [ "sublocality_level_1", "sublocality", "political" ]
            },
            {
               "long_name" : "London",
               "short_name" : "London",
               "types" : [ "locality", "political" ]
            },
            {
               "long_name" : "London",
               "short_name" : "London",
               "types" : [ "postal_town" ]
            },
            {
               "long_name" : "Greater London",
               "short_name" : "Gt Lon",
               "types" : [ "administrative_area_level_2", "political" ]
            },
            {
               "long_name" : "United Kingdom",
               "short_name" : "GB",
               "types" : [ "country", "political" ]
            },
            {
               "long_name" : "W1D 4SL",
               "short_name" : "W1D 4SL",
               "types" : [ "postal_code" ]
            }
         ],
         "formatted_address" : "54 Frith Street, Soho, London W1D 4SL, UK",
         "geometry" : {
            "location" : {
               "lat" : 51.5137474,
               "lng" : -0.1318321
            },
            "location_type" : "ROOFTOP",
            "viewport" : {
               "northeast" : {
                  "lat" : 51.5150963802915,
                  "lng" : -0.130483119708498
               },
               "southwest" : {
                  "lat" : 51.5123984197085,
                  "lng" : -0.133181080291502
               }
            }
         },
         "types" : [ "street_address" ]
      }
   ],
   "status" : "OK"
}

希望在這種情況下能對其他人有所幫助!

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM