Google Maps API V3 Library

Derek Jones edited this page Jul 5, 2012 · 4 revisions
Clone this wiki locally

Category:Contributions | Category:Contributions::Libraries | Category:Contributions::Libraries::Google Maps

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.

The following table is required for the caching functionality of the library.

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
$this->gmap->addMarkerByAddress("42 Beanland Gardens, Wibsey, Bradford,UK","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.

The library can be downloaded from and some comprehensive tutorials can be seen

Thank you for taking the time to use my libraries. As always, please do not hesitate to notify me of any bugs you might find.

The original thread for this can be found here,