Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/42.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 如何使用源纬度和目的纬度的google maps api生成纬度和经度_Html_Css_Google Maps - Fatal编程技术网

Html 如何使用源纬度和目的纬度的google maps api生成纬度和经度

Html 如何使用源纬度和目的纬度的google maps api生成纬度和经度,html,css,google-maps,Html,Css,Google Maps,我正在开发谷歌地图api 我需要使用源和目标纬度/经度来生成纬度和经度 请任何人帮忙,需要应用什么公式来生成源和目的地之间的纬度和经度。 是否有计算公式以及从源到目标的lat长度 您需要地理编码器来获取特定位置的纬度和经度 var startingPoint = 'your location'; var latitude, longitude, map, geocoder = new google.maps.Geocoder(); geocoder.geocode({'address': st

我正在开发谷歌地图api

我需要使用源和目标纬度/经度来生成纬度和经度

请任何人帮忙,需要应用什么公式来生成源和目的地之间的纬度和经度。 是否有计算公式以及从源到目标的lat长度


您需要地理编码器来获取特定位置的纬度和经度

var startingPoint = 'your location';
var latitude, longitude, map, geocoder = new google.maps.Geocoder();

geocoder.geocode({'address': startingPoint}, function(results, status){
    //console latitude & longitude of your location
    latitude = results[0].geometry.location.lat();
    longitude = results[0].geometry.location.lng();
    console.log("Latitude - " + latitude);
    console.log("Longitude - " + longitude);

    if(status == 'OK'){
        map = new google.maps.Map(document.getElementById('map'), {
            center: {lat: results[0].geometry.location.lat(), lng: results[0].geometry.location.lng()},
            zoom: 15
        }); 
    } else {
        console.log("Geocode not working - " + status);
    }
});

有关谷歌地图api的更多信息,请参阅此页。

在提出问题之前,我们必须至少尝试做一些研究这是按地址获取lat和longs的地理编码。是否有任何公式通过提供源纬度和目的纬度来生成纬度和经度。为了清晰起见,我最近更新了一张图片。