गूगल दिशा API त्रुटि (NOT_FOUND)

वोट
1

मैं एक सवाल जावास्क्रिप्ट के साथ गूगल एपीआई दिशा के विषय में, मैं पहली बार के लिए यह उपयोग कर रहा हूँ है।

मैं एक कारपूलिंग वेबसाइट developping कर रहा हूँ। मैं दो स्थानों है कि मैं एक इनपुट Google स्वतः पूर्ण का उपयोग करने से मिला जो दिशा बनाना चाहते हैं। मैं अपने दो LatLng निर्देशांक है कि मैं एक स्ट्रिंग के रूप में पारित कर दिया मूल और गंतव्य क्षेत्रों में डाल करने के लिए प्राप्त करने के लिए प्रबंधित किया है। हालांकि यह गूँज दिशा-निर्देश NOT_FOUND की वजह से अनुरोध विफल। किसी को भी मेरी मदद कर सकते हैं? धन्यवाद :)

एचटीएमएल फील्ड्स

<input type=text name=departure  id=autocomplete_address>
<input type=button id=departure_check value=Add this departure>

<input type=text name=arrival  id=autocomplete_address2>
<input type=button id=arrival_check value=Add this destination >

जावास्क्रिप्ट:

var latorigine;
var latdestination;

function initMap() {
    var geocoder = new google.maps.Geocoder;
    var directionsService = new google.maps.DirectionsService;
    var directionsDisplay = new google.maps.DirectionsRenderer;
    map = new google.maps.Map(document.getElementById('searchmap'), {
        center: {lat: 50.437616, lng: 2.809546},
        zoom: 15
    });

    directionsDisplay.setMap(map);       

    //AUTOCOMPLETE
    var departure_input =(document.getElementById('autocomplete_address'));
    var arrival_input =(document.getElementById('autocomplete_address2'));
    var options = {
        types: ['address'],
        componentRestrictions: {country: fr}
    }
    var departure_autocomplete = new 
    google.maps.places.Autocomplete(departure_input,options);
    var arrival_autocomplete = new 
    google.maps.places.Autocomplete(arrival_input,options);

    document.getElementById('departure_check').addEventListener('click', function(latorigine) {
        var departure_place = departure_autocomplete.getPlace();
        latorigine = '  '+ departure_place.geometry.location.lat() + ,  +  departure_place.geometry.location.lng()+ '  ';
        console.log(latorigine);
    });

    document.getElementById('arrival_check').addEventListener('click', function(latdestination) {
        var arrival_place = arrival_autocomplete.getPlace();
        latdestination = '  ' +arrival_place.geometry.location.lat() + ,  + arrival_place.geometry.location.lng()+ '  ';
        console.log(latdestination);
    });

}
//END INITMAP


function trajectdirection(directionsService, directionsDisplay,latorigine, latdestination) {
    directionsService.route({
        origin: latorigine.toString(),
        destination: latdestination.toString(),
        travelMode: 'DRIVING'
        }, function(response, status) {
            if (status === 'OK') {
                directionsDisplay.setDirections(response);
            } else {
                window.alert('Directions request failed due to ' + status);
            }
        }
    });
}
23/03/2018 को 18:23
का स्रोत उपयोगकर्ता
अन्य भाषाओं में...                            


1 जवाब

गूगल दिशा API त्रुटि (NOT_FOUND)

वोट
1

मैं एक सवाल जावास्क्रिप्ट के साथ गूगल एपीआई दिशा के विषय में, मैं पहली बार के लिए यह उपयोग कर रहा हूँ है।

मैं एक कारपूलिंग वेबसाइट developping कर रहा हूँ। मैं दो स्थानों है कि मैं एक इनपुट Google स्वतः पूर्ण का उपयोग करने से मिला जो दिशा बनाना चाहते हैं। मैं अपने दो LatLng निर्देशांक है कि मैं एक स्ट्रिंग के रूप में पारित कर दिया मूल और गंतव्य क्षेत्रों में डाल करने के लिए प्राप्त करने के लिए प्रबंधित किया है। हालांकि यह गूँज "दिशा-निर्देश NOT_FOUND की वजह से अनुरोध विफल"। किसी को भी मेरी मदद कर सकते हैं? धन्यवाद :)

एचटीएमएल फील्ड्स

<input type="text" name="departure"  id="autocomplete_address">
<input type="button" id="departure_check" value="Add this departure">

<input type="text" name="arrival"  id="autocomplete_address2">
<input type="button" id="arrival_check" value="Add this destination" >

जावास्क्रिप्ट:

var latorigine;
var latdestination;

function initMap() {
    var geocoder = new google.maps.Geocoder;
    var directionsService = new google.maps.DirectionsService;
    var directionsDisplay = new google.maps.DirectionsRenderer;
    map = new google.maps.Map(document.getElementById('searchmap'), {
        center: {lat: 50.437616, lng: 2.809546},
        zoom: 15
    });

    directionsDisplay.setMap(map);       

    //AUTOCOMPLETE
    var departure_input =(document.getElementById('autocomplete_address'));
    var arrival_input =(document.getElementById('autocomplete_address2'));
    var options = {
        types: ['address'],
        componentRestrictions: {country: "fr"}
    }
    var departure_autocomplete = new 
    google.maps.places.Autocomplete(departure_input,options);
    var arrival_autocomplete = new 
    google.maps.places.Autocomplete(arrival_input,options);

    document.getElementById('departure_check').addEventListener('click', function(latorigine) {
        var departure_place = departure_autocomplete.getPlace();
        latorigine = ' " '+ departure_place.geometry.location.lat() + ", " +  departure_place.geometry.location.lng()+ ' " ';
        console.log(latorigine);
    });

    document.getElementById('arrival_check').addEventListener('click', function(latdestination) {
        var arrival_place = arrival_autocomplete.getPlace();
        latdestination = ' " ' +arrival_place.geometry.location.lat() + ", " + arrival_place.geometry.location.lng()+ ' " ';
        console.log(latdestination);
    });

}
//END INITMAP


function trajectdirection(directionsService, directionsDisplay,latorigine, latdestination) {
    directionsService.route({
        origin: latorigine.toString(),
        destination: latdestination.toString(),
        travelMode: 'DRIVING'
        }, function(response, status) {
            if (status === 'OK') {
                directionsDisplay.setDirections(response);
            } else {
                window.alert('Directions request failed due to ' + status);
            }
        }
    });
}
23/03/2018 को 18:23
का स्रोत उपयोगकर्ता

Cookies help us deliver our services. By using our services, you agree to our use of cookies. Learn more