使用Google地理编码准确性与Javascript

时间:2013-01-11 20:58:39

标签: javascript google-geocoder

访问Google地理编码准确度值的语法是什么?这就是我现在所拥有的,但它在黑暗中是一个彻头彻尾的刺:

var googleValue = results[0].geomtery.Accuracy;

2 个答案:

答案 0 :(得分:0)

来自the API docs来自此示例回复:

http://maps.googleapis.com/maps/geo?q=Toledo&output=json&sensor=false&gl=es
#
# Returns
#
{
  "name": "Toledo",
  "Status": {
    "code": 200,
    "request": "geocode"
  },
  "Placemark": [ {
    "id": "p1",
    "address": "Toledo, Spain",
    "AddressDetails": {
        "Country": {
            "CountryNameCode": "ES",
            "CountryName": "Spain",
            "AdministrativeArea": {
                "AdministrativeAreaName": "CM",
                "SubAdministrativeArea":     {
                    "SubAdministrativeAreaName": "Toledo",
                    "Locality": {"LocalityName": "Toledo"}
                }
            }
        },
        "Accuracy": 4},
    "Point": {
      "coordinates": [ -4.0244759, 39.8567775, 0 ]
    }
  } ]
}

因此,您可以PlaceMark[0].AddressDetails.Accuracy访问它。

答案 1 :(得分:0)

正如第一条评论所说 - V3不再支持此位置功能。相反,您会收到一个“位置类型”值,该值使用四组值来描述准确性。可以使用以下语法访问它:

var googleValue = results[0].geometry.location_type;