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 |
Playing Animations on Scroll | 19,876 Kb |
Dungeon Crawler | 3,644 Kb |
Simple Accordion | 2,952 Kb |
Circle Progression Plugin | 2,612 Kb |
Responsive square grid in pure CSS | 2,140 Kb |
Form Progress Bar | 4,644 Kb |
Sliding Lines Animation | 2,572 Kb |
Custom Select Element | 3,616 Kb |
SVG Animation - Circle Fill | 3,322 Kb |
Multi-Column Responsive Carousel | 5,686 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 |
Animated Donut Chart | Jplhomer | 3,808 Kb |
Simple checkbox style | Vncnz | 2,628 Kb |
A Pen by Theun | Tjoen | 6,152 Kb |
A Pen by Miro Olma | Programiro | 2,342 Kb |
Voting App - register | MatheusLima92 | 1,948 Kb |
Animated rainbow wave on canvas | Icodeforlove | 2,777 Kb |
Coburg Banks SVG Logo | Mjtweaver | 3,875 Kb |
React Vote Component | Souporserious | 5,465 Kb |
Large canvas mousemove experiment | Jibbon | 2,885 Kb |
Mario | Takaneichinose | 3,902 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!