Welcome to WebmasterWorld Guest from 54.159.105.39

Forum Moderators: open

Message Too Old, No Replies

Reading current location

     
10:38 am on Sep 30, 2016 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month

joined:Oct 25, 2006
posts: 1043
votes: 0


I have read blog Google developers like:
[developers.google.com ]

1. How to read value Lat and Lon in this examples to be captured?
2. How to enable current position and its detection just from mobile devices as it is not correct if user is using PC as static location?

Capturing Google map items can be done.
<input type="hidden" data-geo="lat" name="lat" />
<input type="hidden" data-geo="lng" name="lng" />



window.onload = function() {
var startPos;
var geoOptions = {
enableHighAccuracy: true
}

var geoSuccess = function(position) {
startPos = position;
document.getElementById('startLat').innerHTML = startPos.coords.latitude;
document.getElementById('startLon').innerHTML = startPos.coords.longitude;
};
var geoError = function(error) {
console.log('Error occurred. Error code: ' + error.code);
// error.code can be:
// 0: unknown error
// 1: permission denied
// 2: position unavailable (error response from location provider)
// 3: timed out
};

navigator.geolocation.getCurrentPosition(geoSuccess, geoError, geoOptions);
};