0

I try use tracking with WP8 using html5, to get my location and show it this the code, but no problem

    <script type="text/javascript">
    var watchID = 0;

    function startLocationTracking() {
        if (navigator.geolocation) {
            var messagedialogpopup = new Windows.UI.Popups.MessageDialog
                    ("Your phone supports GeoLocation");
            messagedialogpopup.showAsync();
            watchID = navigator.geolocation.watchPosition(showCurrentLocation, errorHandler, { enableHighAccuracy: true });
        } else {
            var messagedialogpopup = new Windows.UI.Popups.MessageDialog
                    ("Your phone does not support GeoLocation.");
            messagedialogpopup.showAsync();
        }
    }

    function showCurrentLocation(position) {
        document.getElementById("mylocation").innerHTML = "Tracking your position --> Current Latitude : " + position.coords.latitude + " , Longitude : " + position.coords.longitude;
    }

    function errorHandler(error) {
        var messagedialogpopup = new Windows.UI.Popups.MessageDialog
                    ("Error while retrieving current position. Error code: " + error.code + ",Message: " + error.message);

    }

    function stopLocationTracking() {
        if (watchID > 0) {
            navigator.geolocation.clearWatch(watchID);
            var messagedialogpopup = new Windows.UI.Popups.MessageDialog
                    ("Stopped Tracking Location");
            messagedialogpopup.showAsync();
        }
    }

    </script>

</head>
<body class="phone">

    <div id="main">

        <input type="button" value="Start Tracking Me" onclick="startLocationTracking()" />
        <input type="button" value="Stop Tracking Me" onclick="stopLocationTracking()" />
        <br />
        <div id="mylocation"></div>
    </div>

</body>
</html>

it shows this screen but the problem is not showing the result. it supposes to show something like this : Tracking your position --> Current Latitude : 34.8346549 , Longitude : 10.7518134 enter image description here

Amin
  • 172
  • 2
  • 12
  • When you press the "Start Tracking Me" button are you promoted to allow the sharing of your location? If not then there is likely something else wrong. Have you enabled location sharing ( ID_CAP_LOCATION) in the app manifest? If not then this is likely your issue. I have found that when this is not enabled JavaScript silently fails. – rbrundritt Aug 24 '14 at 09:10
  • yes, that's the role of the app to share my location,my location is enabled and I use directly on my phone lumia 820,its work with browser, any browser. – Amin Aug 24 '14 at 10:18
  • @rbrundritt , I want to track my route on map using bing map, and I color it, so any help, by the way I succeed to use bing map JavaScript on WP8.1 html5 – Amin Aug 24 '14 at 10:29
  • Take a look at this article for adding a bing map to your app http://msdn.microsoft.com/en-us/library/hh852186.aspx – sebagomez Aug 29 '14 at 11:39
  • @ sebagomez , I know it, and I already have my solution to add a bing map on WP8.1 using html – Amin Aug 30 '14 at 10:50

0 Answers0