Changeset 3151 for trunk/modules

Show
Ignore:
Timestamp:
07/18/2008 12:13:09 PM (5 months ago)
Author:
alexsancho
Message:

Added method to generate statics maps

Location:
trunk/modules/gmaps
Files:
1 added
6 modified

Legend:

Unmodified
Added
Removed
  • trunk/modules/gmaps/controllers/gmaps_demo.php

    r3145 r3151  
    3131 
    3232                View::factory('gmaps/api_demo')->set(array('api_url' => $map->api_uri(), 'map' => $map->render()))->render(TRUE); 
     33        } 
     34         
     35        public function image_map() 
     36        { 
     37                $points = array('-37.814251' => '144.963169', '-33.867139' => '151.207114', '-27.467580' => '153.027892'); 
     38                 
     39                View::factory('gmaps/static_demo')->set(array('simple' => Gmap::static_map(44.9801, -93.2519),'multi' => Gmap::static_map($points)))->render(TRUE); 
    3340        } 
    3441 
  • trunk/modules/gmaps/i18n/en_US/gmaps.php

    r3145 r3151  
    33$lang = array 
    44( 
    5         'invalid_marker'        =>      'Los parametros del marcador son incorrectos', 
     5        'invalid_marker'                =>      'Invalid marker params (latitude: %s, longitude: %s)', 
     6        'invalid_dimensions'    =>      'Invalid map dimensions (width: %s, height: %s)', 
    67); 
  • trunk/modules/gmaps/i18n/es_ES/gmaps.php

    r3145 r3151  
    33$lang = array 
    44( 
    5         'invalid_marker'        =>      'Los parametros del marcador son incorrectos', 
     5        'invalid_marker'                => 'Los parametros del marcador son incorrectos (latitud: %s, longitud: %s)', 
     6        'invalid_dimensions'    => 'Las dimensones del mapa son incorrectas (ancho: %s, alto: %s)', 
    67); 
  • trunk/modules/gmaps/libraries/Gmap.php

    r3146 r3151  
    9393                return $xml; 
    9494        } 
     95         
     96        /** 
     97         * Returns an image map 
     98         * 
     99         * @param   mixed  $lat latitude or an array of marker points 
     100         * @param       float  $lon longitude 
     101         * @param       integer $zoom zoom level (1-16) 
     102         * @param       string $type map type (roadmap or mobile) 
     103         * @param       integer $width map width 
     104         * @param       integer $height map height 
     105         * @return  string 
     106         */ 
     107        public static function static_map($lat = 0, $lon = 0, $zoom = 6, $type = 'roadmap', $width = 300, $height = 300) 
     108        { 
     109                $api_url = 'http://maps.google.com/staticmap?key='.Config::item('gmaps.api_key'); 
     110 
     111                $types = array('roadmap', 'mobile'); 
     112 
     113                $width = min(640, (int) $width); 
     114        $height = min(640, (int) $height); 
     115 
     116                if ($width <= 0 OR $height <= 0) 
     117                        throw new Kohana_Exception('gmaps.invalid_dimensions', $width, $height); 
     118 
     119                $api_url = $api_url.'&amp;size='.$width.'x'.$height; 
     120                 
     121                if (in_array($type, $types)) 
     122            $api_url = $api_url.'&amp;maptype='.$type; 
     123                 
     124                if (is_array($lat)) 
     125                { 
     126                        foreach ($lat as $key => $value) 
     127                                $markers[] = $key.','.$value; 
     128 
     129                        $api_url = $api_url.'&amp;markers='.implode('|', $markers); 
     130                } 
     131                else 
     132                { 
     133                        $api_url = $api_url.'&amp;center='.$lat.','.$lon.'&amp;zoom='.$zoom; 
     134                } 
     135 
     136        return $api_url; 
     137        } 
    95138 
    96139        // Map settings 
  • trunk/modules/gmaps/views/gmaps/javascript.php

    r3145 r3151  
    1 google.load("maps", "2.x", {"language" : "<?php echo substr(Config::item('locale.language'), 0, 2);?>"}); 
     1google.load("maps", "2.x", {"language" : "<?php echo substr(Config::item('locale.language.0'), 0, 2);?>"}); 
    22function initialize() { 
    33    if (GBrowserIsCompatible()) { 
  • trunk/modules/gmaps/views/gmaps/jquery_javascript.php

    r3145 r3151  
    1 google.load("maps", "2.x", {"language" : "<?php echo substr(Config::item('locale.language'), 0, 2);?>"}); 
     1google.load("maps", "2.x", {"language" : "<?php echo substr(Config::item('locale.language.0'), 0, 2);?>"}); 
    22 
    33$(function()