'How to add options for radius? (Google Places API)
Here is my code for obtaining addresses using Google Places API.
It returns matching addresses too far afield. I need to restrict it by radius how would I add my starting location to this code?
<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?
key=XXXXXXX&libraries=places"></script>
<script type="text/javascript">
var options = {
componentRestrictions: { country: "uk" }
};
google.maps.event.addDomListener(window, 'load', function () {
var places = new
google.maps.places.Autocomplete(document.getElementById('<%=txtLocation.ClientID %>'),
options);
google.maps.event.addListener(places, 'place_changed', function () {
var place = places.getPlace();
var latitude = place.geometry.location.lat();
var longitude = place.geometry.location.lng();
hf1.Set("FullDestination", place.formatted_address);
hf1.Set("Latitude", latitude);
hf1.Set("Longitude", longitude);
document.getElementById('<%=txtLocation.ClientID %>').value =
place.formatted_address;
});
});
</script>
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
