Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 4 years ago.
Improve this question
I would like to know how geolocation works in a web browser like Google Chrome or Firefox?
I can access this web site http://html5demos.com/geo and when I allow the browser to send my location, it shows my current location.
But when I send that URL to my friends to test it, it doesn't work for all of them. How does geolocation work and how do I implement it to get the correct location?
When you visit a location-aware
website, Firefox will ask you if you
want to share your location.
If you consent, Firefox gathers
information about nearby wireless
access points and your computer’s IP
address. Then Firefox sends this
information to the default geolocation
service provider, Google Location
Services, to get an estimate of your
location. That location estimate is
then shared with the requesting
website.
http://www.mozilla.com/en-US/firefox/geolocation/
So it depends on the browser they are using and some luck :-)
Re how it works: the Wikipedia article discusses several techniques (IP address location, cellphone and WiFi triangulation, GPS).
The HTML5 implementations require both browser support (FF 3.6, Opera 10.60, Chrome 4? 5?, IE maybe some day) and user consent before the geolocation data are retrieved.
As to how to implement it, the code of the demo you link to seems to be under the MIT License which basically says "you can do whatever, as long as you keep the resulting code under the license"; so you could take that code as a base to build on.
Info and examples from W3C Geolocation API Specification:
The Geolocation API defines a high-level interface to location
information associated only with the device hosting the
implementation, such as latitude and longitude. The API itself is
agnostic of the underlying location information sources. Common
sources of location information include Global Positioning System
(GPS) and location inferred from network signals such as IP address,
RFID, WiFi and Bluetooth MAC addresses, and GSM/CDMA cell IDs, as well
as user input. No guarantee is given that the API returns the device's
actual location.
You could implement it this way:
(one-shot position request)
function showMap(position) {
// Show a map centered at (position.coords.latitude, position.coords.longitude).
}
// One-shot position request.
navigator.geolocation.getCurrentPosition(showMap);
(requesting repeated position updates)
function scrollMap(position) {
// Scrolls the map so that it is centered at (position.coords.latitude, position.coords.longitude).
}
// Request repeated updates.
var watchId = navigator.geolocation.watchPosition(scrollMap);
function buttonClickHandler() {
// Cancel the updates when the user clicks a button.
navigator.geolocation.clearWatch(watchId);
}
Things really depend on the implementation of the website you are using and your browser.
Simplest way, which doesnt require any client side extensions is that the webpage gets your ip address and uses any of the "ip to geolocation" services to make a questimate where you are currently.
Second options is that browsers have an extension that can advertise your your coordinates to the webserver. In these cases, this information in the client side can be either fetched, again from ip to geolocation services or gps unit attached to your computer. For example, Nokia N900 and build-in browser MicroB has this sort of extension.
Related
I assume it has something to do with this:
For me Google one Tap stopped working on all my sites that previously worked. I added API HTTP refer to restriction in console.developer.com, but I still get a warning message "The client origin is not permitted to use this API." any thoughts? If you go to the page https://www.wego.com/ you can see that Google one tap still works...
https://news.ycombinator.com/item?id=17044518#17045809
but Google YOLO stop working for everyone. I use it like many people for login and it just stop work.
My domain are obviously added on console.developers.google.com
Any ETA for fix this? Some information would be great for people who rely on it.
Google YOLO is not disabled. It is open to a small list of Google Partners.
The reason you were able to access it earlier was because it was open for a short period of time but the whitelist is now readded/enabled.
Reference:
https://twitter.com/sirdarckcat/status/994867137704587264
Google YOLO was put on whitelist after a client-side exploit became clear to google.
People could cover the login button of the prompt with something like a cookie consent (which we all know people automatically accept).
Therefor people could easily steal their gmail or other details due to this google decided to put it on whitelist and review the sites that are using this technology in order to ensure that they are using it as they should.
Google retroactively labeled One-Tap as a "closed beta".
https://developers.google.com/identity/one-tap/web
The beta test program for this API is currently closed. We are improving the API's cross-browser functionality and will provide updates here in the coming months.
The link for the entire project is currently 404, but the beta statement is visible on the wayback machine.
I am looking to spoof the geo ip information in my local sitecore 8 instance so I can create events widget based on which city the end user is in.
From my research I found you can either use the ForwardedRequestHttpHeader in the header to pass the IP or my own class to override the IP via startTracking pipeline. Both these method allow me to write the IP address into the Interaction collection in my xDB.
My question is how do I resolve the spoofed IP to get rest of the details in Interaction collection document such as city, state, country and postcode?
Please note: I currently do not have access to the sitecore geolocation service. So really need a way to mock all the geo location based data.
Not sure if it helps, but 8.1's Experience Explorer allows you to (natively) spoof locations. If you expand out the ribbon and goto the Experience Tab and click "Other" you'll see "Explore":
Once you click that, the UI will change over and expose two expandable tabs (on left and right). On the left slide-out, you can manage location by going to the "Visitor Information" section and opening the "GEO IP" tab.
What I needed to was to spoof the IP address but also create a custom geo ip lookup provider by overriding the method GetInformationByIp(string ip) in
LookupProviderBase.
More than a question this may be general information . I am using a VPN service and located in the Middle East. I've found most (if not all but one) IP geolocation webpages shows my location as New York which matches the VPN IP address. But the service whatismyipaddres_dot_com shows the correct IP address and my location in Kuwait. Clicking some links on the mentioned webpage it takes me to a page showing they use several services from which one is showing Kuwait and the other two New York. However,contary on the expected "majority vote", they pick the single one different which, in fact, is right. As you can see they do not mention the name, but I believe the provider is Maxmind (maxmind_dot_com).
Sorry, not allowed to post images!!
Does anyone knows what they may be using ( router MAC? Google account ?).I use VPN to access ESPN , etc , but if this method is used by all other geoloc services in the future ,it will render the VPN unusable !
The web site whatismyipaddress dot com is using a mixture of HTML5 geolocation and IP geolocation.
Most likely your MAC address are being used to geolocate the location using HTML5 than using IP address geolocation.
Source: http://www.geolocation.com
I'm communicating with an API that requires I use a particular user-agent string. The format for this is basically User-Agent: IOS_USER_AGENT API_CUSTOM_AGENT
Upon investigation I discovered that people would use UIWebView and apply a javascript function to extract the system user agent string. Now that UIWebView is deprecated, its replacement WKWebView offers an asynchronous means of calculating the user agent (not ideal for my purposes).
Is there any way to extract some form of the iOS user agent string without needing to randomly create some off-screen web view. Especially with SFSafariViewController I don't think its entirely impossible that these web views become deprecated in future.
I know that Apps like WhatsApp and Facebook use the system User-Agent see here. The question is, what is the most reliable way of achieving this without involving web view trickery?
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 10 months ago.
The community reviewed whether to reopen this question 10 months ago and left it closed:
Original close reason(s) were not resolved
Improve this question
What does it mean when you see things like:
?__utma=1.32168570.1258672608.1258672608.1259628772.2&__utmb=1.4.10.1259628772&
etc in the the url string?
Maybe it's simple, but I'm thinking it's something I'm not aware of because I see it every now and again.
Here's a good link to explain them. They are cookies used by Google Analytics to track information on your website:
https://developers.google.com/analytics/devguides/collection/analyticsjs/cookie-usage#gajs
Your browser don't support cookies. That's the reason you see it in the url.
In fact google use cookies __utma, __utmb, __utmc, __utmz to track information.
When cookies are disabled - browser pass this information throught URL as GET param.
They are URL parameters, they pass information back to the web server.
protocol://username:password#server:port?parameterList#anchorName
Example:
http://stackoverflow.com:80/page?param1=value1¶m2=value2
The #anchorName will skip you to a certain part of an HTML page
The parameterList portion is also called the query
The protocol portion is also called the scheme
The username:password part can be ommitted
The port will default to 80 if the protocol is HTTP and the port is not specified
If you don't specify the protocol in a web browser, it will default to HTTP.
You will often want to have a single page do multiple things. This is accomplished by accepting different parameters. These parameters will typically pass information to the server which will modify how the next page is displayed, or how another action is performed on the server
Sometimes URL parameters are replaced with nice looking URL paths. This is accomplished with newer web frameworks like ASP .NET MVC, Django, Ruby on Rails, etc...
There is a much more detailed description from what I gave in RFC 3986: Uniform Resource Identifier (URI): Generic Syntax.
The __utma Cookie
This cookie is what’s called a “persistent” cookie, as in, it never expires (technically, it does expire…in the year 2038…but for the sake of explanation, let’s pretend that it never expires, ever). This cookie keeps track of the number of times a visitor has been to the site pertaining to the cookie, when their first visit was, and when their last visit occurred. Google Analytics uses the information from this cookie to calculate things like Days and Visits to purchase.
The __utmb and __utmc Cookies
The B and C cookies are brothers, working together to calculate how long a visit takes. __utmb takes a timestamp of the exact moment in time when a visitor enters a site, while __utmc takes a timestamp of the exact moment in time when a visitor leaves a site. __utmb expires at the end of the session. __utmc waits 30 minutes, and then it expires. You see, __utmc has no way of knowing when a user closes their browser or leaves a website, so it waits 30 minutes for another pageview to happen, and if it doesn’t, it expires.
[By Joe Teixeira]
It is related to google analytics... it's used for their tracking. Although I suspect Brian's answer answers what you were really asking...