[turba] Add Yahoo! Maps

Mike Bydalek mbydalek at zivix.com
Tue Feb 10 11:08:27 PST 2004


Here is a strictly optional patch that adds an addition Mapping link for a Turba
contact.

Basically those of us in the U.S. are able to use Yahoo! to map, which sometimes
is better than Mapquest.  Personally I find that Yahoo! is better for newer
addresses, and Mapquest is better for more established areas.

I'm not on the Dev list, and this patch is for a file in the framework
(horde/framework/UI/UI/VarRenderer/html.php), but the only place I see use for
it is in Turba, so I'm putting it here.  If I should not do this in the future,
just please let me know!

Thanks,
Mike
-------------- next part --------------
*** html.php	Tue Jan 13 14:27:12 2004
--- html.php.new	Tue Jan 13 14:26:24 2004
***************
*** 659,664 ****
--- 659,665 ----
  
          if (preg_match('/(.*)\n(.*)\s*,\s*(\w+)\.?\s+(\d+|[a-zA-Z]\d[a-zA-Z]\s?\d[a-zA-Z]\d)/', $address, $addressParts)) {
              /* American/Canadian address style. */
+             /* Mapquest generated map */
              $mapurl = 'http://www.mapquest.com/maps/map.adp?size=big&zoom=7';
              if (!empty($addressParts[1])) {
                  $mapurl .= '&address=' . urlencode($addressParts[1]);
***************
*** 675,680 ****
--- 676,697 ----
                      $mapurl .= '&country=CA';
                  }
              }
+ 
+             /* Yahoo! generated map */
+             $mapurl2 = 'http://us.rd.yahoo.com/maps/home/submit_a/*-http://maps.yahoo.com/maps?srchtype=a&getmap=Get+Map&';
+             if (!empty($addressParts[1])) {
+                 $mapurl2 .= '&addr=' . urlencode($addressParts[1]);
+             }
+             if (!empty($addressParts[2]) && !empty($addressParts[3])) {
+                 $mapurl2 .= '&csz=' . urlencode($addressParts[2] . ' ' . $addressParts[3]);
+             }
+             if ((empty($addressParts[2]) || empty($addressParts[3])) && !empty($addressParts[4])) {
+                 $mapurl2 .= '&csz=' . urlencode($addressParts[4]);
+                 if (preg_match('|[a-zA-Z]\d[a-zA-Z]\s?\d[a-zA-Z]\d|', $addressParts[4])) {
+                     $mapurl2 .= '&country=ca';
+                 }
+             }
+ 
          } elseif (preg_match('/(.*)\nD-(\d{5})\s+(.*)/i', $address, $addressParts)) {
              /* German address style. */
              $mapurl = 'http://www.map24.de/map24/index.php3?maptype=RELOAD&country0=de&gcf=1';
***************
*** 691,697 ****
          echo nl2br(@htmlspecialchars($var->getValue($vars, $index), ENT_QUOTES, NLS::getCharset()));
          if (!empty($mapurl)) {
              global $registry;
!             echo Horde::link($mapurl, _("View map"), null, '_blank') . Horde::img('map.gif', _("View map"), 'align="middle"', $registry->getParam('graphics', 'horde')) . '</a>';
          }
      }
  
--- 708,716 ----
          echo nl2br(@htmlspecialchars($var->getValue($vars, $index), ENT_QUOTES, NLS::getCharset()));
          if (!empty($mapurl)) {
              global $registry;
!             echo Horde::link($mapurl, _("Mapquest map"), null, '_blank') . Horde::img('map.gif', _("Mapquest map"), 'align="middle"', $registry->getParam('graphics', 'horde')) . '</a>';
! 		if (isset($mapurl2))
! 			echo Horde::link($mapurl2, _("Yahoo! map"), null, '_blank') . Horde::img('map.gif', _("Yahoo! map"), 'align="middle"', $registry->getParam('graphics', 'horde')) . '</a>';
          }
      }
  


More information about the turba mailing list