I use the following code to get the GPS coordinates on a Android/iOS device from a mobisite but it doesn't work on WP7.
How can I get a user's GPS coordinates in IE on a WP7 device? (I am testing on a Samsung Omnia 7).
<script language="javascript">
navigator.geolocation.getCurrentPosition(findLocation, noLocation);
function findLocation(position)
{
var lat = position.coords.latitude;
var lng = position.coords.longitude;
document.getElementB开发者_JAVA技巧yId("result").innerHTML = "Lat: " + lat + ", Long: " + lng;
}
function noLocation()
{
document.getElementById("result").innerHTML = "Unable to get location";
}
</script>
What happens when you run this on a WP7 device?
When are you running this? Be sure to do it after the document has loaded.
If you're running this inside a WebBrowser control then be sure to set IsGeolocationEnabled to true.
ALso check that location is enabled on the device and in IE.
X-Ref http://msdn.microsoft.com/en-gb/library/gg593067.aspx
The error callback should contain a positionError parameter which may give you more information about any error.
精彩评论