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.
Add label for directions and more
How can I get to put a link with label Directions so that people when click on it they will pass in the address and get to full Google map to get directions. Also any way to pass in more labels I would like to pass in the star ratings too. Am using it for business rating.
Thanks. Please.
Doesn't work with null or empty address
If you set an address that can't be found, such as "XXXXX", a map without a marker centered at the default latitude and longitude is shown, as expected.
However, if you don't set the address at all or set it to '', then no map is shown at all. I would expect it to show up at the default lat and lng exactly the same as when the address can't be found.
The hackaround if you want to show the default map is to explicitly set a dummy address like "XXXXXXXXXX".
is there is any way to plot the gmap inside a fancy box?
is there is any way to plot the gmap inside a fancy box?
i tried but failed.
-Sirin
hello
this extension is working fine.its very very helpful.
If you have any questions, please ask in the forum instead.
Signup or Login in order to comment.