Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to convert postcode to Geolocation (latitude & longitude) using google maps api?

I just want to get latitude & longitude using the post code with Google maps API.

I am using PHP for development.

How can I do this?

The post code can be from any where in this world.

like image 759
Peeyush Avatar asked Aug 16 '11 09:08

Peeyush


People also ask

How do I find the latitude and longitude of a ZIP code in Excel?

To get the latitude of the address in cell B2, use the formula = GetLatitude(B2) To get the longitude of the address in cell B2, use the formula = GetLongitude(B2) To get both the latitude and longitude of the address in cell B2, use the formula = GetCoordinates(B2)

What is the postcode for latitude?

For those driving to Latitude, Henham Park can be found at the postcode NR34 8AN. The site sits just north of Blythburgh, which is a village in East Suffolk.


1 Answers

You can do this using google map Geocoding API. Please find below example, but to correct latitude/longitude and address you need to pass full address along with zipcode.

For more detail please click on below link:

http://code.google.com/apis/maps/documentation/geocoding/

<?php
$url ="http://maps.googleapis.com/maps/api/geocode/xml?address=1600+Amphitheatre+Parkway,+Mountain+View,+CA&sensor=false";
$result = simplexml_load_file($url);
print"<pre>";
print_r($result);
?>
like image 162
Sanjeev Chauhan Avatar answered Oct 05 '22 22:10

Sanjeev Chauhan