Skip to content
solidsnake edited this page Feb 12, 2011 · 12 revisions

Welcome to the Kohana-Google-Maps-Module wiki!

Here you can read about the Google Maps module. I hope you'll find the examples here helpfull!

Creating a Google-Map in your action

So, you want to display a Google-Map on your Homepage or in your Kohana application. You can just echo an instance of the Gmap class... Simple, is it?

public function action_index()
{
   $this->template->gmap = Gmap::factory();
} // function

Inside your view:

<h2>Look, a Google Map!</h2>
<?php echo $gmap; ?>

Creating more advanced Google-Maps

So, you want to add a few markers? That's no problem - Keep in mind that the "marker-id" (first parameter) must always be unique. If not, your previous marker will be overwritten.

public function action_index()
{
   $map = Gmap::factory();
   $this->template->bind('gmap', $map);

   $map->add_marker('A brand new marker', 51.123, 6.987)
      ->add_marker('Another marker', 52.13, 6.87);
      ->add_marker('A third marker', 52.34, 6.23);
} // function

But simply displaying markers is a bit boring - So we'll add some Content and maybe a custom icon?

public function action_index()
{
   $map = Gmap::factory();
   $this->template->bind('gmap', $map);
   
   $marker_options = array(
      'content' => '<p>Simply stuff some <b>HTML</b> here!</p>',
      'icon'    => Kohana::find_file('path/to/image', 'image');
   );
   
   $map->add_marker('A brand new marker', 51.123, 6.987, $marker_options)
      ->add_marker('Another marker', 52.13, 6.87);
} // function