Get Latitude and longitude of address php

PHP code to get Latitude and Longitude from Google Map

This PHP code will help you to get the Latitude and Longitude of the given address. Google enable us to get the latitude and longitude using the JSOn API code. Here we just read the json api from google and parse the JSON code and use it in PHP code

<?php
$address = 'No:xx Streen name, Post office, City, Country PIN/ZIP code';
$prepAddr = str_replace(' ','+',$address);
$geocode=file_get_contents('http://maps.google.com/maps/api/geocode/json?address='.$prepAddr.'&sensor=false');
$output= json_decode($geocode);
$lat = $output->results[0]->geometry->location->lat;
$long = $output->results[0]->geometry->location->lng;
echo $address.'<br>Lat: '.$lat.'<br>Long: '.$long;
?>


Related Topic jQuery Code for Google or Yahoo! Map Interface
How to Calculate Distance Between Two Coordinates
Latitude and Longitude Calculation in Geographic Coordinate System
Short Notes on Point-to-Point Protocol
What are all the Primary Networking Devices
PHP  Google  

nScraps.com 2011   Privacy Policy  Terms of Service  Feedback