HTML5 GeoLocation Example
How do I make an html5 geolocation example?
Light weight geo location example that returns the users address, city, etc.... What is a html5 geolocation example? How do you make a html5 geolocation example? This script and codes were developed by Adam Grayson on 10 November 2022, Thursday.
HTML5 GeoLocation Example - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>HTML5 GeoLocation Example</title> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/meyer-reset/2.0/reset.min.css"> <link rel="stylesheet" href="css/style.css">
</head>
<body> // Be sure to enable-allow your browsers geoLocation features for this page
// Address wont be 100 percent accurate- but has increased performance on devices with GPS features such as phones and tablets
//Inspired by 'http://petarstrinic.com/visitors-zip-code-using-html5-geolocation-google-maps-api/'
.geoLocation .address p searching... .city p searching... .state p searching... .zip p searching... .country p searching... <script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script>
<script src='https://maps.googleapis.com/maps/api/js?sensor=false'></script> <script src="js/index.js"></script>
</body>
</html>
HTML5 GeoLocation Example - Script Codes CSS Codes
html, body { width: 100%; height: 100%; background: #12aeef; font: 25px/35px "TrebuchetMS", trebuchet, sans-serif; color: #ffffff; text-align: center; position: relative; display: table;
}
html .geoLocation, body .geoLocation { display: table-cell; vertical-align: middle;
}
HTML5 GeoLocation Example - Script Codes JS Codes
(function() { var getLocation, setAddressText, showPosition; getLocation = function() { if (navigator.geolocation) { return navigator.geolocation.getCurrentPosition(showPosition); } else { return alert("Geolocation is not supported by this browser."); } }; showPosition = function(position) { var lat, long, point; lat = position.coords.latitude; long = position.coords.longitude; point = new google.maps.LatLng(lat, long); new google.maps.Geocoder().geocode({ latLng: point }, function(res, status) { var address, city, country, state, zip; address = res[0].formatted_address.match(/[^,]+/); zip = res[0].formatted_address.match(/,\s\w{2}\s(\d{5})/); city = res[0].formatted_address.match(/,\s(\w+),\s\w{2}/); state = res[0].formatted_address.match(/,\s\w+,\s(\w{2})/); country = res[0].formatted_address.match(/\d,\s(.+)$/); setAddressText(address[0], city[1], state[1], zip[1], country[1]); }); }; setAddressText = function(address, city, state, zip, country) { $('.address p').text(address); $('.city p').text(city); $('.state p').text(state); $('.zip p').text(zip); return $('.country p').text(country); }; getLocation();
}).call(this);
Developer | Adam Grayson |
Username | agrayson |
Uploaded | November 10, 2022 |
Rating | 3 |
Size | 3,685 Kb |
Views | 24,288 |
Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!
Name | Size |
SVG Animation - Circle Fill | 3,322 Kb |
Simple Accordion | 2,952 Kb |
Circle Progression Plugin | 2,612 Kb |
Drag and Drop File Preview | 3,444 Kb |
Dungeon Crawler | 3,644 Kb |
Centered background Image with hot spots | 3,869 Kb |
HTML5 GeoLocation Example | 3,685 Kb |
Custom Event Policing | 3,255 Kb |
Responsive square grid in pure CSS | 2,140 Kb |
Form Progress Bar | 4,644 Kb |
Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!
Name | Username | Size |
Pure CSS Menu | Bronsrobin | 3,321 Kb |
A Pen by Bryan | Brydave | 2,286 Kb |
Bootstrap Responsive Menu Drawer | JesseGlacken | 3,777 Kb |
RollOver Effect 2 | Lmack90 | 2,162 Kb |
Sort the Knowlege | Eprouver | 3,915 Kb |
CSS 3D Radio buttons | Andreasnylin | 1,650 Kb |
Two column of responsive height | Fixie | 2,908 Kb |
Page Transitions in Backbone | Mikefowler | 3,691 Kb |
Slide In Panel | Vikvarg | 2,811 Kb |
Tail rose iris lined | Kbrtrm | 1,846 Kb |
Surf anonymously, prevent hackers from acquiring your IP address, send anonymous email, and encrypt your Internet connection. High speed, ultra secure, and easy to use. Instant setup. Hide Your IP Now!