2 yön A ve B arasındaki güzergah yolunu çizmek için Google Yönlendirme API'sını kullanıyorum. Bunu yapabilirim. Şimdi, C ve A yollarının yolunda bir yere C düştüğünü kontrol etme şartım var.Yön api: Bir yolun 2 yol arasındaki bir rotada düşüp düşmediğini kontrol edin
İşte kodumdan oluşturduğum yol yolunun anlık görüntüsü. Bu konuda nasıl
function initialize() {
var input = document.getElementById('searchTextFieldSource');
var input1 = document.getElementById('searchTextFieldDestination');
var autocomplete = new google.maps.places.Autocomplete(input);
var autocomplete1 = new google.maps.places.Autocomplete(input1);
google.maps.event.addListener(autocomplete1, 'place_changed', function() {
var place = autocomplete.getPlace();
document.getElementById('city1').value = place.name;
var place1Lat = place.geometry.location.lat();
var place1Lng = place.geometry.location.lng();
document.getElementById('cityLat1').value = place1Lat;
document.getElementById('cityLng1').value = place1Lng;
var obj = new Object();
obj.city =place.name;
obj.latitude = place.geometry.location.lat();
obj.longitude = place.geometry.location.lng();
locations.push(obj);
var place2 = autocomplete1.getPlace();
document.getElementById('city2').value = place2.name;
var place2Lat = place2.geometry.location.lat();
var place2Lng = place2.geometry.location.lng();
document.getElementById('cityLat2').value = place2Lat;
document.getElementById('cityLng2').value = place2Lng;
var obj = new Object();
obj.city = place2.name;
obj.latitude = place2.geometry.location.lat();
obj.longitude = place2.geometry.location.lng();
locations.push(obj);
directionsDisplay = new google.maps.DirectionsRenderer();
var startPlace = new google.maps.LatLng(place1Lat, place1Lng);
var mapOptions = {
zoom:7,
center: startPlace
}
var map = new google.maps.Map(document.getElementById('map'), mapOptions);
directionsDisplay.setMap(map);
//refreshMap(locations);
var start = $("#city1").val();
var end = $("#city2").val();
var request = {
origin:start,
destination:end,
travelMode: google.maps.TravelMode.DRIVING
};
directionsService.route(request, function(response, status) {
if (status == google.maps.DirectionsStatus.OK) {
directionsDisplay.setDirections(response);
}
});
});
}
gidebilir
: Burada
gelen kodu?
ben kodunuzda "yer C" görmüyorum. Bir seçenek rotanız için makul sınırları belirlemek için RouteBoxer kullanmaktır. Eğer ara nokta bu sınırlar tarafından içeriyorsa, bu yeterince iyi olabilir, aksi halde daha fazla test gerçekleştirebilirsiniz (rota poligonundan uzaklaşmak gibi. [Bu benzer soruya bakın] (http://stackoverflow.com/questions/20476917/find -o-yer-yalan-arasında-kaynak-ve-hedef-google-haritalar-ve-yerler-api) (hangi bir cevap yok) – geocodezip
muhtemel [Nasıl Gidilir Yerler (örneğin Benzin İstasyonları) Google Haritalar API'sı Menşei ve Hedef Arasında Yolculuk Boyunca] (http://stackoverflow.com/questions/17283826/how-to-to-get-places-eg-gas-stations-along-route-between-origin-and- destinati) – geocodezip
[Güzergahınız boyunca (0,25 mil boyunca) benzin istasyonları] (http://www.geocodezip.com/v3_SO_RouteBoxerPlaces_configurable.html?dist=0.25&to=Electronics%20City&from=BTM%20Layout&type=gas_station&name=&submit=) – geocodezip