Welcome Guest, Not a member yet? Register   Sign In
Adding Phoogle to your site
#1

[eluser]floweringmind88[/eluser]
http://www.systemsevendesigns.com/phoogle

Phoogle is an easy way to add google maps to your site. I recently added it to my site and thought I would share the steps for integrating it into CodeIgniter as some asked me about it.

Attached is my modified version so that it works in the libraries directory.

Here is my code for the controller, you will need to get your own apikey from google:

class Stadium extends Controller {

function Welcome()
{
parent::Controller();

}

function index($letter = NULL)
{
error_reporting(E_ALL ^ E_NOTICE);
$dataarr = array();
$dataarr['letter'] = $letter;
$dataarr['baseurl'] = base_url();

$this->load->library('phoogle');
$this->phoogle->setAPIKey("ABQIAAAAFwL0dcVBl8P3ctLK2UPZpRTwyyyNgDoMoQlEr_yhAHAGj7xDVBTQT0wx46ZbzxuY9jzBWGVyV2GySA");

$this->load->view('header');
$this->load->view('stadium',$dataarr);
$this->load->view('footer');
}

}

Finally here is my view:


$this->phoogle->printGoogleJS();

$this->phoogle->addAddress('4000 E Quincy Ave, Englewood, CO 80113', '<b>Kent Denver Stadium</b>');
$this->phoogle->setHeight('476');
$this->phoogle->setWidth('742');
$this->phoogle->showMap();


Hope you find it useful!

Chris
#2

[eluser]BaRzO[/eluser]
thanks Smile
#3

[eluser]codelearn[/eluser]
Thanks again!

FYI: if you are getting this error:

Quote:Fatal error: Cannot use string offset as an array in .... phoogle.php on line 132

Use this fix...

Comment out the following lines of code in phoogle.php:

Code:
$results = $this->xml2array(utf8_encode($addressData));

if (empty($results['kml'][Response]['Placemark']['Point']['coordinates'])){
$pointer = count($this->invalidPoints);
$this->invalidPoints[$pointer]['lat']= $results['kml'][Response]['Placemark']['Point']['coordinates'][0];
$this->invalidPoints[$pointer]['long']= $results['kml'][Response]['Placemark']['Point']['coordinates'][1];
$this->invalidPoints[$pointer]['passedAddress'] = $address;
$this->invalidPoints[$pointer]['htmlMessage'] = $htmlMessage;
}else{
$pointer = count($this->validPoints);
$this->validPoints[$pointer]['lat']= $results['kml'][Response]['Placemark']['Point']['coordinates'];
$this->validPoints[$pointer]['long']= $results['kml'][Response]['Placemark']['Point']['coordinates'];
$this->validPoints[$pointer]['passedAddress'] = $address;
$this->validPoints[$pointer]['htmlMessage'] = $htmlMessage;
}

Replace with this:

Code:
$xml = new SimpleXMLElement(utf8_encode($addressData));
$myCode = (string)$xml->Response->Status->code;
$myCoordinates = (string)$xml->Response->Placemark->Point->coordinates;
$myCoordinatesArray = explode(",", $myCoordinates);
$pointer = count($this->validPoints);
$this->validPoints[$pointer]['long']= $myCoordinatesArray[0];
$this->validPoints[$pointer]['lat']= $myCoordinatesArray[1];
$this->validPoints[$pointer]['passedAddress'] = $address;
$this->validPoints[$pointer]['htmlMessage'] = $htmlMessage;

From http://forums.digitalpoint.com/showthread.php?p=9772549




Theme © iAndrew 2016 - Forum software by © MyBB