Get Visitor Location(lat/long) Using Geo location in Any Application

 

       Get Visitor Location(lat/long) Using Geo location in Any Application






function getLocation() { if (navigator.geolocation) { navigator.geolocation.getCurrentPosition(showPosition, showError); } else { alert("Geolocation is not supported by this browser."); } } function showPosition(position) { apex.item("PAGE_ITEM_LAT").setValue(position.coords.latitude) apex.item("PAGE_ITEM_LONG").setValue(position.coords.longitude) function geocode_api(){ var latitude = position.coords.latitude var longitude = position.coords.longitude var key = "API_KEY" $.post('https://maps.googleapis.com/maps/api/geocode/json?latlng='+latitude+','+longitude+'&key='+key+'', function(data, status){ var address = JSON.parse(JSON.stringify(data.results[0].formatted_address)) apex.item("PAGE_ITEM_LOCATION").setValue(address) // alert("Data: " + data + "\nStatus: " + status); }); }; geocode_api(); } 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.geolocation app tutorial, geolocation, javascript, location") break; case error.TIMEOUT: alert("The request to get user location timed out.") break; case error.UNKNOWN_ERROR: alert( "An unknown error occurred.") break; } }





Stay Informed:  Stay up-to-date with the latest Oracle APEX tips and updates by following my social media profiles.

 Follow on YouTube:  Dive deeper into Oracle APEX by exploring my YouTube channel for tutorials and insights: 

 YouTube Channel: YouTube


Connect on LinkedIn:  Let's connect on LinkedIn for networking opportunities, discussions, and more: 

 LinkedIn Profile: Linkedin



Comments