Esempio n. 1
0
 /**
  * Returns an image map
  *
  * @param mixed $lat latitude or an array of marker points
  * @param float $lon longitude
  * @param integer $zoom zoom level (1-19)
  * @param string $type map type (roadmap or mobile)
  * @param integer $width map width
  * @param integer $height map height
  * @return string
  */
 public static function static_map($lat = 0, $lon = 0, $zoom = 6, $type = NULL, $width = 300, $height = 300)
 {
     // Valid map types
     $types = array('roadmap', 'mobile');
     // Maximum width and height are 640px
     $width = min(640, abs($width));
     $height = min(640, abs($height));
     $parameters['size'] = $width . 'x' . $height;
     // Minimum zoom = 0, maximum zoom = 19
     $parameters['zoom'] = max(0, min(19, abs($zoom)));
     if (in_array($type, $types)) {
         // Set map type
         $parameters['maptype'] = $type;
     }
     if (is_array($lat)) {
         foreach ($lat as $_lat => $_lon) {
             $parameters['markers'][] = $_lat . ',' . $_lon;
         }
         $parameters['markers'] = implode('|', $parameters['markers']);
     } else {
         $parameters['center'] = $lat . ',' . $lon;
     }
     return Gmap::api_url('staticmap', $parameters);
 }
Esempio n. 2
0
 public function jquery()
 {
     $map = new Gmap('map');
     $map->center(0, 35, 16)->controls('large');
     View::factory('gmaps/jquery')->set(array('api_url' => Gmap::api_url(), 'map' => $map->render('gmaps/jquery_javascript')))->render(TRUE);
 }