расхождения между местами Google api и результатами поиска на Картах - PullRequest
0 голосов
/ 05 февраля 2020

, если я указываю Google Maps на местоположение [-20.1419057374276,-157.33203817679], а затем выполняю поиск "туроператор" поблизости, я получаю, в случае этого местоположения, 9 результатов https://www.google.com/maps/search/Tour+operator/@-21.2333094,-159.7948598,14z

, если я использую Google Places API (в данном случае в R с использованием httr: GET - я также пробовал googleway) Я не получаю никаких результатов (статус: "ZERO_RESULTS"):

res.wild <-GET (вставить ( "<code>https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=",paste(centers$lat[i],centers$lon[i],sep=","),"&radius=35000&keyword=tour+operator&key=",myKey,sep=""))

где центры $ lat [i], центры $ lon [i] - -20.1419057374276, -157.33203817679

Я использовал поиск с помощью радара, который больше недоступен но, похоже, возвращал результаты в соответствии с прямым поиском на картах Google. Просматривая документацию, я не вижу, откуда это несоответствие. У кого-нибудь есть идеи?

спасибо!

1 Ответ

1 голос
/ 07 февраля 2020

Координаты, указанные в URL Карт Google, ненадежны, поскольку учитывают увеличение. Если вы хотите получить точные координаты, используйте другие методы, такие как геокодирование.

Координаты -20.1419057374276,-157.33203817679 указывают на Мауке, острова Кука: https://developers.google.com/maps/documentation/utils/geocoder/#q% 3D-20.141906% 252 C -157.332038

Если вы хотите добраться поблизости места из Раротонга, острова Кука, тогда вы можете, например, использовать -21.229237,-159.776349 вместо: https://developers.google.com/maps/documentation/utils/geocoder/#q% 3D-21.229237% 252 C -159.776349

Попробуйте этот запрос, используя вышеуказанные координаты :

https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=-21.229237, - 159,776349 и радиус = 35000 & ключевое слово = тур + оператор и ключ = YOUR_KEY

Вывод близок к тому, что вы получаете в Google Maps:

