Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
HTML5 Geolocation without SSL connection
HTML 5 Geolocation is used to find out the location of the user. This can be without SSL connection. This can be generated as follows −
// Variable apigeo shows successful location:
var apigeo = function(position) {
alert("API geolocation success!
lat = " + position.coords.latitude + "
lng = " + position.coords.longitude);
};
var tryapigeo = function() {
jQuery.post( "check the location on google map", function(success) {
apiGeolocationSuccess({coords: {latitude: success.location.lat, longitude: success.location.lng}});
}) //Gives success on given geolocation
.failure(function(err) { //On failure, alert with failure is shown
alert("error while showing geolocation!
"+err);
});
};
Then various switch cases for the error codes can be generated, different error codes for different errors.
var tryloc = function() {//tryloc variable show current position
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(
browserGeolocationSuccess, browserGeolocationFail,{
maximumAge: 70000, timeout: 40000, enableHighAccuracy: true});
/ /this will show result with high accuracy
}};Advertisements