Im building an app that requires location. Im serving my app locally via apache and have permitted chrome to give my virtual host access to location despite being served without ssl. My coordinates are coming out wrong as (6.5243793 3.3792057). Thats completely in another state on another part of my country. When I visit https://www.gps-coordinates.net/my-location, it gives the same location. But on firefox, https://www.gps-coordinates.net/my-location is giving me a more accurate location. On chrome mobile, im also getting a correct location Here is my code snippet
if(navigator.geolocation){
navigator.geolocation.getCurrentPosition(function(position){
var lat = position.coords.latitude,
long = position.coords.longitude;
initMap(lat,long);
// logging to console to find out why the map location is incorrect
console.log(lat+" "+long)
});
}
Can someone tell me whats going on, or better yet how to find out the exact location, probably through google maps api?
Chrome on mobile uses the GPS in your phone.
Chrome on desktop uses a service that estimates your location based on your IP address. This database is imprecise and often out of date. Firefox uses a different service, which works in the same way, but where your particular IP has a more accurate record.
Related
I'm working on a project where the user's location is needed. The implementation seems to be working correctly, the user gets a prompt to allow sharing their location and the coordinates are received.
The problem is that those coordinates seem to wildly change based on the device or browser. Three different browsers in the same device provide 3 different coordinates, and not just with my code, the same happens when testing with other sites that provide geolocation like https://my-current-location.com/
Does this mean that the browsers Geolocation API can't be trusted? Is there a better way of obtaining a user's location that's more reliable?
I've tried working with server-side location (IP) and the results were also as bad, at least for the part of the world where this needs to work.
I try to take my location by using the share location html5 geolocation on the browser, when run in PC browser it appears a notif to allow access share location, while when I try on my smartphone browser chrome / firefox it does not work ... so my question..
whether when share location it only take Lat / Lot according from my IP ..
When share location why is not accurate, is taking the location of my card provider phone.
whether to use the GPS feature on our smartphone to take the location through the browser.
I have a Google Map (v3) on a website. When a user hits the page, I am reading the geolocation from it´s browser (if it´s supported):
navigator.geolocation.getCurrentPosition(successCallback, errorCallback, {enableHighAccuracy: true, timeout: timeOut, maximumAge: maximumAge })
The function is working, but not always as expected. In Google Chrome it´s working perfectly - the getCurrentPosition function is returning a coordinate object with latitude and longitude as floating points (decimals). Curiously it´s different in IE11. It´s also returning the coordinate object - but here are both latitude and longitude in integers, which means, that the accuracy is very bad, and not really showing the right position on the map.
Is this a bug? And does anyone know if it´s possible to fix this?
Thank you!
Different browsers use different geolocation service providers to get an estimate of your location and that could explain why you're seeing different results with Google Maps.
Google Chrome similarly uses Google Location Services. The default geolocation service provider of Firefox is Google Location Services as well. Safari uses Skyhook Wireless's service.
Searching on the web, I could not find which specific geolocation service provider IE makes use of but the different results you see between browsers can be attributed to the quality of data provided by the geolocation service provider. So my guess is, you have to wait for the precision of the geolocation calculation in IE to improve as I haven't seen any documented way to change the geolocation service provider that a browser uses. Alternatively, see if Bing Maps works well in IE or try using a commercial IP-based Geolocation detector service like Maxmind to detect coordinates.
The problem is that if the user denies access to location data, the google map is never initialized.
For Example: http://code.google.com/apis/maps/documentation/javascript/examples/map-geolocation.html
When it asks for permission, say not now. The map will be grey.
What can I do to initialize the map no matter what?
I decided to just set a default center point on the map so that if I get a more specific position, I zoom in there, if not I leave it alone.
Hopefully Mozilla fixes this soon, since the bug has been around nearly a year.
Use a server-side script to do IP address geolocation. This will yield a location in the same country at least. Use the IP address's location as default if the user does not permit geolocation in the browser.
An example web service providing IP geolocation is http://www.geobytes.com/iplocator.htm Google will find many more.
If I use navigator.geolocation.getCurrentPosition() in any web page and visit it using web browser of any mobile device with GPS, will it use GPS navigation?
And how it will determine location if device has no GPS?
The Geolocation API is agnostic of the underlying location information sources and therefore it is up to the browser (and device) to determine how the geolocation data is determined.
See here for more details on how Firefox gets the geo location information from Google, http://code.google.com/p/gears/wiki/GeolocationAPI
Short answer is: they keep a database with the location of all wifi hotspots (most likely collected by the same cars that take streetview footage) and uses that information to provide location data.