CodeIgniter Google Maps Library Using Google Maps API Version 3

CodeIgniter Google Maps Library Using Google Maps API Version 3

Ok, it's finally here. My Code Igniter library using Google Maps API version 3.

Once again, the php code beghind the API isn't actually mine, kudos for that goes to the incredibly talent guys at the php-google-map-api project which can be found here...

I have modified their code slightly and put it in a nice, pretty CodeIgniter wrapper.

I will also be sorting out some example scripts but for now you'll just have to figure it out yourself. This library is compatible with the old style gmap cache database structure from my Google Map API version 2 wrapper. But in case you missed it the SQL to create the database should be...

CREATE TABLE geocode_cache (
    lng double NOT NULL,
    lat double NOT NULL,
    query varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL

Then, all you need to do is copy the GMap.php and JSMin.php files to your code igniter library directory.

A quick tutorial. To generate a very basic map, with a marker generated from an address...



// valid types are hybrid, satellite, terrain, map

// you can also use addMarkerByCoords($long,$lat)
// both marker methods also support $html, $tooltip, $icon_file and $icon_shadow_filename
$this->gmap->addMarkerByAddress("Some Street, Some Town, Some City, Some Country","Marker Title", "Marker Description");

$data['headerjs'] = $this->gmap->getHeaderJS();
$data['headermap'] = $this->gmap->getMapJS();
$data['onload'] = $this->gmap->printOnLoad();
$data['map'] = $this->gmap->printMap();
$data['sidebar'] = $this->gmap->printSidebar();


Your template file should look similar to the following...

        <title>Map Test</title>
        <?php echo $headerjs; ?>
        <?php echo $headermap; ?>
        <?php echo $onload; ?>
        <?php echo $map; ?>
        <?php echo $sidebar; ?>

This library supports almost every feature present in the new google maps api version 3 and as such is incredibly full featured, over time I will be writing tutorials on how to do certain thing using this library so please stay tuned.


Comments Section

Feel free to comment on the post but keep it clean and on topic.

comments powered by Disqus

About Me

Garry Welding Tried my hand at the start-up scene with 650hours and I'm a maintainer of a few of my own open-source projects. For now I'm now taking it easy working a cushy employee lifestyle with Mamas & Papas, one of the largest children's retailers in the UK.