I wrote this script
- Code: Select all
<!DOCTYPE html><html><head>
<script>
function getCurrentPosition() {
// Try W3C Geolocation (Preferred)
if (window.blackberry && blackberry.location.GPSSupported) {
blackberry.location.setAidMode(2);
blackberry.location.refreshLocation();
document.location = 'index.php?lat=' + blackberry.location.latitude + '&lon=' + blackberry.location.longitude + '&adr=Standort+Mobiltelefon&radius=6';
} else {
if (navigator.geolocation) {
browserSupportFlag = true;
navigator.geolocation.getCurrentPosition(function (position) {
document.location = 'index.php?lat=' + position.coords.latitude + '&lon=' + position.coords.longitude + '&adr=Standort+Mobiltelefon&radius=6';
}, function () {
handleNoGeolocation(browserSupportFlag);
}, {
enableHighAccuracy: true,
maximumAge: 0,
timeout: 30000
});
// Try Google Gears Geolocation
} else if (google.gears) {
browserSupportFlag = true;
var geo = google.gears.factory.create('beta.geolocation');
geo.getCurrentPosition(function (position) {
document.location = 'index.php?lat=' + position.latitude + '&lon=' + position.longitude + '&adr=Standort+Mobiltelefon&radius=6';
}, function () {
handleNoGeoLocation(browserSupportFlag);
});
// Browser doesn't support Geolocation
} else {
browserSupportFlag = false;
handleNoGeolocation(browserSupportFlag);
}
if (browserSupportFlag) {
watchId = navigator.geolocation.watchPosition(function (position) {
if (position.coords.accuracy <= 50) {
document.location = 'index.php?lat=' + position.coords.latitude + '&lon=' + position.coords.longitude + '&adr=Standort+Mobiltelefon&radius=6';
}
}, function () {
handleNoGeolocation(browserSupportFlag);
}, {
enableHighAccuracy: true,
maximumAge: 0,
timeout: 30000
});
}
}
}
function BlackberrylocationCB() {
document.location = 'index.php?lat=' + blackberry.location.latitude + '&lon=' + blackberry.location.longitude + '&adr=Standort+Mobiltelefon&radius=6';
}
function handleNoGeolocation(errorFlag) {
document.location = 'index.php?lat=0&lon=0&adr=Standort+Mobiltelefon&radius=6';
}
</script>
</head><body onLoad="getCurrentPosition();"></body></html>
Which is to forward lat and lon from several gps-sources to index.php as parameters you can fetch with $_GET in PHP.
If handleNoGeolocation is executed, lat=0 & lon=0 is set. Using opera, chrome, ie, I get correct coordinates. Using my android phone's browser or firefox I get lat=0 & lon=0. Even though the apb and ff ask whether position should be transmitted, and a point inside a circle is flashing in android, they don't seem to pass this data.
Is this a android / ff issue you can resolve with adapting this code? If so, how?