[英]Yelp Search API no coordinate for a business
I am using the Search YELP API to develop a mobile application. 我正在使用Search YELP API开发移动应用程序。 I would like to display several businesses on a google map. 我想在Google地图上显示几家公司。 But unfortunately, I dont receive everything the coordinate object in my business. 但不幸的是,我没有收到企业中所有的坐标对象。
"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"
},
How should I face with this problem ? 我应该如何面对这个问题? Is there any walkaround to display my business on the map anyway ? 无论如何,是否有任何解决方案可在地图上显示我的业务?
I just found an answer to my problem. 我刚刚找到问题的答案。
In case if the coordinates are not provided, I can use geocoding provided by 在如果不提供的坐标的情况下,我可以使用地理编码提供
in formatting my request like this : 在格式化我的请求是这样的:
// 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);
which is similar to : https://maps.googleapis.com/maps/api/geocode/json?address=54+Frith+Street,+London,+GB 类似于: https : //maps.googleapis.com/maps/api/geocode/json?address=54+Frith+Street,+London,+GB
The API return me a JSON : 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"
}
Hope it will help other people in that case ! 希望在这种情况下能对其他人有所帮助!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.