Perform automatic reverse geocoding on marker drag end-event
authorAlexander Ebert <ebert@woltlab.com>
Tue, 4 Feb 2014 11:56:52 +0000 (12:56 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Tue, 4 Feb 2014 11:56:52 +0000 (12:56 +0100)
wcfsetup/install/files/js/WCF.Location.js

index c8ca727bfd59521acdc865a101ab9dc425937951..0eef61e9ad27fe91a3e5675d6a4de36ae225f185 100644 (file)
@@ -500,6 +500,8 @@ WCF.Location.GoogleMaps.LocationInput = Class.extend({
                                }
                        }, this));
                }
+               
+               this._marker.addListener('dragend', $.proxy(this._updateLocation, this));
        },
        
        /**
@@ -520,6 +522,17 @@ WCF.Location.GoogleMaps.LocationInput = Class.extend({
                return this._marker;
        },
        
+       /**
+        * Updates location on marker position change.
+        */
+       _updateLocation: function() {
+               WCF.Location.GoogleMaps.Util.reverseGeocoding($.proxy(function(result) {
+                       if (result !== null) {
+                               $(this._searchInput).val(result);
+                       }
+               }, this), this._marker);
+       },
+       
        /**
         * Sets the marker based on an entered location.
         *