1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/ 1.4.2/jquery.min.js"></script> <script type="text/javascript" src="jquery.cookie.js"></script> <script type="text/javascript">// <![CDATA[ function success(position) { var s = document.querySelector('#status'); if (s.className == 'success') { return; } s.innerHTML = "Found you!"; s.className = 'Success'; var mapcanvas = document.createElement('div'); mapcanvas.id = 'mapcanvas'; mapcanvas.style.height = '100%'; mapcanvas.style.width = '100%'; document.querySelector('#map').appendChild(mapcanvas); var latlng = new google.maps.LatLng(position.coords.latitude, position.coords.longitude); var myOptions = { zoom: 15, center: latlng, mapTypeControl: false, navigationControlOptions: {style: google.maps.NavigationControlStyle.SMALL}, mapTypeId: google.maps.MapTypeId.ROADMAP }; var map = new google.maps.Map(document.getElementById("mapcanvas"), myOptions); var marker = new google.maps.Marker({ position: latlng, map: map, title:"You are here!" }); $.cookie("MyLat", position.coords.latitude); // Storing latitude value $.cookie("MyLon", position.coords.longitude); // Storing longitude value } function error(msg) { var s = document.querySelector('#status'); s.innerHTML = typeof msg == 'string' ? msg : "failed"; s.className = 'Fail'; } if (navigator.geolocation) { navigator.geolocation.getCurrentPosition(success, error); } else { error('Not supported'); //HTML Support } //Jquery Code $(document).ready(function() { $("#check").click(function() { var lat = $.cookie("MyLat"); var lon = $.cookie("MyLon"); alert('Latitued: '+lat); alert('Longitude: '+lon); var url="http://maps.googleapis.com/maps/api/geocode/json?latlng="+lat+","+lon+"&sensor=false"; alert('Google Map API: '+url); //Get Json Request Here }); }); // ]]></script> <input id="check" type="button" value="Check-out" /> |
Loading………….