locked
WinJS: geolocation raises "unspecified error"

    Question

  • I currently got an issue with geolocation. It raises me a "WinRTError: Unspecified error" when I try to geolocate the user.

    Here is my code:

    // Where I use my geolocate method...
    if (!parameters.cp) {
        promise = me.geolocate().then(function (position) {
            if (position) {
                parameters.lat = position.coordinate.latitude;
                parameters.lon = position.coordinate.longitude;
            }
    }
    
    // The geolocate method
    geolocate: function () {
    
        var location = new Windows.Devices.Geolocation.Geolocator();
    
        if (location) {
            return location.getGeopositionAsync().then(function (position) {
                return WinJS.Promise.wrap(position);
            }, function (error) {
                Acme.Alert.alert("An error occured: " + error);
            });
        }
    
        return WinJS.Promise.wrap(false);
    
    },

    Location is correctly set. Yet, it never enters inside the getGeopositionAsync then function.

    Have you any idea where it may come from? 

    I also tried with the provided sample for detecting geolocation. But it does not work neither:

        Location Status:Data from location services is currently unavailable.
        Error Message: Unspecified error 

    The capability Location is correctly checked.

    I am using Windows8 Gold retail.

    Thanks for your help!

    Wednesday, September 05, 2012 7:39 AM

Answers

  • What country are you in?

    The error message simply means that your position cannot be obtained for some reason.

    -Jeff


    Jeff Sanders (MSFT)

    • Marked as answer by Dino He Monday, September 24, 2012 7:37 AM
    Friday, September 07, 2012 1:06 PM
    Moderator

All replies

  • Can you try this sample are report back?

    http://code.msdn.microsoft.com/windowsapps/Geolocation-2483de66

    -Jeff


    Jeff Sanders (MSFT)

    Wednesday, September 05, 2012 3:48 PM
    Moderator
  • I am unable to launch the sample:

        Could not find SDK "Microsoft.WinJS.1.0, Version=1.0"
        C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets

    Is it a wrong configuration of my project?

    Thursday, September 06, 2012 10:10 AM
  • No the project is included in the sample and that should run fine.

    Are you running Windows 8 RTM and Visual Studio Express 2012 (RTM)?

    -Jeff


    Jeff Sanders (MSFT)

    Thursday, September 06, 2012 11:56 AM
    Moderator
  • I am using RTM Gold Release- English version with Visual Studio 11 Beta Ultimate. I will download Visual Studio 2012, a more up-to-date version.

    Thursday, September 06, 2012 1:02 PM
  • I just installed Visual Studio 2012. The application is now correctly launching. Yet, I still got Unspecified error when I am trying second item (Get position).

    Seems the same issue. :/


    Thursday, September 06, 2012 1:58 PM
  • I tried with HTML5 and following code:

    navigator.geolocation.getCurrentPosition(function (position) {
        // Breakpoint
    }, function (error) {
        // Breakpoint
    });

    Still does not work. I got the error message: "The current position could not be determined".

    Making extra search, I found this blog post: http://social.msdn.microsoft.com/Forums/en-US/winappswithhtml5/thread/6cf353ff-96cd-4853-b842-fb1d606f7251/

    My location capability is correctly set. Is there any issue with my Manifest?

    <?xml version="1.0" encoding="utf-8"?>
    <Package xmlns="http://schemas.microsoft.com/appx/2010/manifest">
      <Identity Name="7ea6e9e9-d88d-4d9f-a124-ea8f4fad1b9d" Version="1.0.0.14" Publisher="CN=xxx" />
      <Properties>
        <DisplayName>xxx</DisplayName>
        <PublisherDisplayName>xxx</PublisherDisplayName>
        <Logo>images\storelogo.png</Logo>
      </Properties>
      <Prerequisites>
        <OSMinVersion>6.2.1</OSMinVersion>
        <OSMaxVersionTested>6.2.1</OSMaxVersionTested>
      </Prerequisites>
      <Resources>
        <Resource Language="x-generate" />
      </Resources>
      <Applications>
        <Application Id="App" StartPage="default.html">
          <VisualElements DisplayName="xxx" Logo="images\logo.png" SmallLogo="images\smalllogo.png" Description="xxx" ForegroundText="light" BackgroundColor="#D80424">
            <DefaultTile ShowName="allLogos" />
            <SplashScreen Image="images\splash-screen.png" />
          </VisualElements>
        </Application>
      </Applications>
      <Capabilities>
        <Capability Name="internetClient" />
        <DeviceCapability Name="location" />
      </Capabilities>
    </Package>

    I tried to enable/disable geolocation permissions (in both the application and the system). No effect.

    Friday, September 07, 2012 10:26 AM
  • What country are you in?

    The error message simply means that your position cannot be obtained for some reason.

    -Jeff


    Jeff Sanders (MSFT)

    • Marked as answer by Dino He Monday, September 24, 2012 7:37 AM
    Friday, September 07, 2012 1:06 PM
    Moderator
  • I am in Paris, France. So, I think it is geolocalizable. ;)

    I found a solution. It seems it was an issue with Visual Studio version. Indeed, I downloaded Visual Studio Express 2012, create a new project and copy/paste each source file individually. All is working now. May be a compatibility break into project description file between the two versions?

    Monday, September 24, 2012 7:42 AM