How it works:
- Accepts an array of ActiveRecord Objects
- Loops through the array, feeding the address and window data to gmapmultiplot.js
- gmapmultiplot.js takes the address and sends it to maps.google.com, which returns a geocoded Latitude and Longitude
- Mapmarker is created with the Lat/Lng and a window(bubble) is created with name, address and phone number
- For multiple address, the map zooms out and centers so that all MapMarkers are visible.
While the class expects certain attributes, this can easily be edited to fit your needs.
You can view the extension in action by viewing a business profile on Rebates Hampton Roads
- Yii 1.1 or above (only tested in 1.1)
- Extract the release file under
This extension was originally written to plot a businesses 1 or more locations, but can be easily modified for different scenarios.
If you run into any problems, please feel free to send me an email and I will correct any errors asap. You can find my email address within the class comments.
See the following code example:
$this->widget('application.extensions.gmapmultiplot.GMapMultiplot', array( 'id' => 'gmap',//id of the <div> container created 'label' => $label, //Title for bubble. Used if you are plotting multiple locations of same business 'address' => $array, //Array of AR objects ));
If passing the extension a single record, simply wrap the record in an array. This prevents an error while the extension attempts to loop through the records:
$this->widget('application.extensions.gmapmultiplot.GMapMultiplot', array( 'id' => 'gmap',//id of the <div> container created 'label' => $label, //Title for bubble. Used if you are plotting multiple locations of same business 'address' => array($array), //Array of AR objects ));
For more code examples, please visit the following link Code Sample on Pastebin.com
Change Log ¶
September 29, 2010 ¶
- Initial release.
October 3, 2010 ¶
- Fixed issue with address format being sent to Google Maps. Map would come up blank if attribute "address2" was left empty.