【问题标题】:undefined Lat and Long google maps未定义的经纬度谷歌地图
【发布时间】:2015-10-21 10:20:16
【问题描述】:

我想要经纬度坐标。而不是协调我得到这个

位置: 荷兰瓦尔勒 地址:荷兰瓦尔勒 纬度:未定义 经度:未定义

    <script type="text/javascript">
    google.maps.event.addDomListener(window, 'load', intilize);
    function intilize() {
        var autocomplete = new google.maps.places.Autocomplete(document.getElementById("txtautocomplete"));

        google.maps.event.addListener(autocomplete, 'place_changed', function () {

        var place = autocomplete.getPlace();
        var location = "Address: " + place.formatted_address + "<br/>";
        location += "Latitude: " + place.geometry.location.A + "<br/>";
        location += "Longitude: " + place.geometry.location.F;
        document.getElementById('lblresult').innerHTML = location
        });

    };

    </script>

    <span>location:</span><input type="text" id="txtautocomplete" style="width:200px" placeholder="enter the adress"/>
    <label id="lblresult"></label>
</body>

【问题讨论】:

标签: javascript google-maps


【解决方案1】:

朋友,

.geometry.location.A/.geometry.location.F 不可访问,使用 lat() 和 lng()

改成这个:

    location += "Latitude: " + place.geometry.location.lat() + "<br/>";
    location += "Longitude: " + place.geometry.location.lng();

【讨论】:

    【解决方案2】:

    问题已解决。

    必须是“place.geometry.location.lat()”而不是“place.geometry.location.A” 和 “place.geometry.location.F”必须是“place.geometry.location.lng()”

    【讨论】:

      猜你喜欢
      • 2014-04-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多