angular.module('googleMaps', [])
    
    .controller('googleMapsSettingsCtrl', ['$scope', '$http', '$rootScope', 'ngDialog', function($scope, $http, $rootScope, ngDialog){
        $scope.google = {};
        $scope.markerSrc = 'core/img/image.svg';
        
        // Get settings
        $http.get('modules/Google-Maps/app/settings.php?settings=true')
        .success(function(data){
            $scope.google.style = angular.fromJson(data)['style'];
            $scope.google.marker = angular.fromJson(data)['marker'];
            $scope.markerSrc = $scope.google.marker;
        });
        
        // Add a custom marker
        $scope.uploadMarker = function(){
            ngDialog.open({ template: 'core/html/modal.html', data: angular.toJson({ id: 'google-marker' }) });
        };
        
        // Watch for edits to the marker
        $scope.$on('choseFile', function(event, data){
            if(data.id === 'google-marker'){
                $scope.google.marker = data.src;
                $scope.markerSrc = $scope.google.marker;
            }
        });
        
        // Save custom style
        $scope.save = function(){
            $http.post('modules/Google-Maps/app/settings.php', { 
                marker: $scope.google.marker,
                style: $scope.google.style
            })
            .success(function(data){
                $rootScope.$broadcast('notify', { message: 'Settings updated' });
            }).error(function(data){
                $rootScope.$broadcast('notify', { message: 'Error' });
            });
        };
    }])
    
    .directive('googleMap', ['$rootScope', '$http', function($rootScope, $http){
        return {
            template: '<div id="map-canvas"></div>',
            link: function(scope, elm, attrs){

                // Get custom styles
                $http.get('modules/Google-Maps/app/settings.php?settings=true')
                .success(function(data){
                    if(data){
                        var googleMapStyle = angular.fromJson(angular.fromJson(data)['style']);
                        if(angular.fromJson(data)['marker'])
                            var marker = angular.fromJson(data)['marker'];
                    }
                    // Google Map from Latitude and Longitude
                    if(attrs.latitude && attrs.longitude){
                        var latitude = attrs.latitude;
                        var longitude = attrs.longitude;
                        var location = new google.maps.LatLng(latitude, longitude);
                        
                        var mapOptions = {
                            center: location,
                            zoom: 12,
                            mapTypeId: google.maps.MapTypeId.ROADMAP,
                            styles: googleMapStyle
                        };
                        
                        var map = new google.maps.Map(document.getElementById("map-canvas"), mapOptions);
                        var driverMarker = new google.maps.Marker({
                                position: location,
                                map: map,
                                icon: marker
                            });
                    } else {
                        var geocoder = new google.maps.Geocoder();
                        var geocoderRequest = { address: attrs.googleMap };
                        geocoder.geocode(geocoderRequest, function(results, status){
                            if(results){
                                if(results[0].geometry.location.k){
                                    var latitude = results[0].geometry.location.k;
                                    var longitude = results[0].geometry.location.D;
                                    
                                    // Google Map
                                    var location = new google.maps.LatLng(latitude, longitude);

                                    var mapOptions = {
                                        center: location,
                                        zoom: 12,
                                        mapTypeId: google.maps.MapTypeId.ROADMAP,
                                        styles: googleMapStyle
                                    };

                                    var map = new google.maps.Map(document.getElementById("map-canvas"), mapOptions);
                                    var driverMarker = new google.maps.Marker({
                                        position: location,
                                        map: map,
                                        icon: marker
                                    });
                                } else // Address wasn't found by google
                                    $rootScope.$broadcast('notify', { message: 'Address not found' });
                            }
                        });
                    }
                });
            }
        };
    }]);
@@ -26,21 +26,17 @@
 s', %5B%5D)%0A
-    
 %0A
+
     .con
@@ -239,25 +239,17 @@
 e.svg';%0A
-        
 %0A
+
         
@@ -566,33 +566,25 @@
         %7D);%0A
-        
 %0A
+
         // A
@@ -767,25 +767,17 @@
      %7D;%0A
-        
 %0A
+
         
@@ -1041,25 +1041,17 @@
     %7D);%0A
-        
 %0A
+
         
@@ -1169,17 +1169,16 @@
 .php', %7B
- 
 %0A       
@@ -1536,21 +1536,17 @@
     %7D%5D)%0A
-    
 %0A
+
     .dir
@@ -1735,17 +1735,16 @@
 attrs)%7B%0A
-%0A
         
@@ -2498,33 +2498,9 @@
 e);%0A
-                        
 %0A
+
     
@@ -2774,33 +2774,9 @@
  %7D;%0A
-                        
 %0A
+
     
@@ -3481,13 +3481,157 @@
 tion
-.k
 )%7B%0A
+                                    for (var key in results%5B0%5D.geometry.location) %7B%0A                                        if(!latitude)%0A        
     
@@ -3709,12 +3709,83 @@
 tion
-.k
+%5Bkey%5D
 ;%0A
+                                        else if(!longitude)%0A        
     
@@ -3864,10 +3864,13 @@
 tion
-.D
+%5Bkey%5D
 ;%0A  
@@ -3903,16 +3903,18 @@
         
+%7D%0A
 %0A       
@@ -5107,12 +5107,12 @@
  %7D;%0A
-
     %7D%5D);
@@ -5111,8 +5111,9 @@
     %7D%5D);
+%0A

Fix google's stupid updates...