Server IP : 162.214.80.37 / Your IP : 216.73.216.83 Web Server : Apache System : Linux sh013.webhostingservices.com 4.19.286-203.ELK.el7.x86_64 #1 SMP Wed Jun 14 04:33:55 CDT 2023 x86_64 User : imyrqtmy ( 2189) PHP Version : 8.2.18 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON Directory (0755) : /home2/imyrqtmy/public_html/clickonn/assets/js/ |
[ Home ] | [ C0mmand ] | [ Upload File ] |
---|
// <script type="text/javascript"> var searchInput = 'search_input'; $(document).ready(function () { // alert('k'); var autocomplete; autocomplete = new google.maps.places.Autocomplete((document.getElementById(searchInput)), { types: ['geocode'], }); google.maps.event.addListener(autocomplete, 'place_changed', function () { var near_place = autocomplete.getPlace(); document.getElementById('loc_lat').value = near_place.geometry.location.lat(); document.getElementById('loc_long').value = near_place.geometry.location.lng(); document.getElementById('latitude_view').innerHTML = near_place.geometry.location.lat(); document.getElementById('longitude_view').innerHTML = near_place.geometry.location.lng(); }); }); $(document).on('change', '#'+searchInput, function () { document.getElementById('latitude_input').value = ''; document.getElementById('longitude_input').value = ''; document.getElementById('latitude_view').innerHTML = ''; document.getElementById('longitude_view').innerHTML = ''; }); // </script> // <script> function getLocation() { if (navigator.geolocation) { navigator.geolocation.getCurrentPosition(showPosition, showError); } else { alert("Geolocation is not supported by this browser."); } } function showPosition(position) { var latitude = position.coords.latitude; var longitude = position.coords.longitude; // You can now send this information to the server using AJAX or any other method // For simplicity, let's just display it on the page // document.getElementById("demo").innerHTML = "Latitude: " + latitude + "<br>Longitude: " + longitude ; // Reverse geocoding using Google Maps Geocoding API var geocodingApiUrl = 'https://maps.googleapis.com/maps/api/geocode/json?latlng='+latitude+','+longitude+'&key=AIzaSyB0F4Yf0ERMSt5OwSDyxHezMyLC9aeMM7E'; fetch(geocodingApiUrl) .then(response => response.json()) .then(data => { if (data.status === "OK") { var address = data.results[0].formatted_address; document.getElementById("demo").innerHTML = "Latitude: " + latitude + "<br>Longitude: " + longitude + "<br>Address: " + address; document.getElementById("search_input").value = address; // $.session.set("userlocation", address); $.ajax({ type: 'POST', url: 'userloaction.php', data: {add: address }, success: function(response) { // alert(response); // $('#sub').html(response); // content.html(response); } }); } else { document.getElementById("demo").innerHTML = "Error in geocoding request"; } }) .catch(error => { console.error('Error fetching geocoding data:', error); document.getElementById("demo").innerHTML = "Error in geocoding request"; }); } function showError(error) { switch (error.code) { case error.PERMISSION_DENIED: alert("User denied the request for Geolocation."); break; case error.POSITION_UNAVAILABLE: alert("Location information is unavailable."); break; case error.TIMEOUT: alert("The request to get user location timed out."); break; case error.UNKNOWN_ERROR: alert("An unknown error occurred."); break; } } window.onload = getLocation; // </script> // <script> // function getLocation() { // if (navigator.geolocation) { // navigator.geolocation.getCurrentPosition(showPosition, showError); // } else { // alert("Geolocation is not supported by this browser."); // } // } // function showPosition(position) { // var latitude = position.coords.latitude; // var longitude = position.coords.longitude; // // Reverse geocoding using Google Maps Geocoding API // var geocodingApiUrl = https://maps.googleapis.com/maps/api/geocode/json?latlng=latitude,longitude&key=AIzaSyB0F4Yf0ERMSt5OwSDyxHezMyLC9aeMM7E; // fetch(geocodingApiUrl) // .then(response => response.json()) // .then(data => { // if (data.status === "OK") { // var address = data.results[0].formatted_address; // document.getElementById("demo").innerHTML = "Latitude: " + latitude + "<br>Longitude: " + longitude + "<br>Address: " + address; // } else { // document.getElementById("demo").innerHTML = "Error in geocoding request"; // } // }) // .catch(error => { // console.error('Error fetching geocoding data:', error); // document.getElementById("demo").innerHTML = "Error in geocoding request"; // }); // } // function showError(error) { // switch (error.code) { // case error.PERMISSION_DENIED: // alert("User denied the request for Geolocation."); // break; // case error.POSITION_UNAVAILABLE: // alert("Location information is unavailable."); // break; // case error.TIMEOUT: // alert("The request to get user location timed out."); // break; // case error.UNKNOWN_ERROR: // alert("An unknown error occurred."); // break; // } // } // window.onload = getLocation; // </script>