<?php
if (isset($_GET['code'])) { die(highlight_file(__FILE__1)); }

$street=$_POST["street"];
$city=$_POST["city"];
$state=$_POST["state"];
$country=$_POST["country"];
echo 
'
<form method="post" action="'
.$_SERVER['PHP_SELF'].'">
<table>
<tr><td>Street (may include housenumber)</td><td><input type="text" size="30" name="street"></td></tr>
<tr><td>City and/or postal code</td><td><input type="text" size="30" name="city"></td></tr>
<tr><td>State (Can be left blank)</td><td><input type="text" size="4" maxlength="2" name="state"></td></tr>
<tr><td>Country</td><td><input type="text" size="30" name="country"></td></tr>
</table>
<input type="submit" value="submit" name="submit"><br />
</form>'
;

if (isset(
$_POST['submit'])) {
    
// Get the url to retrieve the json code
    
$address=$street.','.$city.','.$country;
    
$address=urlencode($address);
    
$base_url='http://maps.google.com/maps/geo?output=json&oe=utf-8&q='.$address;

    
// Initializing curl
    
$ch curl_init$base_url );
    
// Configuring curl options
    
$options = array(
    
CURLOPT_RETURNTRANSFER => true,
    );
    
// Setting curl options
    
curl_setopt_array$ch$options );
    
// Getting results
    
$string =  curl_exec($ch); // Getting jSON result string

    // Getting the coordinated and showing the link
    
$json=json_decode($string);
    
$lon=$json->Placemark[0]->Point->coordinates[0];
    
$lat=$json->Placemark[0]->Point->coordinates[1];
    
$wigle="http://www.wigle.net/gps/gps/Map/onlinemap2/?maplat=".$lat."&maplon=".$lon."&mapzoom=16";
    echo 
'<a href="'.$wigle.'" target="wigle">'.$wigle.'</a>';

}
?>