diff --git a/web/components/Main.js b/web/components/Main.js
index 064beb5..33bebe5 100644
--- a/web/components/Main.js
+++ b/web/components/Main.js
@@ -1,6 +1,7 @@
import React from 'react';
import Filters from './Filters';
import Listings from './Listings';
+import { pacSelectFirst } from '../helpers/googleMaps';
class Main extends React.Component {
constructor(props) {
@@ -28,13 +29,29 @@ class Main extends React.Component {
control.style = "top: 200px;"
var input = document.getElementById('gmaps-places-input');
+
+ pacSelectFirst(input);
var options = {
componentRestrictions: {country: "BA"}
};
var searchBox = new google.maps.places.Autocomplete(input, options);
- searchBox.addListener('places_changed', function() {
- console.log('search changed', searchBox.getPlaces());
+
+ searchBox.addListener('place_changed', function() {
+ var place = searchBox.getPlace();
+
+ if (!place.geometry) {
+ return;
+ }
+
+ if (place.geometry.viewport) {
+ map.fitBounds(place.geometry.viewport);
+
+ } else {
+ map.setCenter(place.geometry.location);
+ map.setZoom(18);
+ }
});
+
control.addEventListener('click', (e) => {
this.setState({
mapClicked: true
diff --git a/web/dist/index.html b/web/dist/index.html
index fb9a240..251c1c5 100644
--- a/web/dist/index.html
+++ b/web/dist/index.html
@@ -14,6 +14,10 @@
+