I try to detect the exact location of user and specially the street if i can.
I tried that using the IP but this didn't work for me because it didn't give the exact location example for what i want is Lebanon Beirut Azarieh or Lebanon Beirut ABC Achrafieh and than i want to store this location in MYSQL database table using PHP.
i tried this code here this code give a good location in Firefox on Localhost
but Online on Firefox and Google chrome give me that Your Location: Not Available
also it didn't work on phone browser iPhone and android (safari,chrome,...)
the idea is a user in the company want to use the website on his phone a special page on the website when he use it i want to take here exact location with the street and store this in database
You can use a flag, enableHighAccuracy:true
Here's an example code:
$(document).ready(function($){
if (navigator.geolocation){
navigator.geolocation.getCurrentPosition(function(position){
latitude = position.coords.latitude;
longitude = position.coords.longitude;
//alert('latitude: '+latitude+' longitude: '+longitude);
}, function(error) {
alert('Error occurred. Error code: ' + error.code);
},{timeout:20000,enableHighAccuracy: true});
}
else{
alert('no geolocation support');
}
});
And I also want to quote that enableHighAccuracy
depends from device to device.
reference here
Here is an android code link,you can get some idea from.getlocation with street