Google-places-api - 没有国家作出回应

时间:2018-01-04 11:01:56

标签: google-maps google-maps-api-3 google-places-api

我正在我的项目中使用Google-places-api

用户使用places-autocomplete查找城市,城市(place_id)存储在数据库中。然后他们可以看到他们访问过的国家。问题出在一些城市或地方。

如果我选择Dakhla中的城市MoroccoWestern Sahara,它不会返回任何国家/地区。它返回带有地址Dakhla 73000的这个json。

这是我的要求:

https://maps.googleapis.com/maps/api/place/details/json?placeid=ChIJQ2KgOjlIIgwRcgFf7vLbciU&key=

响应,你可以清楚地看到没有像国家这样的东西:

{
  "html_attributions": [

  ],
  "result": {
    "address_components": [
      {
        "long_name": "Dakhla",
        "short_name": "Dakhla",
        "types": [
          "locality",
          "political"
        ]
      },
      {
        "long_name": "73000",
        "short_name": "73000",
        "types": [
          "postal_code"
        ]
      }
    ],
    "adr_address": "<span class=\"locality\">Dakhla</span> <span class=\"postal-code\">73000</span>",
    "formatted_address": "Dakhla 73000",
    "geometry": {
      "location": {
        "lat": 23.7221111,
        "lng": -15.9347384
      },
      "viewport": {
        "northeast": {
          "lat": 23.7557101,
          "lng": -15.9082891
        },
        "southwest": {
          "lat": 23.6551306,
          "lng": -15.982863
        }
      }
    },
    "icon": "https://maps.gstatic.com/mapfiles/place_api/icons/geocode-71.png",
    "id": "4617ad02ab8faa18c1fbfa0d4ad6912184fd5d96",
    "name": "Dakhla",
    "photos": [
      {
        "height": 3456,
        "html_attributions": [
          "<a href=\"https://maps.google.com/maps/contrib/101097515652901724856/photos\">Anass eagles</a>"
        ],
        "photo_reference": "CmRaAAAA2Yed-VeeRRlwAFsiydbMubthP2DKraqL9h2Jm942UZDxlu2WQ7ZgLjOjHC3PaYqMuXsK7r2-pmxxRgFBjXvrgNBp5PzeVatbwZSQF5TGcdc-cqmdJZXMy-4xqaUD6eQ8EhBGXM0WrdBeM510nkZF2pr3GhSqU0hYlKDx7cAT_tLDUAXQpm3SFw",
        "width": 5184
      },
      {
        "height": 482,
        "html_attributions": [
          "<a href=\"https://maps.google.com/maps/contrib/115265998372124547858/photos\">AN OU AR</a>"
        ],
        "photo_reference": "CmRaAAAAkrItWe0tbch3zTtrTp7VHbNDT9RiZJtq0QBIGc2RHSTgNMHSRWkZ8ZtEC01-CmKCiSRf3AMlEcSTKuEKGuYZMKATIdTxWbwl6NoCle0xza9dW1_4GteLk5UaAaMZOxQ-EhDhG7HOlzFQKiWbcrx_RzIBGhRrFjrqxXA5iO4rlenGjaQC-dvmQQ",
        "width": 1280
      },
      {
        "height": 2848,
        "html_attributions": [
          "<a href=\"https://maps.google.com/maps/contrib/109340304984953152070/photos\">Laasri Photo</a>"
        ],
        "photo_reference": "CmRaAAAAw2NU-MmFfu4xeu42AbUwZfQq9YXvbfXuK6QBCl0651gO-EKW_4SUsM3jSA6TP277sAG77dNsZjoHZ9huVvyzuWyuGupf_49YHuTQIRVxXIXFuzKt8FicASPQ26QqET3XEhBkc5FudE60iEM8QMR5IV5aGhSfAm96l2t19ckVKMAna6dXG0MDwQ",
        "width": 4288
      }
    ],
    "place_id": "ChIJQ2KgOjlIIgwRcgFf7vLbciU",
    "reference": "CmRbAAAA6wvlR94FGET4itrDJ8zgThYhbU2uL4BVphEIKqkdXNpqigNTScX46GqylfK6x2_ETIhYFutmjN3eCIQzFsVHYJYX9n2nHycVa0AxwyJizPrnvFYAIiD8fO_Ib66TJTJoEhBLFH5SDZDZ9DTJuqKkHZsyGhTqn0loCaR8uHfVc1NfeNOMXaiTEQ",
    "scope": "GOOGLE",
    "types": [
      "locality",
      "political"
    ],
    "url": "https://maps.google.com/?q=Dakhla+73000&ftid=0xc2248393aa06243:0x2572dbf2ee5f0172",
    "utc_offset": 0,
    "vicinity": "Dakhla"
  },
  "status": "OK"
}
你会做什么?这个国家对我们非常重要。

修改

我唯一想到的是尝试获取国家/地区,如果没有此类信息,请使用它的坐标并尝试其他服务,例如OpenStreetMaps,但我希望避免使用两种不同的服务。

0 个答案:

没有答案