geocode

postado em 6 de jun de 2012 16:30 por Silvio Garbes
geocode(
 
Double latitude,
 
Double longitude,
 
Integer maxResults[optional, default 1]: maximum number of results)

Returns a list of addresses for the given latitude and longitude.

Returns:
  A list of addresses
.

Exemplo

<?php
// @author: Anton Perkin (anton.perkinAT_NOSP_AMgmail.com)
// http://groups.google.com/group/php-for-android/browse_thread/thread/bab685d3ae202152

include("Android.php");
$droid = new Android();

//creates alert
$droid->dialogCreateAlert();

$result = array();

//gets coordinates
$latitude = $droid->getInput("Location", "Latitude: ");
$longitude= $droid->getInput("Location", "Longitude: ");

//gets the location info
$locations = $droid->geocode($latitude['result'], $longitude['result']);

//parses location info
foreach ($locations['result'] as $location)
{
  $location = get_object_vars($location);

  //sets location items
  foreach ($location as $key => $value)
  {
    $result[] = ucfirst(str_replace('_', ' ', $key)).': '.$value;
  }
}
$droid->dialogSetItems($result);

//displays the box
$droid->dialogShow();

?>
Comments