Showing posts with label Google Map. Show all posts
Showing posts with label Google Map. Show all posts

Wednesday 6 August 2014

Get address by using lattitude and longitude Google APi

<?php

echo getAddress("28.6100", "77.2300");

function getaddress($lat,$lng)
{
$url = 'http://maps.googleapis.com/maps/api/geocode/json?latlng='.trim($lat).','.trim($lng).'&sensor=false';
$json = @file_get_contents($url);
$data=json_decode($json);
$status = $data->status;
if($status=="OK")
return $data->results[0]->formatted_address;
else
return false;
}
?>

Friday 18 July 2014

How to get IP based country,state,currency and countrycode and Internet connection Provider and lattitude & longitude in PHP?

<?php
echo getipaddress();
function getipaddress(){
   $xml = simplexml_load_file("http://www.geoplugin.net/xml.gp?ip=".getRealIpAddr());
   print_r($xml);
   $ccode=$xml->geoplugin_countryCode;
   return $ccode;
}
function getRealIpAddr(){
   if (!empty($_SERVER['HTTP_CLIENT_IP']))  
   {
  $ip=$_SERVER['HTTP_CLIENT_IP'];
 }elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR']))  
 {
      $ip=$_SERVER['HTTP_X_FORWARDED_FOR'];
 }else{
  $ip=$_SERVER['REMOTE_ADDR'];
 }
 //$ip="YOUR IP";
 return $ip;
}
   
echo "<hr>";
$details = ip_details(getRealIpAddr());
print_r($details);

function ip_details($ip) {
    $json = file_get_contents("http://ipinfo.io/{$ip}");
    $details = json_decode($json);
    return $details;
}


?>

Monday 30 June 2014

Google Maps Image APIs

Get Google Map Image for specific latittude & longitude
Static Maps API

<img src="http://maps.google.com/staticmap?size=500x400&markers=11,78&zoom=12">


<img src="http://maps.googleapis.com/maps/api/streetview?size=200x200&location=40.720032,-73.988354&heading=235">

Friday 11 April 2014

Get Latitdue and longitude from google map

Code:
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="http://maps.google.com/maps?file=api&v=2&key=" type="text/javascript"></script>
<script type="text/javascript">
$( document ).ready(function() {
 $("#map").show();
 show_popup();
});


function show_popup(){
 $("#map").show();
if (GBrowserIsCompatible()) {
var map = new GMap2(document.getElementById("map"));
map.addControl(new GSmallMapControl());
map.addControl(new GMapTypeControl());
var center = new GLatLng(11.00, 78.00);
map.setCenter(center, 7);
geocoder = new GClientGeocoder();
var marker = new GMarker(center, {draggable: true});
map.addOverlay(marker);
document.getElementById("lat").value = center.lat().toFixed(5);
document.getElementById("lng").value = center.lng().toFixed(5);

GEvent.addListener(marker, "dragend", function() {
var point = marker.getPoint();
map.panTo(point);
document.getElementById("lat").value = point.lat().toFixed(5);
document.getElementById("lng").value = point.lng().toFixed(5);
});

GEvent.addListener(map, "moveend", function() {
map.clearOverlays();
var center = map.getCenter();
var marker = new GMarker(center, {draggable: true});
map.addOverlay(marker);
document.getElementById("lat").value = center.lat().toFixed(5);
document.getElementById("lng").value = center.lng().toFixed(5);

GEvent.addListener(marker, "dragend", function() {
var point =marker.getPoint();
map.panTo(point);
document.getElementById("lat").value = point.lat().toFixed(5);
document.getElementById("lng").value = point.lng().toFixed(5);
});
});
}
}
</script>
<table align='center'>
<tr>
<td><label>Latitude</label></td>
<td><label>:</label></td>
<td><input type="text" name="latitude" id="lat" onclick="show_popup();" readonly value=""/>
<em></em>
</td>
<td><label>Longitude</label></td>
<td><label>:</label></td>
<td><input type="text" name="longitude" onclick="show_popup();" id="lng" readonly value=""/>
<em></em>
</td>
</tr>
<tr><td colspan='6'><div align="center" id="map" style="width:700px;height:450px;-webkit-border-radius: 18px 20px 20px 20px;-moz-border-radius: 18px 20px 20px 20px;border-radius: 18px 20px 20px 20px;border:2px solid #82B5CF;background:rgba(231,228,237,0.5);"></div></td></tr>
</table>