Freigeben über


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

  • Anonymous
    February 17, 2011
    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?

  • Anonymous
    February 17, 2011
    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.

  • Anonymous
    February 17, 2011
    The comment has been removed

  • Anonymous
    February 17, 2011
    The comment has been removed

  • Anonymous
    February 17, 2011
    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?

  • Anonymous
    February 17, 2011
    Nice! Now please implement web workers, web sockets, html5 forms, text-shadow, border-image and multi-columns!

  • Anonymous
    February 17, 2011
    yay!

  • Anonymous
    February 17, 2011
    The comment has been removed

  • Anonymous
    February 17, 2011
    @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!

  • Anonymous
    February 17, 2011
    @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.

  • Anonymous
    February 17, 2011
    @EricLaw: The post has a link to a W3C API Specification. Isn't that enough to make it a developer post? :-)

  • Anonymous
    February 17, 2011
    Pls add offline application manifest support to the browser!

  • Anonymous
    February 17, 2011
    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...

  • Anonymous
    February 17, 2011
    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).

  • Anonymous
    February 17, 2011
    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?

  • Anonymous
    February 17, 2011
    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!

  • Anonymous
    February 17, 2011
    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.

  • Anonymous
    February 17, 2011
    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?

  • Anonymous
    February 17, 2011
    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.

  • Anonymous
    February 17, 2011
    @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

  • Anonymous
    February 17, 2011
    IE9 located my house pretty much perfectly, it was basically pointing right at my router lol.

  • Anonymous
    February 17, 2011
    The comment has been removed

  • Anonymous
    February 17, 2011
    Microsoft buildings form patterns?

  • Anonymous
    February 17, 2011
    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)

  • Anonymous
    February 17, 2011
    The comment has been removed

  • Anonymous
    February 17, 2011
    If only we had IndexedDB so we can actually do something with that data. ^_^

  • Anonymous
    February 17, 2011
    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.

  • Anonymous
    February 17, 2011
    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

  • Anonymous
    February 17, 2011
    +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

  • Anonymous
    February 17, 2011
    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

  • Anonymous
    February 17, 2011
    The announcement is here: windowsteamblog.com/.../come-celebrate-the-beauty-of-the-web.aspx The date: March 14th 2011

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

  • Anonymous
    February 17, 2011
    ...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!

  • Anonymous
    February 17, 2011
    @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!

  • Anonymous
    February 17, 2011
    The comment has been removed

  • Anonymous
    February 17, 2011
    The comment has been removed

  • Anonymous
    February 17, 2011
    Your location service missed my location by about 70km and I see no way to correct it.

  • Anonymous
    February 18, 2011
    The page also works nice in Firefox 3.6.13 :-p

  • Anonymous
    February 18, 2011
    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.

  • Anonymous
    February 18, 2011
    About 50 meters away. Acceptable.

  • Anonymous
    February 18, 2011
    it gets my location so accurately I refuse to screenshot it (for a false sense of security ;-)

  • Anonymous
    February 18, 2011
    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...

  • Anonymous
    February 18, 2011
    @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.

  • Anonymous
    February 18, 2011
    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.

  • Anonymous
    February 18, 2011
    i guess tracking happens to occur over a single session? :D

  • Anonymous
    February 18, 2011
    @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.

  • Anonymous
    February 18, 2011
    @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.

  • Anonymous
    February 18, 2011
    @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

  • Anonymous
    February 18, 2011
    (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)

  • Anonymous
    February 18, 2011
    no doug, im givin into you for free

  • Anonymous
    February 18, 2011
    pigheadednessless vs pigheadedlessness :D

  • Anonymous
    February 18, 2011
    The comment has been removed

  • Anonymous
    February 18, 2011
    Meh. It works better in Firefox 4. Firefox 4's notification mechanism is stronger than IE9's.

  • Anonymous
    February 18, 2011
    There are two "Manage Addons" buttons and a missing "Developer Tools" button.

  • Anonymous
    February 18, 2011
    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.

  • Anonymous
    February 19, 2011
    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.

  • Anonymous
    February 20, 2011
    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?

  • Anonymous
    February 20, 2011
    @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!

  • Anonymous
    February 20, 2011
    "Unable to locate your position." =/ I live in Brazil, it is a pity that he does not find.

  • Anonymous
    February 21, 2011
    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

  • Anonymous
    February 21, 2011
    The comment has been removed

  • Anonymous
    February 21, 2011
    @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.

  • Anonymous
    February 22, 2011
    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.

  • Anonymous
    February 22, 2011
    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...

  • Anonymous
    February 22, 2011
    Interestingly, if I don´t click  links and navigate only in the address bar, the browser works fine ...

  • Anonymous
    February 22, 2011
    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,

  • Anonymous
    February 23, 2011
    I don't see yet Lima, Peru in your test page  :(

  • Anonymous
    February 23, 2011
    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

  • Anonymous
    February 23, 2011
    @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.

  • Anonymous
    February 24, 2011
    @DavidPaulo. Please try the methods described in our Answers Forum post. Link here: http://bit.ly/fixcrash

  • Anonymous
    February 24, 2011
    So cool! But FF4.0 have a cleav address bar.

  • Anonymous
    March 01, 2011
    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.