Beispiel #1
0
        async private void locator_PositionChanged(Geolocator sender, PositionChangedEventArgs e)
        {
            await dispatcher.RunAsync(CoreDispatcherPriority.Normal, async() =>
            {
                Geoposition geoPosition = e.Position;

                double lat      = geoPosition.Coordinate.Point.Position.Latitude;
                double longi    = geoPosition.Coordinate.Point.Position.Longitude;
                double accuracy = geoPosition.Coordinate.Accuracy;

                var js = new leaderupdate {
                    groupid = gid, latitude = lat, longitude = longi, accuracy = accuracy
                };
                string json = JsonConvert.SerializeObject(js);

                using (HttpClient hc = new HttpClient())
                {
                    hc.DefaultRequestHeaders
                    .Accept
                    .Add(new MediaTypeWithQualityHeaderValue("application/json"));
                    var response = await hc.PostAsync(URI + "/updateleader", new StringContent(json));
                }
                funcmap();
            });
        }
Beispiel #2
0
        async private void locator_PositionChanged(Geolocator sender, PositionChangedEventArgs e)
        {
            await dispatcher.RunAsync(CoreDispatcherPriority.Normal, async () =>
            {

                Geoposition geoPosition = e.Position;

                double lat = geoPosition.Coordinate.Point.Position.Latitude;
                double longi = geoPosition.Coordinate.Point.Position.Longitude;
                double accuracy = geoPosition.Coordinate.Accuracy;

                var js = new leaderupdate { groupid = gid, latitude = lat, longitude = longi, accuracy = accuracy };
                string json = JsonConvert.SerializeObject(js);

                using (HttpClient hc = new HttpClient())
                {
                    hc.DefaultRequestHeaders
                    .Accept
                    .Add(new MediaTypeWithQualityHeaderValue("application/json"));
                    var response = await hc.PostAsync(URI+"/updateleader", new StringContent(json));
                }
                funcmap();
            });
        }