从位置坐标获得经度

时间:2017-10-11 20:37:14

标签: javascript html5 google-maps google-maps-api-3 google-api

我无法从经度中检索数据。静态地工作,但是如果我使用变量currentLatLng.longitutde,我得到null。 这是我的代码:

var currentLatLng = position.coords;
var latlon = "Latitude" + currentLatLng.latitude + ","
             + "Longitude" + currentLatLng.longitutde;
var mappOptions = {
    center: new google.maps.LatLng(currentLatLng.latitude,
                                   currentLatLng.longitutde),
    //center: new google.maps.LatLng(currentLatLng.latitude, 10.181531600000001),
    zoom: 15,
    mapTypeId: google.maps.MapTypeId.ROADMAP
};
var DirectionsService = new google.maps.DirectionsService;
var directionsDisplay = new google.maps.DirectionsRenderer;
var geocoder = new google.maps.Geocoder;
var map = new google.maps.Map(document.getElementById("map"), mappOptions);
directionsDisplay.setMap(map);

2 个答案:

答案 0 :(得分:1)

这是经度,而不是长期。

答案 1 :(得分:0)

注意不要自动填充它的经度,而不是长期 enter image description here