Changeset 3181 for trunk/modules

Show
Ignore:
Timestamp:
07/21/2008 12:01:21 PM (4 months ago)
Author:
Shadowhand
Message:

More updates to Gmap:

  • api_uri renamed to api_url (duh)
  • address_to_xml now uses api_url
Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/modules/gmaps/libraries/Gmap.php

    r3180 r3181  
    1919         * @return  string 
    2020         */ 
    21          public static function api_uri($component = 'jsapi', $parameters = NULL) 
     21         public static function api_url($component = 'jsapi', $parameters = NULL) 
    2222         { 
    23                 if (empty($parameters['key'])) 
    24                 { 
    25                         // Set the API key 
    26                         $parameters['key'] = Kohana::config('gmaps.api_key'); 
    27                 } 
    28  
    2923                if (empty($parameters['ie'])) 
    3024                { 
     
    3933                } 
    4034 
    41                 return html::specialchars('http://www.google.com/'.$component.'?'.http_build_query($parameters), FALSE); 
     35                if (empty($parameters['key'])) 
     36                { 
     37                        // Set the API key last 
     38                        $parameters['key'] = Kohana::config('gmaps.api_key'); 
     39                } 
     40 
     41                return 'http://www.google.com/'.$component.'?'.http_build_query($parameters); 
    4242         } 
    4343 
     
    8787                else 
    8888                { 
     89                        // Set the XML URL 
     90                        $xml = Gmap::api_url('maps/geo', array('output' => 'xml', 'q' => rawurlencode($address))); 
     91 
    8992                        // Disable error reporting while fetching the feed 
    9093                        $ER = error_reporting(~E_NOTICE); 
    9194 
    9295                        // Load the XML 
    93                         $xml = simplexml_load_file 
    94                         ( 
    95                                 'http://maps.google.com/maps/geo?'. 
    96                                 '&output=xml'. 
    97                                 '&oe=utf-8'. 
    98                                 '&key='.Kohana::config('gmaps.api_key'). // Get the API key 
    99                                 '&q='.rawurlencode($address) // Send the address URL encoded 
    100                         ); 
     96                        $xml = simplexml_load_file($xml); 
    10197 
    10298                        if (is_object($xml) AND ($xml instanceof SimpleXMLElement) AND (int) $xml->Response->Status->code === 200) 
     
    163159                } 
    164160 
    165         return Gmap::api_uri('staticmap', $parameters); 
     161        return Gmap::api_url('staticmap', $parameters); 
    166162        } 
    167163