W3C Geolocation API in IE9


IE9 RC includes support for the W3C Geolocation API, which enables Web developers to request the user’s physical location. This capability is useful for many Web sites, especially those that are already location-aware. For example, mapping services can now center the map based on where you actually are. Sites that let you check in can recommend nearby places. Local search can work more reliability.

Screen shot of location displayed on map

Internet Explorer respects your privacy. With your permission, Web sites can obtain your approximate latitude and longitude by calling one of the W3C Geolocation API methods. If a Web site requests your location, Internet Explorer will notify you and let you choose whether or not to grant the requesting Web site access to your location. You can allow or deny the Web site access to your location once, or you can always allow or deny by clicking on the “Options for this site” button. At any time, you can clear the list of sites you have allowed or denied access to on the Privacy tab in Tools->Internet Options. On that tab, you can also turn off geolocation and prevent any Web site from requesting your location.

Screen shot of prompt asking for permission to provide location

If you allow, Internet Explorer will approximate your location with the help of the Microsoft Location Service and works without the need for additional hardware. Given an IP address or a list of nearby WiFi hotspots, it can approximate your physical location using a database of IP addresses and a database of known hotspot locations.

Illustration showing how WiFi positioning works

You can try out this capability on the IE9 Test Drive site. Just click “locate me,” approve the prompt, and check out the result. If you zoom out, you can see the error radius that is returned by the API. You’ll notice that location requests with WiFi data are more accurate than those based just on IP address.

In a future post we’ll get into some useful code samples that demonstrate how to integrate this capability into your Web site. Until then, you can check out the Geolocation Demo on the IE Test Drive site.

—Andy Zeigler, Program Manager, Internet Explorer

