Google maps 如何在谷歌地图中获得点的坐标?

Google maps 如何在谷歌地图中获得点的坐标?,google-maps,google-maps-api-3,maps,Google Maps,Google Maps Api 3,Maps,我目前正在处理我的地图,在那里我可以动态添加路由并将其保存到my mysql数据库。我已经知道如何得到标记A和B的坐标,但我知道如何得到白点的坐标。如何得到它的坐标?或者有可能得到它的坐标 我使用了这种代码 函数initMap(){ var lat_液化天然气={ 纬度:22.08672, 液化天然气:79.42444 }; var map=new google.maps.map(document.getElementById('map'){ 缩放:6, 中心:拉图液化天然气 }); var

我目前正在处理我的地图,在那里我可以动态添加路由并将其保存到my mysql数据库。我已经知道如何得到标记A和B的坐标,但我知道如何得到白点的坐标。如何得到它的坐标?或者有可能得到它的坐标

我使用了这种代码

函数initMap(){
var lat_液化天然气={
纬度:22.08672,
液化天然气:79.42444
};
var map=new google.maps.map(document.getElementById('map'){
缩放:6,
中心:拉图液化天然气
});
var directionsService=新的google.maps.directionsService;
var directionsDisplay=新建google.maps.DirectionsRenderer({
真的,
地图:地图,
面板:document.getElementById('右面板')
});
directionsDisplay.addListener('directions\u changed',function(){
ComputeTotalInstance(directionsDisplay.getDirections());
});
显示路线('新德里,IN','印多尔,IN',方向服务,
方向显示);
}
功能显示路线(起点、终点、服务、显示){
服务路线({
来源:来源,,
目的地:目的地,
航路点:[{
地点:印度新德里
}, {
地点:'印多尔,位于'
}],
travelMode:google.maps.travelMode.DRIVING,
避免收费:正确
},功能(响应、状态){
if(status==google.maps.directionstatus.OK){
显示。设置方向(响应);
}否则{
警报('由于:'+状态而无法显示方向);
}
});
}

您可以尝试以下事件侦听器:

google.maps.event.addListener(marker, 'dragend', function (event) {
    document.getElementById("latbox").value = this.getPosition().lat();
    document.getElementById("lngbox").value = this.getPosition().lng();
});

像这样初始化映射。。我使用了事件侦听器方向,因此对于每次更改,它都会自动保存其航路点

 var map, ren, ser, waypoints;
  function initmap()
{
   map = new google.maps.Map( document.getElementById('map'),
   {'zoom':10,'mapTypeId': google.maps.MapTypeId.ROADMAP, 'center': new 
    google.maps.LatLng(9.848070, 124.218979) })

   ren = new google.maps.DirectionsRenderer( {'draggable':true} );
   ren.setMap(map);
   ser = new google.maps.DirectionsService();


   ren.addListener('directions_changed', function() {
//if you drag the dots it automatically chnage the way ponts
 computeTotalDistance(ren.getDirections());
save_waypoints();

});
  function save_waypoints()
 {
var w=[],wp;
var rleg = ren.directions.routes[0].legs[0];
data.start = {'lat': rleg.start_location.lat(), 'lng':rleg.start_location.lng()}
data.end = {'lat': rleg.end_location.lat(), 'lng':rleg.end_location.lng()}
var wp = rleg.via_waypoints
for(var i=0;i<wp.length;i++)w[i] = [wp[i].lat(),wp[i].lng()]
data.waypoints = w;

waypoints = JSON.stringify(data)


 }
保存航路点

 var map, ren, ser, waypoints;
  function initmap()
{
   map = new google.maps.Map( document.getElementById('map'),
   {'zoom':10,'mapTypeId': google.maps.MapTypeId.ROADMAP, 'center': new 
    google.maps.LatLng(9.848070, 124.218979) })

   ren = new google.maps.DirectionsRenderer( {'draggable':true} );
   ren.setMap(map);
   ser = new google.maps.DirectionsService();


   ren.addListener('directions_changed', function() {
//if you drag the dots it automatically chnage the way ponts
 computeTotalDistance(ren.getDirections());
save_waypoints();

});
  function save_waypoints()
 {
var w=[],wp;
var rleg = ren.directions.routes[0].legs[0];
data.start = {'lat': rleg.start_location.lat(), 'lng':rleg.start_location.lng()}
data.end = {'lat': rleg.end_location.lat(), 'lng':rleg.end_location.lng()}
var wp = rleg.via_waypoints
for(var i=0;i<wp.length;i++)w[i] = [wp[i].lat(),wp[i].lng()]
data.waypoints = w;

waypoints = JSON.stringify(data)


 }
功能保存路径点()
{
var w=[],wp;
var rleg=ren.directions.routes[0]。legs[0];
data.start={'lat':rleg.start_location.lat(),'lng':rleg.start_location.lng()}
data.end={'lat':rleg.end_location.lat(),'lng':rleg.end_location.lng()}
var wp=rleg.via_航路点

对于(var i=0;i)您现有的代码是什么样子的?您如何检索端点?这些是航路点,您应该能够以与检索端点类似的方式检索它们。这些白点是可拖动的,我没有重设它。