Some tweaks/fixes to the event map:
authorMichael J. Rubinsky <mrubinsk@horde.org>
Sat, 26 Jun 2010 16:10:05 +0000 (12:10 -0400)
committerMichael J. Rubinsky <mrubinsk@horde.org>
Sat, 26 Jun 2010 16:10:05 +0000 (12:10 -0400)
    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
kronolith/js/kronolith.js
kronolith/templates/index/edit.inc

index 4f3bd5a..fe8081f 100644 (file)
@@ -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) {
index a70461f..3a181c8 100644 (file)
@@ -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);
     },
index 50178c5..b959530 100644 (file)
@@ -52,7 +52,7 @@
   <input type="text" name="location" id="kronolithEventLocation" size="25" />
   <?php if ($GLOBALS['conf']['maps']['driver']): ?>
   <span id="kronolithEventMapLink" style="display:none">
-    <span class="kronolithSeparator">|</span> <span><a href="#" class="kronolithEventGeo"><?php echo _("Find in Maps") ?></a></span>
+    <span class="kronolithSeparator">|</span> <span><a href="#" class="kronolithEventGeo"><?php echo _("Find in Maps") ?></a></span>&nbsp;<span id="kronolithEventGeo_loading_img" style="display:none;"><?php echo Horde::img('loading.gif', _("Loading...")) ?></span>
   </span>
   <?php endif; ?>
 </div>