nearby.org.uk logo · Coordinate Convertor
· Interactive Feature Map
· Location Searches
· Google Earth & Maps
· UK Placenames
· GB Paper Maps
· API / Downloads
· Blog
· Support Nearby
   

(Google) GeoWeb Search API 2 KMLalpha!

Feedback on my blog

Query (q)
LatLong (sll)
What (mrt)
(documentation)

Powered by the Google AJAX Search Local API (aka GeoSearch??), pear-JSON and KML writing class

(Relevent) Source:

<?
    
require_once 'JSON.php';

    
$json = new Services_JSON();

    
$_GET = array('v' => "1.0")+$_GET;
    
$_GET['key'] = "abcdef";
    
    
$url "http://ajax.googleapis.com/ajax/services/search/local?".http_build_query($_GET); 
    
$output file_get_contents($url);
    
    
$value $json->decode($output);
    
    require_once 
'kmlfile.class.php';
    
$kml = new kmlFile();
    
$kml->atom true;
    
    
$kml->filename "GeoWeb-Example.kml";
    
$folder $kml->addChild('Folder');
    
$folder->setItem('name',"Results");
    
    if (
count($value->responseData->results)) {
        foreach (
$value->responseData->results as $id => $obj) {
            
$point = new kmlPoint($obj->lat,$obj->lng);

            
$placemark = new kmlPlacemark($id+1000,$obj->title,$point);
            
$placemark->useCredit('',$obj->url);
            if (!empty(
$obj->content))
                
$placemark->setItemCDATA('description',$obj->content);
            
            
$folder->addChild($placemark);
        }
    }
    
    if (!isset(
$_GET['debug'])) {
        
//if havent sent headers could just do this:
        
$kml->outputKML();
        
//which would output the correct http headers
    
} else {
        print 
"<textarea rows=35 style=width:100%>";
        print 
$kml->returnKML();
        print 
"</textarea>";
    }
?>
1
- Home - Blog - Location Links - Location Search - Search Gateway - Gazetteer - Location Search Index - API -
/nearby.org.uk © 2005-2010 [disclaimer] BackToTop