Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions app/css/app.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
body.zipcode-false {
body.location-false {
background-image : url('../img/google_maps_hello_world.jpg');
}

Expand All @@ -14,7 +14,7 @@ body.zipcode-false {
background-color: #fff;
}

.search-zipcode {
.search-location {
margin-top: 10px;
}

Expand Down Expand Up @@ -69,4 +69,10 @@ body.zipcode-false {
.table tr.active td {
background-color: transparent !important;
}
.modal{
z-index: -99;
}
.modal-backdrop{
z-index: -100;
}

10 changes: 6 additions & 4 deletions app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@
<link href="css/normalize.css" rel="stylesheet" type="text/css" />
<link href="css/bootstrap.min.css" rel="stylesheet" type="text/css" />
<link href="css/bootstrap-responsive.min.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" href="../bower_components/angular-google-places-autocomplete/src/autocomplete.css">
<link rel="stylesheet" href="css/app.css"/>
</head>

<body ng-controller="MainCtrl" class="zipcode-{{applied()}}">
<body ng-controller="MainCtrl" class="location-{{applied()}}">
<!-- View placeholder -->
<div ng-view></div>

Expand All @@ -27,21 +28,22 @@
<script src="../bower_components/angular-route/angular-route.js"></script>
<script src="lib/ui-bootstrap.min.js"></script>
<script src="lib/ui-bootstrap-tpls.min.js"></script>
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&libraries=places&key=AIzaSyCOUo69jud8ZVGG4sa7ijZ3y6XL_XNmkXg"></script>
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&libraries=places&key=AIzaSyAAGgC2aY58wU72naGqF2oQHAa6iNDU_zk"></script>
<script src="../bower_components/angular-google-places-autocomplete/src/autocomplete.js"></script>
<script src="js/app.js"></script>
<script src="js/services.js"></script>
<script src="js/controllers.js"></script>
<script src="js/filters.js"></script>
<script src="js/directives.js"></script>
<script src="js/utils.js"></script>
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
/*(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');

ga('create', 'UA-10379928-16', 'lookaround.herokuapp.com');
ga('send', 'pageview');
ga('send', 'pageview');*/
</script>
</body>
</html>
9 changes: 5 additions & 4 deletions app/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,18 @@ var lookAroundApp = angular.module("lookAroundApp", [
"lookAroundApp.filters",
"lookAroundApp.directives",
"ui.bootstrap",
"ngRoute"
"ngRoute",
"google.places"
]);

lookAroundApp.config(['$routeProvider', function ($routeProvider) {
$routeProvider
.when("/",
{
controller: "ZipCodeFrmCtrl",
templateUrl: "partials/zipcode.html"
controller: "locFrmCtrl",
templateUrl: "partials/location.html"
})
.when("/search/:zipcode/:place",
.when("/search/:loc/:place",
{
controller: "SearchCtrl",
templateUrl: "partials/search.html"
Expand Down
37 changes: 19 additions & 18 deletions app/js/controllers.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
angular.module("lookAroundApp.controllers", [ ])

/**
* [ZipCodeFrmCtrl]
* Responsible for updating the route whenever zipcode is changed
* [locFrmCtrl]
* Responsible for updating the route whenever location is changed
* appears in the first page, and the header
*
* - default placeurl in route parameters is 'atm'
Expand All @@ -16,11 +16,11 @@ angular.module("lookAroundApp.controllers", [ ])
* @param {[type]} $routeParams
* @return {[type]}
*/
.controller("ZipCodeFrmCtrl", ['$scope', '$location', '$routeParams',
.controller("locFrmCtrl", ['$scope', '$location', '$routeParams',
function ($scope, $location, $routeParams) {
var placeurl = $routeParams.place || "atm";
$scope.sendZip = function (zipcode) {
$location.path("/search/" + zipcode + "/" + placeurl);
$scope.sendLoc = function (loc) {
$location.path("/search/" + loc.formatted_address + "/" + placeurl);
};

// Currently displaying Result near ...
Expand All @@ -41,8 +41,8 @@ angular.module("lookAroundApp.controllers", [ ])
* [SearchCtrl]
* This controller is responsible for the main search in the view
*
* - It first gets the zip code from the route params and check for the place data
* - it then gets the map latitude and longitude from the zipcode ( using Google GeoCoder )
* - It first gets the location from the route params and check for the place data
* - it then gets the map latitude and longitude from the location ( using Google GeoCoder )
* - using the places Api, it will fetch the data for the given place type ( 'atm|bar|bus-station' ..etc)
* - and renders the map using this data
*
Expand All @@ -57,11 +57,11 @@ angular.module("lookAroundApp.controllers", [ ])
.controller("SearchCtrl",
['$scope', '$routeParams', '$location', 'googleMap', '$http', '$filter',
function ($scope, $routeParams, $location, googleMap, $http, $filter) {
$scope.zipCode = $routeParams.zipcode;
$scope.loc = $routeParams.loc;
$scope.place = $routeParams.place;

/* redirect to the home page if there's no zipcode */
if (!$scope.zipCode) {
console.log($scope.loc);
/* redirect to the home page if there's no location */
if (!$scope.loc) {
$location.path("/");
}

Expand All @@ -79,7 +79,7 @@ angular.module("lookAroundApp.controllers", [ ])
* @return {string}
*/
$scope.getUrl = function (placeurl) {
return "#/search/" + $scope.zipCode + placeurl;
return "#/search/" + $scope.loc + placeurl;
};

/*
Expand Down Expand Up @@ -112,16 +112,17 @@ angular.module("lookAroundApp.controllers", [ ])

/*
start the Geocoding to get the latitude and longitude from the
zipcode proviced. This lat/long will be served to the places api to fetch the places details
location proviced. This lat/long will be served to the places api to fetch the places details
*/
googleMap.getGeoCoder().geocode({
address: $scope.zipCode
address: $scope.loc
}, function (results, status) {
var lat = results[ 0 ].geometry.location.lat(),
lng = results[ 0 ].geometry.location.lng();

/* $scope.$apply is required as this function will be executed inside the GeoCoder context */
$scope.$apply(function () {
console.log(results[ 0 ]);
$scope.searchplace = results[ 0 ] && results[ 0 ].formatted_address;
});

Expand Down Expand Up @@ -220,15 +221,15 @@ angular.module("lookAroundApp.controllers", [ ])
*/
.controller("MainCtrl", ['$scope', '$routeParams', '$location', '$window',
function ($scope, $routeParams, $location, $window) {
// checks if the url contains any valid zipcode
// checks if the url contains any valid location
$scope.applied = function () {
return !!$routeParams.zipcode;
return !!$routeParams.loc;
};
// some Google analytics
$scope.$on("$viewContentLoaded", function (event) {
$window.ga("send", "pageview", {
/*$window.ga("send", "pageview", {
"page": $location.path()
});
});*/
});
}
])
Expand Down
24 changes: 24 additions & 0 deletions app/partials/location.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<div id="enterZipCodeView">
<div class="modal">
<div class="modal-header">
<h3>Enter your Place or City or Zip code</h3>
</div>
<div class="modal-body">
<form class="form-inline" name="locFrm" novalidate>
<input type="text" name="loc"
g-places-autocomplete
force-selection="true"
placeholder="Enter your city or zip code"
required
ng-model="loc">
<input type="submit" class="btn btn-primary"
value="GO" ng-disabled="locFrm.$invalid"
ng-click="sendLoc(loc)">
</form>
</div>
<div class="modal-footer">
<p class="text-left text-success" ng-show="!locFrm.$invalid" ng-cloak>Place or City is valid</p>
</div>
</div>
<div class="modal-backdrop light fade in"></div>
</div>
15 changes: 9 additions & 6 deletions app/partials/search.html
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
<div class="container-fluid">
<div class="row-fluid navbar navbar-inverse">
<div class="navbar-inner" ng-controller="ZipCodeFrmCtrl">
<div class="container-fluid search-zipcode ">
<form class="form-inline pull-left" name="zipCodeFrm" novalidate>
<div class="navbar-inner" ng-controller="locFrmCtrl">
<div class="container-fluid search-location ">
<form class="form-inline pull-left" name="locFrm" novalidate>
<!-- <div class="control-group"> -->
<label class="search-label" for="zip">Look around near :
<input type="text" name="zip" placeholder="Enter your zip code" required ng-pattern="/^\d{5,6}$/" ng-model="zipCode" class="input-medium search-query">
<label class="search-label" for="loc">Look around near :
<input type="text" id="loc" g-places-autocomplete
name="loc" placeholder="Enter your zip code or City"
ng-model="loc" class="input-medium search-query">
</label>
<button type="submit" class="btn btn-primary" value="GO" ng-disabled="zipCodeFrm.$invalid" ng-click="sendZip(zipCode)">GO</button>
<button type="submit" class="btn btn-primary" value="GO"
ng-disabled="locFrm.$invalid" ng-click="sendLoc(loc)">GO</button>
<!-- </div> -->
</form>
<div class="pull-right" ng-controller="AboutDialogCtrl" style="margin-right: 70px">
Expand Down
17 changes: 0 additions & 17 deletions app/partials/zipcode.html

This file was deleted.

3 changes: 2 additions & 1 deletion bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"homepage": "https://github.com/shidhincr/LookAround",
"dependencies": {
"angular": "~1.4.8",
"angular-route": "~1.4.8"
"angular-route": "~1.4.8",
"angular-google-places-autocomplete": "^0.2.7"
},
"authors": [
"Sahil Bhatia <sahil@joshsoftware.com>"
Expand Down