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.
protected/extensionsSee the following code example:
$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
<div id="gmap"></div> <script src="http://maps.google.com/maps?file=api&v=2.x&key=..." type="text/javascript"></script> <script src="/assets/f71433f3/gmap.js" type="text/javascript"></script> <script language="javascript"> var GMAP_DEF_LAT = 54.863963; var GMAP_DEF_LNG = 1.73584; var GMAP_DEF_ZOOM = 7; var m = new GMap("gmap", "1600+Amphitheatre+Pky,+Mountain+View,+CA", "some company"); m.show(); </script>
As you see, there is an object - m, it can be used in any JS scripts. It has the following methods:
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.
Total 4 comments
this extension is working fine.its very very helpful.
is there is any way to plot the gmap inside a fancy box? i tried but failed.
-Sirin
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".
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.
Leave a comment
Please login to leave your comment.