html - get the latitude and longitude using javascript -
i have textbox
in page gets location
name , button
text getlat&long
. on clicking
button have show alert
of latitude
, longitude
of location in textbox
. suggestion?
please dont give me suggestion googleapis b'coz stage limitations after limit want pay this. try googleapis
:-
<html> <head> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script> <script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?sensor=false"></script> <script type="text/javascript"> function myip(){ $("#btn").click(function(){ var geocoder = new google.maps.geocoder(); geocoder.geocode( { 'address': '#city'}, function(results, status) { if (status == google.maps.geocoderstatus.ok) { alert("location : " + results[0].geometry.location.lat() + " " +results[0].geometry.location.lng()); } else { alert("something got wrong " + status); } }); }); } </script> </head> <body onload="myip()"> <input type="text" id= "city"> <input id="btn" type="button" value="get lat&long" /> </body> </html>
thanks.
getting latitude , longitude address or location name (geocoding) complicated, third party service google api going needed.
Comments
Post a Comment