|
|
@@ -692,6 +692,12 @@ app.controller('mainController', function($scope, $detection, $http, $mdSidenav,
|
|
|
$scope.mapType = 'Satellite';
|
|
|
$scope.view = {};
|
|
|
$scope.isShown = {};
|
|
|
+
|
|
|
+
|
|
|
+ if($location.search().q) {
|
|
|
+ $scope.address = $location.search().q;
|
|
|
+ $scope.suggestLocation($location.search().q);
|
|
|
+ }
|
|
|
};
|
|
|
|
|
|
var isDate = function(value) {
|
|
|
@@ -1212,23 +1218,34 @@ app.controller('mainController', function($scope, $detection, $http, $mdSidenav,
|
|
|
var i = 0, j = 0;
|
|
|
$scope.suggestLocation = function(val) {
|
|
|
|
|
|
- $scope.suggestionsReady = false;
|
|
|
- i++;
|
|
|
- return $http.get(suggestURL, {
|
|
|
- params: {
|
|
|
- text: val
|
|
|
- }
|
|
|
- }).then(function(response) {
|
|
|
+ try {
|
|
|
+ var coordinates = JSON.parse(val);
|
|
|
|
|
|
- if(val === $scope.address) { // Very important to debounce queries
|
|
|
- $scope.suggestionsReady = response.data.suggestions.length !== 0;
|
|
|
- $scope.suggestions = _.cloneDeep(response.data.suggestions);
|
|
|
+ if(coordinates && coordinates.x) {
|
|
|
+ $scope.geoCode = coordinates;
|
|
|
+ addCurrentMarker();
|
|
|
}
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ catch(e) {
|
|
|
+ $scope.suggestionsReady = false;
|
|
|
+ i++;
|
|
|
+ return $http.get(suggestURL, {
|
|
|
+ params: {
|
|
|
+ text: val
|
|
|
+ }
|
|
|
+ }).then(function(response) {
|
|
|
+
|
|
|
+ if(val === $scope.address) { // Very important to debounce queries
|
|
|
+ $scope.suggestionsReady = response.data.suggestions.length !== 0;
|
|
|
+ $scope.suggestions = _.cloneDeep(response.data.suggestions);
|
|
|
+ }
|
|
|
|
|
|
- return response.data.suggestions.map(function(item){
|
|
|
- return item.text;
|
|
|
+ return response.data.suggestions.map(function(item){
|
|
|
+ return item.text;
|
|
|
+ });
|
|
|
});
|
|
|
- });
|
|
|
+ }
|
|
|
};
|
|
|
|
|
|
$scope.toggleResultPane = function() {
|