我正在做一个项目,我想知道如果20公里之间的2个标记之间的距离如何计算?我想知道如何计算距离。 根据我的代码,我只能显示地图和标记。
谢谢!
var TheFamilyPractice = new google.maps.Marker({
position: { lat: 1.332419, lng: 103.867687},
map: map
});
var contentTheFamilyPractice = '<div id="content">' +
'<div id="siteNotice">' +
'</div>' +
'<h1 id="firstHeading" class="firstHeading">The Family Practice</h1>' +
'<div id="bodyContent">' +
'<p><b>Clinic Name: </b>The Family Practice </p> ' +
'<p><b>Tel: </b>62816906 </p>' +
'<p><b>Address: </b>148 Potong Pasir Ave 1, Singapore 350148</p>' +
'</div>' +
'</div>';
var infowindow01 = new google.maps.InfoWindow({
content: contentTheFamilyPractice
});
TheFamilyPractice.addListener('click', function () {
infowindow01.open(map, TheFamilyPractice);
});
var Bankok = new google.maps.Marker({
position: { lat: 1.332432, lng: 103.868321 },
map: map
});
var contentBankok = '<div id="content">' +
'<div id="siteNotice">' +
'</div>' +
'<h1 id="firstHeading" class="firstHeading">Ban Kok Clinic & Surgery</h1>' +
'<div id="bodyContent">' +
'<p><b>Clinic Name: </b>Ban Kok Clinic & Surgery </p> ' +
'<p><b>Tel: </b>62869955 </p>' +
'<p><b>Address: </b>146 Potong Pasir Ave 1, Singapore 350146</p>' +
'</div>' +
'</div>';
var infowindow02 = new google.maps.InfoWindow({
content: contentBankok
});
Bankok.addListener('click', function () {
infowindow02.open(map, Bankok);
});
答案 0 :(得分:0)
如果您想要最短的距离,则称为Great-circle distance,您可以检查this answer。
如果您需要行驶距离(如交通地图所示),请选中Google Maps Distance Matrix API。