Google static maps helper for CakePHP
This is a simple CakePHP helper to create static maps using google API. For more information on the api and how to get an api key consult the Google Static Maps API.
1. Add helper file to your app
Download the file google_static_map.php (http://karlmendes.com/static/google_static_map/google_static_map.zip) and add it to the folder “YOUR_APP/views/helper”.
2. Add your google api key to the core.php
Add the following line to core.php to define the google api key:
Download code
<?php
Configure::write('GoogleMapsAPIKey', '---KEY---');
?>
3. Reference it on your controller
Refer the helper on the controller together with the other helpers you may be using.
Download code
<?php
var $helpers = array('Html','Form','Javascript','GoogleStaticMap');
?>
4. Use it in your view
To use ti just call the function map using the desired parameters, this is a simple example:
Download code
<?php
$params = array(
'markers'=>array(array(-4,40),array(-20,80)),
'size'=>array(400,300),
'zoom'=>12
);
echo $googleStaticMap->map($params);
?>
For those willing to take a quick look at the helper code go to the next page, if you got what you want already stop right here.
Comments
Comment
1 hi