0
看着https://developers.google.com/maps/documentation/javascript/examples/directions-simple我仍然不明白我如何让用户能够选择位置通过拖放标记或通过输入地址,然后通过单击按钮显示选定的位置。允许用户通过标记或输入地址选择一个位置
有什么建议吗?
看着https://developers.google.com/maps/documentation/javascript/examples/directions-simple我仍然不明白我如何让用户能够选择位置通过拖放标记或通过输入地址,然后通过单击按钮显示选定的位置。允许用户通过标记或输入地址选择一个位置
有什么建议吗?
您可以处理地图点击事件,并获得纬度LNG并创建一个标记,并显示在地图上。
google.maps.event.addListener(map, 'click', function(event){
alert("Latitude: "+event.latLng.lat()+" "+", longitude: "+event.latLng.lng());
var myLatlng = new google.maps.LatLng(event.latLng.lat(),event.latLng.lng());
var marker = new google.maps.Marker({
position: myLatlng,
map: map,
title: 'Hello World!'
});
});
使用myLatLng计算距离。 此外,如果要在用户将鼠标悬停在地图上时显示标记,请处理地图的鼠标悬停事件。 有关活动列表,请参阅此处:https://developers.google.com/maps/documentation/javascript/events
选择一个位置?或选择驾驶方向的开始或结束点?你想做什么不清楚。 – MrUpsidown