Fixes map center then refreshing it
authorMatthias Schmidt <gravatronics@live.com>
Fri, 14 Feb 2014 16:49:35 +0000 (17:49 +0100)
committerMatthias Schmidt <gravatronics@live.com>
Fri, 14 Feb 2014 16:49:35 +0000 (17:49 +0100)
wcfsetup/install/files/js/WCF.Location.js

index ae77ac00fbff7f40ffb948be2c5858d71625050b..0910ace6eb7c831613becffc16ace604b6c5d0ad 100644 (file)
@@ -276,7 +276,13 @@ WCF.Location.GoogleMaps.Map = Class.extend({
         * Refreshes the map.
         */
        refresh: function() {
+               // save current center since resize does not preserve it
+               var $center = this._map.getCenter();
+               
                google.maps.event.trigger(this._map, 'resize');
+               
+               // set center to old value again
+               this._map.setCenter($center);
        },
        
        /**
@@ -714,7 +720,10 @@ WCF.Location.GoogleMaps.Util = {
         * @param       google.maps.Marker      marker
         */
        focusMarker: function(marker) {
+               console.log(marker.getPosition().lat(), marker.getPosition().lng());
+               console.log(marker.getMap().getCenter().lat(), marker.getMap().getCenter().lng());
                marker.getMap().setCenter(marker.getPosition());
+               console.log(marker.getMap().getCenter().lat(), marker.getMap().getCenter().lng());
        },
        
        /**