-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgoodToHave1.js
30 lines (28 loc) · 1.11 KB
/
goodToHave1.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
function initAutocomplete() {
// add Autocomplete suport
var autocomplete = new google.maps.places.Autocomplete(
(document.getElementById('addressInput')));
autocomplete.bindTo('bounds', map);
// add event to handle autocomplete
autocomplete.addListener('place_changed', function() {
infoWindow.close();
currentPositionMarker.setVisible(false);
var place = autocomplete.getPlace();
if (!place.geometry) {
// User entered the name of a Place that was not suggested and
// pressed the Enter key, or the Place Details request failed.
window.alert("No details available for input: '" + place.name + "'");
return;
}
// If the place has a geometry, then present it on a map.
if (place.geometry.viewport) {
map.fitBounds(place.geometry.viewport);
} else {
map.setCenter(place.geometry.location);
map.setZoom(6);
}
showCurrentPosition(place.geometry.location);
currentPositionMarker.setVisible(true);
displayNearestLocations();
});
}