Notice
  • Restricted Access
Harshawardhan Natu

Harshawardhan Natu

Fetching Latitude and Longitude from address or parts of address using BIng Maps Geocoding API -

/**
* Fetch Latitude and Longitude for a given pincode using bing maps geocoding API.
*
* @author Harshawardhan Natu
*
* @param string $pin
*
* @return array $latlong
*/
function getLatLong($pin)
{
$latlong = array();

$requestURL = " http://dev.virtualearth.net/REST/v1/Locations?countryRegion=IN&postalCode=".$pin."&key=Ak886YHtbrDyPF7-4eG3WngHEowFGkMWcIEGPgeZCpphK-WWNKv8atTt7IS9GdyI";

$response = file_get_contents($requestURL);
$output = json_decode($response);

$latlong['latitude'] = $output->resourceSets[0]->resources[0]->point->coordinates[0];
$latlong['latitude'] = number_format($latlong['latitude'], 6, '.', '');
$latlong['longitude'] = $output->resourceSets[0]->resources[0]->point->coordinates[1];
$latlong['longitude'] = number_format($latlong['longitude'], 6, '.', '');

return $latlong;
}

Documention URL - https://docs.microsoft.com/en-us/bingmaps/rest-services/locations/find-a-location-by-address

Upcoming Events

No events found.

Who's Online

7 users online