gmap Simple google map implementation

  1. Documentation
  2. Change Log

This extension allows you to use google maps on your page. You just put address and widget does the rest. It also has an extensive client side, so you can later interact with the map using fairly simple API.

Resources

Documentation

Requirements
  • Yii 1.0 or above
Installation
  • Extract the release file under protected/extensions
Usage

See the following code example:

<?php
$this->widget('application.extensions.gmap.GMap', array(
	'id' => 'gmap',//id of the <div> container created
	'key' => '...', //goole API key, should be obtained for each site,it's free
	'label' => 'some company', //text written in the text bubble
	'address' => array(
		'address' => '1600 Amphitheatre Pky',//address of the place
		'city' => 'Mountain View', //city
		'state' => 'CA'//state
		//'country' => 'USA' - country
		//'zip' => 'XXXXX' - zip or postal code
		)
));
?>

This generates nearly the following ~~~ [html]

~~~

As you see, there is an object - m, it can be used in any JS scripts. It has the following methods:

  • Constructor - accepts ID of the div container, address and label. Constructs an object, doesn't affect any markup.
  • setAddress - accepts string with address in the form of ADDRESS, CITY[, STATE][,COUNTRY][,ZIP]. Alternative way - specify an object {address:'',city:'',state:'',country:'',zip:''}. Address AND City AND (State OR Country) are required.
  • setLabel - sets the label. If label is empty, address will be show in the text bubble.
  • show - renders the map, sets the marker.

If you use widget without specifying an address, you will get the same, but will have to m.setAddress and call m.show() manually. This may be used for showing user his place when hitting Refresh button.

Change Log

January 18, 2009
  • Initial release.
2 0
12 followers
3 067 downloads
Yii Version: 1.1
License: BSD-2-Clause
Category: Others
Tags:
Developed by: KJedi
Created on: Jan 18, 2009
Last updated: 15 years ago

Downloads

show all