Ich bin in einer Situation, die ich Google Maps Autocomplete auf eine bestimmte Stadt Ergebnisse begrenzen muss.Google Maps Autocomplete innerhalb einer Stadt
$(document).ready(function() {
var autocomplete =
new google.maps.places.Autocomplete(
document.getElementById('addr'));
autocomplete.setTypes(['address']);
autocomplete.setComponentRestrictions({'country':'us'});
google.maps.event.addListener(autocomplete, 'place_changed',
function() {
var place = autocomplete.getPlace();
$('#name').text(place.formatted_address);
$('#lat').text(place.geometry.location.lat());
$('#long').text(place.geometry.location.lng());
var service = new google.maps.DistanceMatrixService();
service.getDistanceMatrix({
origins: [new google.maps.LatLng(
place.geometry.location.lat(),
place.geometry.location.lng())],
destinations: ['Raleigh, NC'],
travelMode: google.maps.TravelMode.DRIVING,
unitSystem: google.maps.UnitSystem.IMPERIAL
},
function(response, status) {
if (response.rows[0].elements[0].status == 'ZERO_RESULTS')
$('#distance').text('No dice!');
else
$('#distance').text(response.rows[0].elements[0].distance.text);
});
});
});
Hier ist die Geige, an der ich gearbeitet habe; http://jsfiddle.net/272tx3qy/8/ Ich versuche Eingabefeld Ergebnisse nach Raleigh, NC nur zu begrenzen (nur Straßen und Adressen in Raleigh, NC)
Ist es etwas möglich Google Maps zu erreichen?
Vielen Dank im Voraus für Ihre Zeit.