Comments (72)

  1. Eric Wilson says:

    If I have GPS hardware installed, will IE use this information?  For example, on Windows Phone 7 will IE9 use GPS information or will it still waste bandwidth communicating with the Windows Location Service?  If the later, how will it determine my location when I am using the phone network and not a hotspot?

  2. Arron says:

    Quick question, that the following quote made me think of

    "If a Web site requests your location, Internet Explorer will notify you and let you choose whether or not to grant the requesting Web site access to your location."

    When writing what is your intended audience, I had been assuming it was developers, however when I see things like implying the reader is not the developer in the example or the rare few that seems like the marketing team hacked your account to make a post, it makes me wonder. Not that their is anything wrong with writing to other audiences just curious.

  3. Peter says:

    I have an error radius of 50 miles here (Country Germany, a home desktop PC without GPS hardware). If I want use this Geolocation for any reason, this 50 miles are too much. Would it be not better if the IE use the location window settings if available (System control->location and other sensors) and not the Microsoft Location Service?

  4. steve says:

    you have a typo/grammar issue on the Test Drive site:

    "Clicking the button below will the W3C Geolocation" – huh? what?!

    Good to see it working here – previous tests showed it wasn't working… or did Microsoft "bend" the specs again to suit their needs?

    PS Still absolutely HATE the notifications at the bottom of the screen.  I would PAY for a feature to move them back to the TOP where I WANT and NEED them.

  5. frank-e says:

    Thanks for the nice test page <ie.microsoft.com/…/Default.html>. I'm quite surprised that my mobile broadband provider shares my location with anybody claiming to have my permission. In fact I gave you the permission, but my provider can't be sure that I did this, or can they?

  6. Blaise Kal says:

    Nice!

    Now please implement web workers, web sockets, html5 forms, text-shadow, border-image and multi-columns!

  7. Klaise Bal says:

    yay!

  8. Doug says:

    The location service seems to be absolutely useless, and I live in a major city (London). Firefox/Chrome get my location spot on…

  9. EricLaw says:

    @Arron: The IEBlog has a HUGE number of readers, and hence we write for many audiences. This post isn't one of our developer-focused posts– those include code. :-)

    @Doug: Can you please be a bit more specific? What exactly happens when you use the demo page?  thanks!

  10. Doug says:

    @EricLaw – it gives my location as next to the Houses of Parliament (i.e. centre of the city), with an error radius that covers pretty much the entire Greater London area. On the same test Firefox/Chrome get my actual location (in the North-East) to within such accuracy that Bing skips the street map and zooms straight into the aerial photography.

  11. @EricLaw: The post has a link to a W3C API Specification. Isn't that enough to make it a developer post? :-)

  12. Bolknote.ru says:

    Pls add offline application manifest support to the browser!

  13. Alvatrus says:

    As an end-user, I am quite relieved and reassured that IE9 gives me some form of control on with whom I want to share my location. At least MS takes my privacy a bit more serious than the other vendors.

    Of course, I'll be the first to allow a third-party ad to access my location on a roadmap site, but it's the thought that counts…

  14. Josh T. says:

    It's good, but it needs some adjustments. Firefox 4, can very accurately pin-point my location down to the very part of the street that I live in, whereas IE9 believes that I'm in a 30 mile radius of somewhere called Mold in Wales (which is correct, but a lot less accurate).

  15. Aethec says:

    Uh…IE9 locates me tenths of kilometers above my actual location.

    Why don't you give us an option to manually enter an address as our location?

  16. Jayne says:

    New bug in IE9 RC – You can't paste a javascript: url into the addressbar! – which makes testing/using bookmarklets in IE really frustrating!

    If you try to add one, IE strips out the javascript: protocol and just leaves your code in the addressbar which causes a search in your preferred search engine rather than executing the code.

    What is even more frustrating is if you HAND TYPE "javascript:" and then paste in the bookmarklet you want to use IE STILL strips it from the URL!

    On the bright side, you can now FINALLY! drag a bookmarklet to your favorites bar, and IE will prompt you if you want to add it… and then MAGIC! it actually adds it! – This was !@#$ing painful in IE8. Thank you for fixing it!

  17. Richard says:

    Huge fan of IE9, but I have to agree with the other guys. Firefox and Chrome both find my exact (like EXACT) location in North London, IE9 puts me in East London.

  18. Kyle says:

    Remote location, limited Wifi:

    Testing IE9 RC Geolocation – Cannot find me.  Testing in Firefox – finds my city

    Easy location with good wifi:

    IE9RC finds me and so does Firefox, but Bing maps fails to render fully.

    2 Outcomes:

    1.) IE9's geolocation needs more fallback support.

    2.) Using Bing Maps was a mistake.  There's a little company called Google that mastered this years ago.  Why would you waste your time trying to use anything but Google Maps?

  19. Jayne says:

    window.prompt() still broken in IE9RC.

    img254.imageshack.us/…/ie9rcpromptfail.png

    Notice how lines are lost, the dialog is a mess, there's no Windows Vista/7 styling, the buttons on the right are all goofy looking, and the font rendering looks like it was done on an Etch-a-sketch [TM].

    Its very disappointing that even with all the new features, IE still can't fix the easy stuff that's been broken for years.

  20. Warren says:

    @Jayne

    That's not a bug, that's a security feature. You can always use the IE Developer Tools Console to muck around with it. You can also type JAVASCRIPT: after pasting in the JavaScript and that will work. See blogs.msdn.com/…/ie9-release-candidate-minor-changes-list.aspx

  21. Prior Semblance says:

    IE9 located my house pretty much perfectly, it was basically pointing right at my router lol.

  22. Jayne says:

    @Warren (thanks for the link) and ok – I see the Social copy/paste this to blah, blah, blah issue… but if I MANUALLY TYPED in JAVASCRIPT: and then pasted in the content I wanted to use… it shouldn't strip "javascript:" from the entire URL, just from the piece I pasted.

    As a developer – IE makes it harder and harder to do real testing in IE.  Its no wonder developers don't build in IE, they only test in IE to ensure what code they send to Chrome and Firefox still works in IE.  I still can't figure out why the about:blank page can't use the javascript: protocol.  It makes testing the most basic things a PITA.  Want to know what the user agent string is? well, first you have to navigate to some page because you can't look it up on the blank page or the tabs page. – Ugh!  Unless of course you press F12 first then click the script tab, then type in the console prompt… then it works – wait if I can do it there – why does the address bar restrict me? What gives?!?!

  23. Pete says:

    Microsoft buildings form patterns?

  24. Croft says:

    A nice feature, I tried just now and it works and looks good. =)

    (When I installed the Release Candidate, it is not working for some reason)

  25. sodaxp says:

    Great post! But when I try the test in IE9 RC, it shows "Unable to locate your position."; if I try the test in Firefox, it shows a Bing map with my current location :D By the way, I'm in Lima, Peru, South America :D :D

    I think IE should support more cities in more countries, something that Firefox does right now.

    Anyway, keep up the good work MS :D

  26. Ryan Gasparini says:

    If only we had IndexedDB so we can actually do something with that data. ^_^

  27. gavin says:

    Is there a way to opt out of the download reputation feature without disabling SmartScreen filter? I like SmartScreen but I don't want to use the reputation based downloading service because after every download it takes some time before I can access it while it verifies the download for a long long time. Please let this be a separate option from SmartScreen in IE9 RTM.

  28. joshuatee says:

    course its gonna be working better in firefox. arent they using googles location services by default? google has been collecting OUR data for years.The only problem is some of us do try to stay away from google for some obvious reasons. Google's become the true empire of evil nowadays… ;(

    My personal hope is that bing is improving quickly which might help google rethink their questionable(at least) practices

  29. Aethec says:

    +1 to the window.prompt() thing – Windows has got enough outdated dialogs, no need for one more.

    @Ryan Gasparini : IndexedDB is a draft, thus they put it in HTML5 Labs: html5labs.interoperabilitybridges.com

  30. Not even close says:

    Location is 10's of miles off. Funny thing though – in Chrome, it's more accurate – well, it gives a big radius over the city which I expect because we're on a major network node in the city but IE9 gives my location in the SEA – beside a town 30 miles away

  31. IE 9 RTW (RTM) date set says:

    The announcement is here: windowsteamblog.com/…/come-celebrate-the-beauty-of-the-web.aspx

    The date: March 14th 2011

  32. 6205 says:

    IE 9 RTW (RTM) date set@: i dont think so, unless they wanna release product full of bugs..

  33. IE 9 RTW (RTM) date set says:

    …at least they have left their (still) largest competitor behind: FF. That is why the folks over at Mozilla use some fraudulent "tests" that really say nothing to compare to their offerings. See blogs.msdn.com/…/user-experiences-listen-learn-refine.aspx if you need an explaination!

  34. todd says:

    @IE 9 RTW (RTM) date set – Uhm, no.

    They said: "On Monday, March 14th at SXSW, we’ll be celebrating the developers and designers who are making that beautiful web a reality" – thats not an RTM date announcement.  However you are close.

    The official launch will be at Mix 2011 on April 12th.

    and as always, it is RTM, not RTW I really wish people would give up on trying to make "rtw" a "thing".

    @6205 – I agree! they have a ton of work left to do… hopefully March is ***VERY*** productive!

  35. todd says:

    @IE 9 RTW (RTM) date set – left FF behind? are you nuts? have you compared browsers?  IE9 is a massive leap forward no doubt… and by (ab)using the GPU they've made massive performance gains, but for usability, features, extensions… you can't beat Chrome/Firefox – IE is still a legacy browser.

  36. Paul Caesar says:

    I'm in Scotland UK, but shows as London as that is where my ISP is. Developers could just look up IP address on RIPE to get a location and bypass the API surely?

  37. Not very accurate... says:

    Your location service missed my location by about 70km and I see no way to correct it.

  38. @ithoughts_de says:

    The page also works nice in Firefox 3.6.13

    :-p

  39. Noel says:

    Just put out an IE9 for XP with faster Javascript, more CSS3 and HTML5 support and fix all the bugs. How hard can it be for a giant company like Microsoft? MS definitely have become too big to care about half the web it seems.

  40. hAl says:

    About 50 meters away.

    Acceptable.

  41. marybranscombe says:

    it gets my location so accurately I refuse to screenshot it (for a false sense of security ;-)

  42. The Reason says:

    The reason its location guess is better for some than others is literally a case of if you're on Wifi or not.  If no wifi, all they have is what your ISP has registered as the location for their IP block.  Some ISPs don't block them down into small areas, so you could have a London based ISP and have your location shown as London if in Scotland.  

    With Wifi data, they literally snoop all hotspots in the area and based on a bit of funky math, pinpoint you.  So if you're on Wifi, but in an area with few other Wifi networks, it'll still be a bad location.

    For most cases where a website captures your location, though, I'd imagine exact precision isn't required.  While showing which movie are available nearby might need at least to know which is the nearest cinema, a site just letting you know whats going on in your City, doesn't need to be so precise.

    At least, I think so…

  43. Doug says:

    @TheReason Yes of course – but for me (and several others above), IE is failing in the same locations where the competition can (and is) pinpointing people.

  44. Doug says:

    Also, can you please remove the word "track" from the prompt unless the site is actually trying to track? (i.e. asking multiple times in a session) "know" might be a better word for one-shot requests.

  45. joshuatee says:

    i guess tracking happens to occur over a single session? :D

  46. Aethec says:

    @The Reason >> I don't think so. It locates me into a pretty small town but I'm in one of the biggest cities in Switzerland.

    Strangely, it *is* better than Firefox 3.6, which locates me even further from my actual location.

  47. EricLaw says:

    @gavin: You can't opt-out of application reputation without disabling SmartScreen entirely. Typically, the "slow" operation in the security phase of download is signature verification and/or AV scanning.

  48. Doug says:

    @joshuatee fair enough, I suppose a website could track you over multiple visits if you gave permission each time. But in many cases e.g. for websites that aren't giving turn by turn directions, and simply want a one-off location, having the browser use the word track is misleading, scary and over the top. Share/know/informed/be told do not have the same connotations and would be much better to use.

    "Why are you trying to track me?"

    "I'm not tracking you, I'm just asking for your location so I can find your nearest store (you are on the find a store page)"

    "My computer says you're tracking me, why are you lying to me? Your competitors don't spy on me…"

    etc

  49. Aethec says:

    (I know I should use Connect, but the "Send Feedback" menu doesn't work on my system…huh)

    IE x64 takes 1257 ms to finish Sunspider, whereas IE x86 is at 280 ms. That's a pretty huge difference…any idea where it might come from? (no addons are enabled, and IE is at its default settings except for a small custom CSS file whose only purpose is to remove dotted borders from clicked links)

  50. joshuatee says:

    no doug, im givin into you for free

  51. joshuatee says:

    pigheadednessless vs pigheadedlessness

    :D

  52. Zbigniew Sandler says:

    Meh. It works better in Firefox 4. Firefox 4's notification mechanism is stronger than IE9's.

  53. Command Bar says:

    There are two "Manage Addons" buttons and a missing "Developer Tools" button.

  54. Aethec says:

    By the way, some buttons in IE9 RC have no width and no height (i.e. they are small dots with no text)…I hope that'll be fixed.

  55. Rob says:

    Since this is nothing that Firefox and Chrome do, and both those browsers implement far more features and properties than IE9 will, there is no need for IE9.

  56. Gill says:

    The accuracy of the IE geolocation seems to be no where near as good as Chrome or Firefox.

    Is the geolocation in IE just a "beta" feature or is this the "design complete" version and we'll have to wait to IE10 to get a fix?

  57. Richard says:

    @Rob – Why stop there? Why not get rid of one of those and only have one browser, then web development will be really easy! Who needs competition?

    Hooray for perspective!

  58. Robert says:

    "Unable to locate your position." =/

    I live in Brazil, it is a pity that he does not find.

  59. Christchurch 2011 Earthquake says:

    If you are looking for someone, or have details on the well-being of someone in the Christchurch area please search/update the information on the Google people finder:

    christchurch-2011.person-finder.appspot.com

    Here is a link to the USGS epicenter location: maps.google.com/maps

  60. Tim Acheson says:

    Nice!

    But you MUST make IE9 work on Windows XP! Even if it requires SP3.

    The single biggest problem deterring adoption and developers is market-penetration.

    The excuse about the nature of the OS is lame — I remember IE4, it changed the OS. It may not be as easy to provide IE9 on XP, but it is worth while, in fact it is essential.

  61. George Foxworthy says:

    @Tim Acheson: "But you MUST make IE9 work on Windows XP! Even if it requires SP3."

    It won't happen. Opera, Firefox and Chrome all still work on Windows XP though. In this regard Opera, Mozilla and Google have better support for Windows than Microsoft does.

  62. Not exactly... says:

    It is not exatly. I am in Nordsæter in Norway, and it says i am in Stange, many kilometres away. But when I am in Drøbak, it fails with around houndred metres.

  63. DavidPaulo says:

    IE9 RC crashes on my windows vista. everytime i click a link, the tab crashes. i had to install chrome in order to post this…

  64. DavidPaulo says:

    Interestingly, if I don´t click  links and navigate only in the address bar, the browser works fine …

  65. jccondor says:

    I have tried several demos and found that the different browsers have implementations. Specifficly in regard to the location service they use. Because of the amount of data that each of these have collected these are the ones that are actually in charge of solving the triangulation of your location. With wifi it seems to be a mix of mac, ip database. Could you further explain how this is implemented in IE, and by the Microsoft Location Service?

    Thanks,

  66. sodaxp says:

    I don't see yet Lima, Peru in your test page  :(

  67. Stijn says:

    Reporting this issue in IE8 Javascript engine here because I have found no other place to report it.

    In IE8 and maybe lower versions as well it seems that the equals operator is not always symmetric, meaning that even though a == b yields true, still b == a will yield false.

    I have described this behaviour on my blog and created a test page for it. It works as I would expect in Firefox and Google Chrome, but fails in Internet Explorer 8.

    Maybe you guys could fix this in IE8 still? Or at least make sure it doesn't happen in IE9?

    I would love to test it in IE9 but I don't have the beta and can't get it as I need to test in IE8 regularly and you can't run them side by side afaik.

    Here is the blog entry describing the issue:

    stijndewitt.wordpress.com/…/equals-operator-not-symmetric-in-ie8

    I welcome comments with test results!

    Here is the test page:

    members.chello.nl/…/test.html

  68. Mathew says:

    @Doug – I agree the word track implies snooping on the user regularly.  If a site just wants to pinpoint you on a map, that's just "sharing" information about your position.  Keeping the word track in the message would be a major mistake.

  69. Feets says:

    @DavidPaulo. Please try the methods described in our Answers Forum post. Link here: http://bit.ly/fixcrash

  70. The7down says:

    So cool! But FF4.0 have a cleav address bar.

  71. Sandeep Deo, Program Manager, Microsoft Location Service says:

    We are very excited about the Geolocation support in IE9 that is powered by our location service. Our location service supports both IP and Wi-Fi based positioning for IE9's Geolocation platform. We have received great user feedback so far which is very encouraging . We are working hard to continually improve the accuracy and coverage of our location service and to keep our Geolocation database continually updated. This will happen over time as more people start using our location service.

    Please continue to provide your valuable feedback about the Geolocation service. We greatly appreciate it.