Friday 19 June 2015

Google Map integration in PHP to Calculate Latitude and Longitude

This code will calculate the latitude and longitude of the place in background on entering the place name.

For integration of Google map to calculate Latitude and Longitude major script is :
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false&libraries=places"></script>


To make the autocomplete of the address create a object of the class:

google.maps.places.Autocomplete
 

Here is the complete code to get the exact location latitude and longitude using Google map. Hope it may help you somewhere.

<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false&libraries=places"></script>
<script type="text/javascript">
function initialize() {
var address = (document.getElementById('my_address'));
var autocomplete = new google.maps.places.Autocomplete(address);
autocomplete.setTypes(['geocode']);
google.maps.event.addListener(autocomplete, 'place_changed', function() {
var place = autocomplete.getPlace();
if (!place.geometry) {
return;
}
 
 
- See Full Code at: http://findnerd.com/list/view/Google-Map-integration-in-PHP-to-Calculate-Latitude-and-Longitude/3558/



For queries about PHP Programming Questions and Answers, You can also Visit to PHP Developer Forum    

No comments:

Post a Comment