How do I install and use YiiGeo?

Created by Brian Armstrong on on 2009-11-13
use howto install
Last updated by:
Brian Armstrong on on 2009-11-13


Extract the contents of the archive to 'protected/extensions/'. Rename the default directory (eg: 'yiigeo-1.0.1/') to whatever you want the component named in your application. This directory will be referred to as '<extdir>' in this tutorial.


Register for an API Key with a support GeoCoder provider
Google registration:
Yahoo registration:

There are two ways to use the Yii GeoCoder Extension. The first is as an imported standalone object, the second is as an application component.


$geocode = new GeoCoder;
$geocode->setApiKey('<your API key>'); // As of 1.0.2
$geocode->setDriver('<your driver>'); // 'google' or 'yahoo'
$result = $geocode->query('Las Vegas, NV 89103');

*Application Component*

STEP 1: Update your application config

'components' => array(
    'geocoder' => array(
       'class' => 'application.extensions.<extdir>.GeoCoder',
       'api_key' => '<your API key>',
       'api_driver' => '<your driver>', // 'google' or 'yahoo'

STEP 2: Using the component

$result = Yii::app()->geocoder->query('Las Vegas, NV 89103');