WebSite-PHP Framework PHP
Multi language
Simple Ajax mode
No HTML, no JavaScript
URL rewriting
Mail sending
Sitemap - RSS - Web service
Download WebSite-PHP FrameWork now
 


Loading
 


Tutorial Geolocation

Tutorials

>

Tutorial Geolocation



Tutorial 1 : Latitude/Longitude Geolocation
File: /pages/tutorials/geolocation/geolocation-01.php

<?php
class Geolocation01 extends Page {
    public function 
InitializeComponent() {
        
parent::$PAGE_TITLE "Tutorial : Latitude/Longitude Geolocation";

        
$geo = new GeoLocalisation();

        
// You need to create a key on the page:
        // http://ipinfodb.com/register.php
        
$geo->setKey("IPINFODB_KEY");

        
$geo->askUserToSharePosition();
        
$geo->setRemoteIP();
        
$geo->getGeoLocation();

        if (
$geo->getLatitude() != "" && $geo->getLongitude() != "") {
            
$this->render = new Label("You have been locate:<br/>" .
                
"Latitude = " round($geo->getLatitude(), 2) . "<br/>" .
                
"Longitude = " round($geo->getLongitude()));
        } else {
            
$this->render = new Label("No Geolocation");
        }
    }
}
?>


Tutorial 2 : City and country Geolocation
File: /pages/tutorials/geolocation/geolocation-02.php

<?php
class Geolocation02 extends Page {
    public function 
InitializeComponent() {
        
parent::$PAGE_TITLE "Tutorial : City and country Geolocation";

        
$geo = new GeoLocalisation();

        
// You need to create a key on the page:
        // http://ipinfodb.com/register.php
        
$geo->setKey("IPINFODB_KEY");

        
$geo->askUserToSharePosition();
        
$geo->setRemoteIP();
        
$geo->getGeoLocation();

        if (
$geo->getCity() != "" && $geo->getCountry() != "") {
            
$this->render = new Label("You have been detected in ".
                
$geo->getCity()." ".$geo->getCountry());
        } else if (
$geo->getLatitude() != "" && $geo->getLongitude() != "") {
            
$this->render = new Label("No city Geolocation, but you have been locate:<br/>" .
                
"Latitude = " round($geo->getLatitude(), 2) . "<br/>" .
                
"Longitude = " round($geo->getLongitude()));
        } else {
            
$this->render = new Label("No city Geolocation");
        }
    }
}
?>



Share

 


Copyright © 2009-2024 WebSite-PHP Framework PHP
Home Documentation Download Quick start Tutorials Wiki Issue Tracker