From 49cd84baf74ac6b2425fcca44b691704f71deb79 Mon Sep 17 00:00:00 2001 From: "Michael J. Rubinsky" Date: Sat, 26 Jun 2010 12:10:05 -0400 Subject: [PATCH] Some tweaks/fixes to the event map: use a spinner while waiting for geocoder to return use initializeMap() here, not ensureMap() Make sure that we don't display the map until we have the information needed to do so. Acutally honor the delayed option --- horde/js/hordemap/horde.js | 2 +- kronolith/js/kronolith.js | 15 +++++++++++---- kronolith/templates/index/edit.inc | 2 +- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/horde/js/hordemap/horde.js b/horde/js/hordemap/horde.js index 4f3bd5a2b..fe8081f2f 100644 --- a/horde/js/hordemap/horde.js +++ b/horde/js/hordemap/horde.js @@ -65,7 +65,7 @@ HordeMap.Map.Horde = Class.create({ // Set the language to use OpenLayers.Lang.setCode(HordeMap.conf.language); - this.map = new OpenLayers.Map(this.opts.elt, options); + this.map = new OpenLayers.Map((this.opts.delayed ? null : this.opts.elt), options); // Create the vector layer for markers if requested. if (HordeMap.conf.useMarkerLayer) { diff --git a/kronolith/js/kronolith.js b/kronolith/js/kronolith.js index a70461f61..3a181c8dc 100644 --- a/kronolith/js/kronolith.js +++ b/kronolith/js/kronolith.js @@ -3718,8 +3718,8 @@ KronolithCore = { switch (trigger.id) { case 'kronolithEventLocation': - if (kc == Event.KEY_RETURN) { - this.ensureMap(true); + if (kc == Event.KEY_RETURN && $F('kronolithEventLocation')) { + this.initializeMap(true); this.geocode($F('kronolithEventLocation')); e.stop(); return; @@ -4259,7 +4259,7 @@ KronolithCore = { break; case 'kronolithEventGeo': - this.ensureMap(true); + this.initializeMap(true); this.geocode($F('kronolithEventLocation')); e.stop(); break; @@ -5508,12 +5508,15 @@ KronolithCore = { // Map initializeMap: function(ignoreLL) { + if (this.mapInitialized) { + return; + } var layers = []; if (Kronolith.conf.maps.providers) { Kronolith.conf.maps.providers.each(function(l) { var p = new HordeMap[l](); - $H(p.getLayers()).values().each(function(e) { layers.push(e); }); + $H(p.getLayers()).values().each(function(e) {layers.push(e);}); }); } @@ -5586,6 +5589,7 @@ KronolithCore = { onGeocodeError: function(r) { + $('kronolithEventGeo_loading_img').toggle(); KronolithCore.showNotifications([ { type: 'horde.error', message: Kronolith.text.geocode_error + ' ' + r} ]); }, @@ -5594,12 +5598,14 @@ KronolithCore = { */ onGeocode: function(r) { + $('kronolithEventGeo_loading_img').toggle(); r = r.shift(); if (r.precision) { zoom = r.precision * 2; } else { zoom = null; } + this.ensureMap(true); this.placeMapMarker({ lat: r.lat, lon: r.lon }, true, zoom); }, @@ -5607,6 +5613,7 @@ KronolithCore = { if (!a) { return; } + $('kronolithEventGeo_loading_img').toggle(); var gc = new HordeMap.Geocoder[Kronolith.conf.maps.geocoder](this.map.map, 'kronolithEventMap'); gc.geocode(a, this.onGeocode.bind(this), this.onGeocodeError); }, diff --git a/kronolith/templates/index/edit.inc b/kronolith/templates/index/edit.inc index 50178c5d4..b95953002 100644 --- a/kronolith/templates/index/edit.inc +++ b/kronolith/templates/index/edit.inc @@ -52,7 +52,7 @@ -- 2.11.0