Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * PLOTING MULTIPLE LOCATIONS OF THE SAME BUSINESS
- *
- * This extension was originally created to display the location(s) or a particular business. Therefore,
- * the extension, as is, expects certain attributes to be passed to it.
- *
- * The required attributes include:
- * @var string $address1
- * @var string $address2
- * @var string $city
- * @var string $state
- * @var string $zip
- * @var string $bphone
- *
- * These names of these attributes can be changed in GMapMultiplot.php Lines 142-150
- *
- * In this scenario the business have a One-To-Many relationship to locations:
- */
- // CONTROLLER EXAMPLE
- public function actionViewmap()
- {
- // Business ID is passed through $_GET parameter
- $businessId = $_GET['id'];
- // Retrive business infomation
- $businessInfo = business::model()->findByPk($businessId);
- // Retrieve business locations
- $locations = locations::model()->findAll('id=:id', array(':id'=>$businessId));
- $this->render('viewmap', array('businessInfo'=>$businessInfo, 'locations'=>$locations))
- }
- // VIEW EXAMPLE
- $this->widget('application.extensions.gmapmultiplot.GMapMultiplot', array(
- 'id' => 'gmap',//id of the <div> container created
- 'label' => $businessInfo->tradename, //text written in the text bubble
- 'address' => $locations, // We feed the array of 'location' objects to the extension
- ));
- /**
- * PLOTING LOCATIONS OF MULTIPLE BUSINESS 0N ONE MAP
- *
- * Alternatively, locations could be a table of businesses with single locations.
- * For example you may have the following model schema:
- *
- * @var string $businessName
- * @var string $address1
- * @var string $address2
- * @var string $city
- * @var string $state
- * @var string $zip
- * @var string $bphone
- *
- * If this is the case, you can simply not feed a label to the extension and make a minor change within
- * GmapMultiplot.php
- */
- // CONTROLLER EXAMPLE
- public function actionViewmap()
- {
- // Retrive business infomation
- $businesses = business::model()->findAll();
- $this->render('viewmap', array('businesses'=>$bussinesses))
- }
- // VIEW EXAMPLE
- $this->widget('application.extensions.gmapmultiplot.GMapMultiplot', array(
- 'id' => 'gmap',//id of the <div> container created
- 'address' => $locations, // We feed the array of 'location' objects to the extension
- ));
- // MAKE CHANGE TO GMapMultiPlot.php LINE: 150
- // BEFORE CHANGE
- $ret .= 'geocode("'.$address.'", "'.$item->bphone.'", "'.$this->label.'", '.$only.');';
- // AFTER CHANGE
- $ret .= 'geocode("'.$address.'", "'.$item->bphone.'", "'.$item->businessname.'", '.$only.');';
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement