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.
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...
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.
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
function getLocation() {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(showPosition);
} else {
x.innerHTML = "Geolocation is not supported by this browser.";
}
}
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?)
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 :
None
0 Points
4 Posts
Unable to get systems location
Mar 13, 2018 12:02 PM|VDE___|LINK
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.
All-Star
48570 Points
18081 Posts
Re: Unable to get systems location
Mar 13, 2018 12:31 PM|PatriceSc|LINK
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.
None
0 Points
4 Posts
Re: Unable to get systems location
Mar 14, 2018 04:11 AM|VDE___|LINK
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.
Star
8670 Points
2882 Posts
Re: Unable to get systems location
Mar 14, 2018 06:23 AM|Cathy Zou|LINK
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
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
None
0 Points
4 Posts
Re: Unable to get systems location
Mar 14, 2018 07:02 AM|VDE___|LINK
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.
Contributor
5961 Points
2468 Posts
Re: Unable to get systems location
Mar 14, 2018 11:29 PM|KathyW|LINK
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?)
None
0 Points
4 Posts
Re: Unable to get systems location
Mar 15, 2018 06:18 AM|VDE___|LINK
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.
Contributor
5961 Points
2468 Posts
Re: Unable to get systems location
Mar 15, 2018 06:55 AM|KathyW|LINK
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.
All-Star
48570 Points
18081 Posts
Re: Unable to get systems location
Mar 15, 2018 09:47 AM|PatriceSc|LINK
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.