Skip to content
Snippets Groups Projects
latlon.php 1.07 KiB
Newer Older
<?php

/* Example script that shows how we can retrieve lat/lng using the yahoo geocoder API
 * 
 * for a basic example, try: http://path/to/UNL_Elgg/scripts/latlon.php?location=Paris,FR
 * 
 * see http://developer.yahoo.com/maps/rest/V1/geocode.html for more information on the Yahoo Geocode API
 */

$street = urlencode($_REQUEST["street"]);
$city = urlencode($_REQUEST["city"]);
$state = urlencode($_REQUEST["state"]);
$country = urlencode($_REQUEST["country"]);
$zip = urlencode($_REQUEST["zip"]);
$location = urlencode($_REQUEST["location"]);


$req = 'http://api.local.yahoo.com/MapsService/V1/geocode?appid=2vqgPxLV34EEubUhiFAvT6wlCTgTooVvFVzi5coJ_.3bZHorwlJ8X8_vHW6e4w--&street='.$street.'&city='.$city.'&state='.$state.'&zip='.$zip.'&country='.$country.'&location='.$location.'&output=php';

$phpserialized = file_get_contents($req);
$phparray = unserialize($phpserialized);
$resultset = $phparray[ResultSet];
$result = $resultset[Result];
$Latitude = $result[Latitude];
$Longitude = $result[Longitude];

echo "({'latitude': '" . $Latitude . "', 'longitude': '" . $Longitude . "'})" ;