我正在使用此代码来查找位于200 km半径范围内的最小最大纬度(即距离特定点的道路距离)。但它返回的结果是径向距离,而不是道路距离。任何人都可以帮我摆脱这个问题吗?
<?php
$lat = 28.6663433;
$long = 77.067959;
$radius = 200; // Kilometers
$earth_radius = 6371;
$lat_max = $lat + rad2deg($radius / $earth_radius);
$long_max = $long + rad2deg($radius / $earth_radius / cos(deg2rad($lat)));
$lat_min = $lat - rad2deg($radius / $earth_radius);
$long_min = $long - rad2deg($radius / $earth_radius / cos(deg2rad($lat)));
echo 'max lat: '.$lat_max.'<br/>';
echo 'max long: '.$long_max.'<br/>';
echo 'min lat: '.$lat_min.'<br/>';
echo 'min lat: '.$long_min.'<br/>';
?>
答案 0 :(得分:0)
对于ROAD距离,您可以查看https://developers.google.com/maps/documentation/javascript/distancematrix#distance_matrix_requests,有不同的示例:
var origin1 = new google.maps.LatLng(55.930385, -3.118425);
var origin2 = "Greenwich, England";
var destinationA = "Stockholm, Sweden";
var destinationB = new google.maps.LatLng(50.087692, 14.421150);
var service = new google.maps.DistanceMatrixService();
service.getDistanceMatrix(
{
origins: [origin1, origin2],
destinations: [destinationA, destinationB],
travelMode: google.maps.TravelMode.DRIVING,
transitOptions: TransitOptions,
drivingOptions: DrivingOptions,
unitSystem: UnitSystem,
avoidHighways: Boolean,
avoidTolls: Boolean,
}, callback);
function callback(response, status) {
// See Parsing the Results for
// the basics of a callback function.
}
您需要一个API密钥。