{
   "html_attributions" : [],
   "results" : [
      {
         "geometry" : {
            "location" : {
               "lat" : -21.2573049,
               "lng" : -159.7311111
            },
            "viewport" : {
               "northeast" : {
                  "lat" : -21.25565152010728,
                  "lng" : -159.7299870701073
               },
               "southwest" : {
                  "lat" : -21.25835117989272,
                  "lng" : -159.7326867298927
               }
            }
         },
         "icon" : "https://maps.gstatic.com/mapfiles/place_api/icons/generic_business-71.png",
         "id" : "d54699b006411b5a5f9450ee2b30e88ad7deec44",
         "name" : "Captain Tamas Lagoon Cruizes",
         "opening_hours" : {
            "open_now" : true
         },
         "photos" : [
            {
               "height" : 645,
               "html_attributions" : [
                  "\u003ca href=\"https://maps.google.com/maps/contrib/102745446521532412613\"\u003eCaptain Tamas Lagoon Cruises\u003c/a\u003e"
               ],
               "photo_reference" : "CmRaAAAA6O-c8lb1bdh75I9dWRqjmTZanPhSx8LgNlVxR9ZMtoLkQMQ0uzSMGFr_xtfwdID9wPS2DlNIXO4aqHc_eVGzjDjPNzLyO_f8YvIp6gaP3xoYGRfKoOb_aZpKOqS2INnMEhA75QSRQC4FQnM8sXketTROGhRC1SgaNX6Hg1S6PIxlVQEOiVM4CQ",
               "width" : 859
            }
         ],
         "place_id" : "ChIJmSbDLojTV3EROL5C9_iW6kg",
         "plus_code" : {
            "compound_code" : "P7V9+3H Ngatangiia District, Cook Islands",
            "global_code" : "53C2P7V9+3H"
         },
         "rating" : 4.8,
         "reference" : "ChIJmSbDLojTV3EROL5C9_iW6kg",
         "scope" : "GOOGLE",
         "types" : [ "travel_agency", "point_of_interest", "establishment" ],
         "user_ratings_total" : 102,
         "vicinity" : "Muri Beach, Muri"
      },
      {
         "geometry" : {
            "location" : {
               "lat" : -21.258145,
               "lng" : -159.732045
            },
            "viewport" : {
               "northeast" : {
                  "lat" : -21.25663512010728,
                  "lng" : -159.7310816201073
               },
               "southwest" : {
                  "lat" : -21.25933477989272,
                  "lng" : -159.7337812798927
               }
            }
         },
         "icon" : "https://maps.gstatic.com/mapfiles/place_api/icons/generic_business-71.png",
         "id" : "354b255213a808490880fe1b9551d0f442aae382",
         "name" : "Koka Lagoon Cruises",
         "opening_hours" : {
            "open_now" : true
         },
         "photos" : [
            {
               "height" : 3024,
               "html_attributions" : [
                  "\u003ca href=\"https://maps.google.com/maps/contrib/103124684904518750526\"\u003eHuong Tran\u003c/a\u003e"
               ],
               "photo_reference" : "CmRaAAAAbNLjafLjIMjmUaJ-jilVZuJfWt79C_IoPEC-epFVSSSSlwQLo9_RMVRWl_dAAx4naup6P8aCr-F-TtTtzWpB_cI0-B1RbBcbp4mIvGxqLQvBeX6DWKi-gaT1UjsfKhG4EhDDBz4JWPKmCx4Mq3hiUv1iGhTKRpHYORs6lj-VYV-bqwTo6VFw0g",
               "width" : 4032
            }
         ],
         "place_id" : "ChIJu4ZfKXbUV3ERrKo9dhOCJiI",
         "plus_code" : {
            "compound_code" : "P7R9+P5 Ngatangiia District, Cook Islands",
            "global_code" : "53C2P7R9+P5"
         },
         "rating" : 4.9,
         "reference" : "ChIJu4ZfKXbUV3ERrKo9dhOCJiI",
         "scope" : "GOOGLE",
         "types" : [ "point_of_interest", "establishment" ],
         "user_ratings_total" : 67,
         "vicinity" : "Muri Beach, Rarotonga"
      },
      {
         "geometry" : {
            "location" : {
               "lat" : -21.2204492,
               "lng" : -159.8285893
            },
            "viewport" : {
               "northeast" : {
                  "lat" : -21.21907502010728,
                  "lng" : -159.8273637201073
               },
               "southwest" : {
                  "lat" : -21.22177467989272,
                  "lng" : -159.8300633798927
               }
            }
         },
         "icon" : "https://maps.gstatic.com/mapfiles/place_api/icons/generic_business-71.png",
         "id" : "6ca2b13851e47e4474fd197888d503d352de2f15",
         "name" : "Tik-e Tours",
         "opening_hours" : {
            "open_now" : true
         },
         "photos" : [
            {
               "height" : 4032,
               "html_attributions" : [
                  "\u003ca href=\"https://maps.google.com/maps/contrib/117619328803821181982\"\u003eA Google User\u003c/a\u003e"
               ],
               "photo_reference" : "CmRaAAAAdq12AeQCjoIpk09GCOx-laja1_iJ2Vzgnonu1quJ0bIzdOjV6YOvBHYoJT8hXwlyaUGB5C5o14HS3i-FUdwOuln7OFsY56r-bguBuQGV5_ukiyNHrCiCeRU5M7PhaLo2EhAfer7M013sz3i2uVsxTEfSGhQqWr9yhhB8UKcNGps3kOxCFcQa3A",
               "width" : 3024
            }
         ],
         "place_id" : "ChIJGe7bPVnQV3ERHI7vgH-Ou3c",
         "plus_code" : {
            "compound_code" : "Q5HC+RH Arorangi District, Cook Islands",
            "global_code" : "53C2Q5HC+RH"
         },
         "rating" : 4.9,
         "reference" : "ChIJGe7bPVnQV3ERHI7vgH-Ou3c",
         "scope" : "GOOGLE",
         "types" : [ "point_of_interest", "establishment" ],
         "user_ratings_total" : 10,
         "vicinity" : "Arorangi District"
      },
      {
         "geometry" : {
            "location" : {
               "lat" : -21.2655311,
               "lng" : -159.7819558
            },
            "viewport" : {
               "northeast" : {
                  "lat" : -21.26411742010728,
                  "lng" : -159.7805932701072
               },
               "southwest" : {
                  "lat" : -21.26681707989272,
                  "lng" : -159.7832929298927
               }
            }
         },
         "icon" : "https://maps.gstatic.com/mapfiles/place_api/icons/generic_business-71.png",
         "id" : "91cdd05c5d95d60981a890fd54886ebcad4b8ba9",
         "name" : "Snorkel Cook Islands",
         "opening_hours" : {
            "open_now" : true
         },
         "photos" : [
            {
               "height" : 2304,
               "html_attributions" : [
                  "\u003ca href=\"https://maps.google.com/maps/contrib/112866284698762632354\"\u003eFe&#39;ena Syme Buchanan\u003c/a\u003e"
               ],
               "photo_reference" : "CmRaAAAAd8e9zm-Wsa8hR-YkjI-bbLB_N_qJ9k5TOaYAjiyYhrHUJjQkdC9DmFc3RZVnQKpcS-QY7A3AtJPIG5OLH8dNSAwiQUB2tYmB-CMD6ZDRUSqqBpa3P_p2y9jc2sv9Lqd4EhDJooK75NFPEz0k_YsX38WMGhS1znNvtNWs-xwCg1OL0sF1JRHRZQ",
               "width" : 3456
            }
         ],
         "place_id" : "ChIJKTe2bjLXV3ERHUapU18Vydg",
         "plus_code" : {
            "compound_code" : "P6M9+Q6 Takitumu District, Cook Islands",
            "global_code" : "53C2P6M9+Q6"
         },
         "rating" : 5,
         "reference" : "ChIJKTe2bjLXV3ERHUapU18Vydg",
         "scope" : "GOOGLE",
         "types" : [ "point_of_interest", "establishment" ],
         "user_ratings_total" : 1,
         "vicinity" : "Rarotonga"
      },
      {
         "geometry" : {
            "location" : {
               "lat" : -21.2031499,
               "lng" : -159.7862431
            },
            "viewport" : {
               "northeast" : {
                  "lat" : -21.20180492010728,
                  "lng" : -159.7848997701073
               },
               "southwest" : {
                  "lat" : -21.20450457989272,
                  "lng" : -159.7875994298927
               }
            }
         },
         "icon" : "https://maps.gstatic.com/mapfiles/place_api/icons/generic_business-71.png",
         "id" : "6c6524b3437e98c139998b5ec06ea81fd3ff2f5f",
         "name" : "Black Watch Charters",
         "place_id" : "ChIJP8sjaZbRV3ERaB06jfdehkY",
         "plus_code" : {
            "compound_code" : "Q6W7+PG Avarua District, Cook Islands",
            "global_code" : "53C2Q6W7+PG"
         },
         "rating" : 0,
         "reference" : "ChIJP8sjaZbRV3ERaB06jfdehkY",
         "scope" : "GOOGLE",
         "types" : [ "point_of_interest", "establishment" ],
         "user_ratings_total" : 0,
         "vicinity" : "Avarua District"
      },
      {
         "geometry" : {
            "location" : {
               "lat" : -21.1994895,
               "lng" : -159.8003902
            },
            "viewport" : {
               "northeast" : {
                  "lat" : -21.19841532010728,
                  "lng" : -159.7989554201073
               },
               "southwest" : {
                  "lat" : -21.20111497989272,
                  "lng" : -159.8016550798928
               }
            }
         },
         "icon" : "https://maps.gstatic.com/mapfiles/place_api/icons/generic_business-71.png",
         "id" : "5f02f471fe2868a51943041aa684874f8269ef7b",
         "name" : "Raro Safari Tours & Concierge Desk",
         "photos" : [
            {
               "height" : 3024,
               "html_attributions" : [
                  "\u003ca href=\"https://maps.google.com/maps/contrib/100947574557964297982\"\u003eJAY PILISI\u003c/a\u003e"
               ],
               "photo_reference" : "CmRaAAAA34pKKofPm9XF97_CcfSLVGq3y2AHn-linLaeEc1RfHRjpbJThl5EQuxKKmamNZ1i4cvqSu1-65He6nLolErQJLXEFDMPis4-5dKmK2TXS2-jyEsnrkcKKPiYqZD3B3jcEhC_GBl65rela41ctpewfxc3GhSt4oGQNCPui4k4j6vFU4o3hQWDDw",
               "width" : 4032
            }
         ],
         "place_id" : "ChIJgRilfy3RV3ERpi1MKCgisSw",
         "plus_code" : {
            "compound_code" : "R52X+6R Avarua District, Cook Islands",
            "global_code" : "53C2R52X+6R"
         },
         "rating" : 4.9,
         "reference" : "ChIJgRilfy3RV3ERpi1MKCgisSw",
         "scope" : "GOOGLE",
         "types" : [
            "tourist_attraction",
            "travel_agency",
            "point_of_interest",
            "establishment"
         ],
         "user_ratings_total" : 10,
         "vicinity" : "Avarua District"
      },
      {
         "geometry" : {
            "location" : {
               "lat" : -21.249997,
               "lng" : -159.822227
            },
            "viewport" : {
               "northeast" : {
                  "lat" : -21.24868352010728,
                  "lng" : -159.8209628201073
               },
               "southwest" : {
                  "lat" : -21.25138317989272,
                  "lng" : -159.8236624798928
               }
            }
         },
         "icon" : "https://maps.gstatic.com/mapfiles/place_api/icons/generic_business-71.png",
         "id" : "affb3957b65c2ca105d0c5e63e547e22b6d73493",
         "name" : "Adventure Cook Islands Ltd",
         "opening_hours" : {
            "open_now" : false
         },
         "photos" : [
            {
               "height" : 1063,
               "html_attributions" : [
                  "\u003ca href=\"https://maps.google.com/maps/contrib/111619238938552241021\"\u003eAdventure Cook Islands Ltd\u003c/a\u003e"
               ],
               "photo_reference" : "CmRaAAAAQ4B12jlUrWlqwK1gWdfEEoGndrBWhviA8DTSI-Q-UoGmyR_7b7mkbtI361dC9dAZh3-Z0YlOYTdvVze9Vuw9qjFNecFMcPGO30ISi6DXCPezDEM_eTZj_mPbCDdLh8cyEhBlTzcXyYr7Atj69fRyPkVhGhQI_eSnR2CEQfCZNOXfM9UOC7uytA",
               "width" : 1417
            }
         ],
         "place_id" : "ChIJOw686NzQV3ERYaRq_jbcJjw",
         "plus_code" : {
            "compound_code" : "Q52H+24 Arorangi District, Cook Islands",
            "global_code" : "53C2Q52H+24"
         },
         "rating" : 4.9,
         "reference" : "ChIJOw686NzQV3ERYaRq_jbcJjw",
         "scope" : "GOOGLE",
         "types" : [ "travel_agency", "point_of_interest", "establishment" ],
         "user_ratings_total" : 21,
         "vicinity" : "Kavera Beach, Arorangi Rarotonga"
      },
      {
         "geometry" : {
            "location" : {
               "lat" : -21.220265,
               "lng" : -159.828848
            },
            "viewport" : {
               "northeast" : {
                  "lat" : -21.21891637010728,
                  "lng" : -159.8274922201073
               },
               "southwest" : {
                  "lat" : -21.22161602989272,
                  "lng" : -159.8301918798927
               }
            }
         },
         "icon" : "https://maps.gstatic.com/mapfiles/place_api/icons/generic_business-71.png",
         "id" : "aca36479a072b313810c37ac835e50440bf3b81f",
         "name" : "Dive Rarotonga",
         "opening_hours" : {
            "open_now" : false
         },
         "photos" : [
            {
               "height" : 337,
               "html_attributions" : [
                  "\u003ca href=\"https://maps.google.com/maps/contrib/102784390999532361399\"\u003eDive Rarotonga\u003c/a\u003e"
               ],
               "photo_reference" : "CmRaAAAAW5A88HqZDDXA6her_GXw7zoxj2wB_U1O-tUubEBFNCteiAoPscB0o5-N5KvN-oY9TIaMnTD1-UhU1wNiX7-nSVMiUTIUcZIzEZFsDgJrO-xPL0hbm5jE887kq3V1VYVIEhCpMlOYcEqSDWLEDAPcnodCGhSBnJ1dO8GpFHZEnTMP6l9t2zpZpA",
               "width" : 600
            }
         ],
         "place_id" : "ChIJkSU-1V3QV3ER3yczeMV8I_k",
         "plus_code" : {
            "compound_code" : "Q5HC+VF Arorangi District, Cook Islands",
            "global_code" : "53C2Q5HC+VF"
         },
         "rating" : 4.9,
         "reference" : "ChIJkSU-1V3QV3ER3yczeMV8I_k",
         "scope" : "GOOGLE",
         "types" : [ "travel_agency", "point_of_interest", "store", "establishment" ],
         "user_ratings_total" : 33,
         "vicinity" : "Yellow A-Frame, Main Road, Arorangi District"
      },
      {
         "geometry" : {
            "location" : {
               "lat" : -21.252595,
               "lng" : -159.730144
            },
            "viewport" : {
               "northeast" : {
                  "lat" : -21.25122567010727,
                  "lng" : -159.7289091701073
               },
               "southwest" : {
                  "lat" : -21.25392532989272,
                  "lng" : -159.7316088298927
               }
            }
         },
         "icon" : "https://maps.gstatic.com/mapfiles/place_api/icons/generic_business-71.png",
         "id" : "f0b212e097fc057cb51138594070cfe5c014d436",
         "name" : "Pacific Divers",
         "opening_hours" : {
            "open_now" : false
         },
         "place_id" : "ChIJRUYyzojTV3ER9iL5iSVfHNo",
         "plus_code" : {
            "compound_code" : "P7W9+XW Ngatangiia District, Cook Islands",
            "global_code" : "53C2P7W9+XW"
         },
         "rating" : 0,
         "reference" : "ChIJRUYyzojTV3ER9iL5iSVfHNo",
         "scope" : "GOOGLE",
         "types" : [ "travel_agency", "school", "point_of_interest", "establishment" ],
         "user_ratings_total" : 0,
         "vicinity" : "Ara Tapu, Muri"
      },
      {
         "geometry" : {
            "location" : {
               "lat" : -21.2012422,
               "lng" : -159.8060292
            },
            "viewport" : {
               "northeast" : {
                  "lat" : -21.19968582010728,
                  "lng" : -159.8046350701073
               },
               "southwest" : {
                  "lat" : -21.20238547989272,
                  "lng" : -159.8073347298927
               }
            }
         },
         "icon" : "https://maps.gstatic.com/mapfiles/place_api/icons/generic_business-71.png",
         "id" : "e53fbdf110553cb3a56e69dedfc348e1da4e0172",
         "name" : "Turama Pacific Travel Group",
         "photos" : [
            {
               "height" : 525,
               "html_attributions" : [
                  "\u003ca href=\"https://maps.google.com/maps/contrib/104663734301544398423\"\u003eA Google User\u003c/a\u003e"
               ],
               "photo_reference" : "CmRaAAAAvgs-ezM5FNldJ1bfCf_sV0Ql58Nj54UKuirPef1T0FNqc6U2YLdpREuexg20VBWNwRdet--vuGenVsazreVEio-ezp4VEzYbrMv2BVbILKGswlL83NN8hT0BPEK3gTOaEhADvZmluOWXh0kRYgtcRE3oGhQ95v3wdXzFgfh06tOico2RmMJWiA",
               "width" : 700
            }
         ],
         "place_id" : "ChIJuUvKeLbRV3EROJNkUZhNG5g",
         "plus_code" : {
            "compound_code" : "Q5XV+GH Avarua District, Cook Islands",
            "global_code" : "53C2Q5XV+GH"
         },
         "rating" : 5,
         "reference" : "ChIJuUvKeLbRV3EROJNkUZhNG5g",
         "scope" : "GOOGLE",
         "types" : [ "travel_agency", "point_of_interest", "establishment" ],
         "user_ratings_total" : 1,
         "vicinity" : "Avarua District"
      }
   ],
   "status" : "OK"
}

Надеюсь, это поможет!

...