Changeset 2158 for trunk/modules/gmaps/controllers/google_map.php
- Timestamp:
- 02/23/2008 01:41:41 PM (9 months ago)
- Files:
-
- 1 modified
-
trunk/modules/gmaps/controllers/google_map.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/modules/gmaps/controllers/google_map.php
r2154 r2158 1 1 <?php defined('SYSPATH') or die('No direct script access.'); 2 2 /** 3 * Gmaps module demo controller. 4 * 5 * $Id$ 6 * 7 * @package Gmaps 8 * @author Woody Gilk 9 * @copyright (c) 2007-2008 Kohana Team 10 * @license http://kohanaphp.com/license.html 11 */ 3 12 class Google_Map_Controller extends Controller { 4 13 5 14 public function index() 6 15 { 7 View::factory('gmaps/api_demo')->render(TRUE); 16 $this->db = Database::instance('mysql://root:r00tdb@localhost/azmap'); 17 18 // Create a new Gmap 19 $map = new Gmap('map'); 20 21 // Set the map center point 22 $map->center(0, 0, 1)->controls('large'); 23 24 // Add a new marker 25 $map->add_marker(44.9801, -93.2519, '<strong>Minneapolis, MN</strong><p>Hello world!</p>'); 26 27 View::factory('gmaps/api_demo')->set('map', $map->render())->render(TRUE); 8 28 } 9 29 10 public function markers()30 public function azmap() 11 31 { 12 $map = new Gmap; 13 14 $markers[] = Gmap::marker('South Africa'); 15 $markers[] = Gmap::marker('8601 Edinbrook Crossing, 55443'); 32 $this->db = Database::instance('mysql://root:r00tdb@localhost/azmap'); 16 33 17 foreach ($markers as $marker) 34 // Create a new Gmap 35 $map = new Gmap('map', array 36 ( 37 'ScrollWheelZoom' => TRUE, 38 )); 39 40 // Set the map center point 41 $map->center(0, 35, 2)->controls('large'); 42 43 // Set marker locations 44 foreach (ORM::factory('location')->find_all() as $location) 18 45 { 19 echo html::anchor 20 ( 21 'http://maps.google.com/?&q=' 22 .rawurlencode($marker->address).'&ll=' 23 .rawurlencode($marker->lon.','.$marker->lat) 24 .'&z=10&iwloc=addr' 25 ).'<br/>'; 46 // Add a new marker 47 $map->add_marker($location->lat, $location->lon, 48 // Get the info window HTML 49 View::factory('gmaps/info_window')->bind('location', $location)->render()); 26 50 } 27 51 52 header('Content-type: text/javascript'); 53 echo $map->render(); 28 54 } 29 55 30 public function georss()56 public function jquery() 31 57 { 32 View::factory('gmaps/ rss_demo')->render(TRUE);58 View::factory('gmaps/jquery')->render(TRUE); 33 59 } 34 60 35 public function feed()61 public function xml() 36 62 { 37 header('Content-Type: text/xml; charset=utf-8'); 38 require Kohana::find_file('views', 'gmaps/rss', FALSE, 'xml'); 63 $this->db = Database::instance('mysql://root:r00tdb@localhost/azmap'); 64 65 // Get all locations 66 $locations = ORM::factory('location')->find_all(); 67 68 // Create the XML container 69 $xml = new SimpleXMLElement('<gmap></gmap>'); 70 71 foreach ($locations as $location) 72 { 73 // Create a new mark 74 $node = $xml->addChild('marker'); 75 76 // Set the latitutde and longitude 77 $node->addAttribute('lon', $location->lon); 78 $node->addAttribute('lat', $location->lat); 79 80 $node->html = View::factory('gmaps/xml')->bind('location', $location)->render(); 81 82 foreach ($location->as_array() as $key => $val) 83 { 84 // Skip the ID 85 if ($key === 'id') continue; 86 87 // Add the data to the XML 88 $node->$key = $val; 89 } 90 } 91 92 header('Content-Type: text/xml'); 93 echo $xml->asXML(); 39 94 } 40 95
