locked
Unable to get systems location RRS feed

  • Question

  • User182103591 posted

    I am facing problem to get my system location with the help of geolocation. In my company’s windows 10 system I am unable to get latitude and longitude while connecting to company’s network, for some systems like windows 7 system it gets latitude and longitude. What could be the reason? Location service is ‘On’ on my system. Consider this as urgent. Thanks in advance.

    Tuesday, March 13, 2018 12:02 PM

All replies

  • User753101303 posted

    Hi,

    Always try to tell what happens exactly rather than something vague such as "I'm unable to get". Do you mean it is blocked or that you get a value which seems wrong? Try maybe also F12 Console. For example a browser should show a message if you try to use http and that https is required for this to work etc...

    The basic idea is to not focus on the fact that it "doesn't work" but instead on what actually happens. What happens if you try https://www.w3schools.com/html/tryit.asp?filename=tryhtml5_geolocation ? For example do you see a question that asks if you allow that ?

    BTW marking a post as "urgent" is useless and sometimes considered rude.

    Tuesday, March 13, 2018 12:31 PM
  • User182103591 posted

    Hi,

    Here is more explanation, I am getting value of latitude and longitude as NAN(https://www.w3schools.com/html/tryit.asp?filename=tryhtml5_geolocation) on my windows 10 system which is in company network, but some of systems giving value in numbers in same network(those systems are windows 7 systems).   For above mentioned link it does not ask me question if to allow to track location.

    Wednesday, March 14, 2018 4:11 AM
  • User-707554951 posted

    Hi vde

    What code you used to get location of system?

    You could consider trying the following ways provide in the following links:

    https://forums.asp.net/t/1952726.aspx?Get+user+location+by+IP+address’

    https://stackoverflow.com/a/36742675/9143922

    Best regards

    Cathy

    Wednesday, March 14, 2018 6:23 AM
  • User182103591 posted

    Hi,

    I am using HTML5 geolocation code,

    <!DOCTYPE html>
    <html>
    <body>

    <p>Click the button to get your coordinates.</p>

    <button onclick="getLocation()">Try It</button>

    <p id="demo"></p>

    <script>
    var x = document.getElementById("demo");

    function getLocation() {
        if (navigator.geolocation) {
            navigator.geolocation.getCurrentPosition(showPosition);
        } else {
            x.innerHTML = "Geolocation is not supported by this browser.";
        }
    }

    function showPosition(position) {
        x.innerHTML = "Latitude: " + position.coords.latitude +
        "<br>Longitude: " + position.coords.longitude;
    }
    </script>

    </body>
    </html>

    Latitude and longitude comes as NAN for some systems like windows 10, and for some systems such as windows 7 it gives data.

    Wednesday, March 14, 2018 7:02 AM
  • User409696431 posted

    I copied your page and tested it, and it gives (after asking my permission) the correct data.  I am on Win 10.  So, it's not specific to Win 10 if you are having problems.

    Now, what do you mean by you can't get the location "while connecting to company’s network"?  Connecting to a page on your company's internal site?  Something else?

    (And, just asking, but how does this question relate to asp.net, which is what this forum is about?)

    Wednesday, March 14, 2018 11:29 PM
  • User182103591 posted

    I mean above code works on some system in my office and some systems not. I am using html5 geolocation to get exact location in asp.net.

    Thursday, March 15, 2018 6:18 AM
  • User409696431 posted

    Since no one here knows what is different among those various computers, I doubt you will find an answer here.  As I said, it's not related to Win 10.

    Thursday, March 15, 2018 6:55 AM
  • User753101303 posted

    All pages are using https ? Could you confirm you looked at F12 Console as suggested ealier ?

    Also I would use a debugger statement and would inspect  other properties. If I remember Windows 10 uses a succession of methods to try to locate the machine (maybe using ultimately the IP). Maybe it could fail depending on how the PC is connected to the nerwork or which firewall rules are in place (I assume it uses some external service behind the scene?)

    Edit: it seems https://developer.mozilla.org/en-US/docs/Web/API/PositionError might return POSITION_UJNAVAILABLE if you are in the above case where the geolocation fails for some reason. In short don't strop at seeing this but use available Tools/APIs for some additional inspection to try to narrow down what happens.

    Edit2: from what I see it seems done through  a callback. Try perhaps :

    navigator.geolocation.getCurrentPosition(showPosition,function(error){alert(error.code);})

    If it shows 2 you should really maybe discuss wiht company admin to see what could block those machines from getting a position.

    Thursday, March 15, 2018 9:47 AM