private async void InitializeMap() { try { #if WINDOWS_APP myMap.Credentials = "AgRNfxvPZHZijcTen8d_YdjOczkXbxKLoIegltoNSdqhGqHmq5PpeZxDvyFw4HM6"; myMap.ZoomLevel = 17; myMap.MapType = MapType.Road; Pushpin pushpin = new Pushpin(); pushpin.Background = new SolidColorBrush(Colors.Blue); MapLayer.SetPosition(pushpin, new Bing.Maps.Location(report.latitude, report.longitude)); myMap.Children.Add(pushpin); myMap.Center = new Bing.Maps.Location(report.latitude, report.longitude); var client = new HttpClient(); Uri Uri = new Uri("https://maps.googleapis.com/maps/api/geocode/json?latlng=" + report.latitude + "," + report.longitude + "&key=AIzaSyDeJZgbdA56eyfwk660AZY0HrljWgpRtVc"); var response = await client.GetAsync(Uri); var result = await response.Content.ReadAsStringAsync(); MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(result)); DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(RootObject)); var list = serializer.ReadObject(ms); RootObject jsonResponse = list as RootObject; AddressTB.Text = jsonResponse.results[0].formatted_address; #endif #if WINDOWS_PHONE_APP myMap.MapServiceToken = "AgRNfxvPZHZijcTen8d_YdjOczkXbxKLoIegltoNSdqhGqHmq5PpeZxDvyFw4HM6"; myMap.ZoomLevel = 10; var pin = new Grid() { Width = 30, Height = 30, Margin = new Windows.UI.Xaml.Thickness(-12) }; pin.Children.Add(new Ellipse() { Fill = new SolidColorBrush(Colors.Blue), Stroke = new SolidColorBrush(Colors.White), StrokeThickness = 3, Width = 30, Height = 30 }); BasicGeoposition location = new BasicGeoposition(); location.Latitude = report.latitude; location.Longitude = report.longitude; MapControl.SetLocation(pin, new Geopoint(location)); myMap.Center = new Geopoint(location); myMap.Children.Add(pin); #endif } catch (Exception e) { } }
public async void InitializeMap() { try { #if WINDOWS_APP myMap.Credentials = "AgRNfxvPZHZijcTen8d_YdjOczkXbxKLoIegltoNSdqhGqHmq5PpeZxDvyFw4HM6"; myMap.ZoomLevel = 10; myMap.MapType = MapType.Road; Geolocator geolocator = new Geolocator(); geolocator.DesiredAccuracy = PositionAccuracy.High; Geoposition currentPosition = await geolocator.GetGeopositionAsync(TimeSpan.FromMinutes(1), TimeSpan.FromSeconds(10)); myMap.Center = new Bing.Maps.Location(currentPosition.Coordinate.Latitude, currentPosition.Coordinate.Longitude); pin = new DraggablePin(myMap); //Set the location of the pin to the center of the map. Bing.Maps.MapLayer.SetPosition(pin, myMap.Center); //Set the pin as draggable. pin.Draggable = true; //Attach to the drag event of the pin. pin.DragEnd += Pin_Dragged; //Add the pin to the map. myMap.Children.Add(pin); myMap.PointerPressedOverride += myMap_PointerPressedOverride; var client = new HttpClient(); Uri Uri = new Uri("https://maps.googleapis.com/maps/api/geocode/json?latlng=" + currentPosition.Coordinate.Latitude + "," + currentPosition.Coordinate.Longitude + "&key=AIzaSyDeJZgbdA56eyfwk660AZY0HrljWgpRtVc"); var response = await client.GetAsync(Uri); var result = await response.Content.ReadAsStringAsync(); MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(result)); DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(RootObject)); var list = serializer.ReadObject(ms); RootObject jsonResponse = list as RootObject; AddressTbl.Text = jsonResponse.results[0].formatted_address; #endif #if WINDOWS_PHONE_APP myMap.MapServiceToken = "AgRNfxvPZHZijcTen8d_YdjOczkXbxKLoIegltoNSdqhGqHmq5PpeZxDvyFw4HM6"; myMap.ZoomLevel = 10; pin = new Grid() { Width = 30, Height = 30, Margin = new Windows.UI.Xaml.Thickness(-12) }; pin.Children.Add(new Ellipse() { Fill = new SolidColorBrush(Colors.Blue), Stroke = new SolidColorBrush(Colors.White), StrokeThickness = 3, Width = 30, Height = 30 }); // Get my current location. Geolocator myGeolocator = new Geolocator(); Geoposition myGeoposition = await myGeolocator.GetGeopositionAsync(); Geocoordinate myGeocoordinate = myGeoposition.Coordinate; MapControl.SetLocation(pin, myGeocoordinate.Point); myMap.Center = myGeocoordinate.Point; myMap.Children.Add(pin); #endif } catch (Exception e) { } }
private async void loadData() { try { Geolocator geolocator = new Geolocator(); geolocator.DesiredAccuracy = PositionAccuracy.High; Geoposition currentPosition = await geolocator.GetGeopositionAsync(TimeSpan.FromMinutes(1), TimeSpan.FromSeconds(10)); var client = new HttpClient(); Uri Uri = new Uri("https://maps.googleapis.com/maps/api/geocode/json?latlng=" + currentPosition.Coordinate.Latitude + "," + currentPosition.Coordinate.Longitude + "&key=AIzaSyDeJZgbdA56eyfwk660AZY0HrljWgpRtVc"); var response = await client.GetAsync(Uri); var result = await response.Content.ReadAsStringAsync(); MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(result)); DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(RootObject)); var list = serializer.ReadObject(ms); RootObject jsonResponse = list as RootObject; #if WINDOWS_APP TextBlock FirstNameTbl = FindChildControl <TextBlock>(ProfileSection, "FirstNameTbl") as TextBlock; #endif FirstNameTbl.Text = user.fname; #if WINDOWS_APP TextBlock LastNameTbl = FindChildControl <TextBlock>(ProfileSection, "LastNameTbl") as TextBlock; #endif LastNameTbl.Text = user.lname; #if WINDOWS_APP TextBlock LocationTbl = FindChildControl <TextBlock>(ProfileSection, "LocationTbl") as TextBlock; #endif LocationTbl.Text = jsonResponse.results[0].formatted_address; #if WINDOWS_APP TextBlock positionTbl = FindChildControl <TextBlock>(ProfileSection, "positionTbl") as TextBlock; #endif positionTbl.Text = user.position; var following = await App.MobileService.GetTable <Follow>().Where(p => p.follower_hw_id == user.id).ToListAsync(); #if WINDOWS_APP TextBlock followingTbl = FindChildControl <TextBlock>(ProfileSection, "followingTbl") as TextBlock; #endif followingTbl.Text = following.Count + ""; var follower = await App.MobileService.GetTable <Follow>().Where(p => p.following_hw_id == user.id).ToListAsync(); #if WINDOWS_APP TextBlock followersTbl = FindChildControl <TextBlock>(ProfileSection, "followersTbl") as TextBlock; #endif followersTbl.Text = follower.Count + ""; var disaster_rp = await App.MobileService.GetTable <Disaster_Report>().Where(p => p.hw_id == user.id).ToListAsync(); var disease_rp = await App.MobileService.GetTable <Disease_Report>().Where(p => p.hw_id == user.id).ToListAsync(); var rf_rp = await App.MobileService.GetTable <Risk_Factor_Report>().Where(p => p.hw_id == user.id).ToListAsync(); #if WINDOWS_APP TextBlock myreportsTbl = FindChildControl <TextBlock>(ProfileSection, "myreportsTbl") as TextBlock; #endif int no_myreport = disaster_rp.Count + disease_rp.Count + rf_rp.Count; myreportsTbl.Text = no_myreport + ""; #if WINDOWS_APP myMap = FindChildControl <Map>(MapSection, "myMap") as Map; myMap.Credentials = "AgRNfxvPZHZijcTen8d_YdjOczkXbxKLoIegltoNSdqhGqHmq5PpeZxDvyFw4HM6"; myMap.ZoomLevel = 10; myMap.MapType = MapType.Road; myMap.Width = 420; myMap.Height = 480; myMap.Center = new Bing.Maps.Location(currentPosition.Coordinate.Latitude, currentPosition.Coordinate.Longitude); if (user.position == "Village Health Volunteer" || user.position == "Tambon Health Promoting Hospital Officer" || user.position == "District Public Health Officer") { Uri = new Uri("https://maps.googleapis.com/maps/api/geocode/json?latlng=" + user.latitude + "," + user.longitude + "&key=AIzaSyDeJZgbdA56eyfwk660AZY0HrljWgpRtVc"); response = await client.GetAsync(Uri); result = await response.Content.ReadAsStringAsync(); ms = new MemoryStream(Encoding.UTF8.GetBytes(result)); serializer = new DataContractJsonSerializer(typeof(RootObject)); list = serializer.ReadObject(ms); jsonResponse = list as RootObject; user_postcode = jsonResponse.results[0].address_components[jsonResponse.results[0].address_components.Count - 1].long_name; } loadRF(); loadDisaster(); loadDisease(); #endif #if WINDOWS_PHONE_APP InitializeMap(); #endif loadReports(); loadNoti(); } catch (Exception e) { } }
private async void loaddata() { try { var client = new HttpClient(); Uri Uri = new Uri("https://maps.googleapis.com/maps/api/geocode/json?latlng=" + user.latitude + "," + user.longitude + "&key=AIzaSyDeJZgbdA56eyfwk660AZY0HrljWgpRtVc"); var response = await client.GetAsync(Uri); var result = await response.Content.ReadAsStringAsync(); MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(result)); DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(RootObject)); var list = serializer.ReadObject(ms); RootObject jsonResponse = list as RootObject; user_postcode = jsonResponse.results[0].address_components[jsonResponse.results[0].address_components.Count - 1].long_name; var today = DateTime.Today; var month = new DateTime(today.Year, today.Month - 1, 1); #if WINDOWS_APP DatePicker StartDatePicker = FindChildControl <DatePicker>(ResponsibleAreaSection, "StartDatePicker") as DatePicker; #endif StartDatePicker.Date = month; Geolocator geolocator = new Geolocator(); geolocator.DesiredAccuracy = PositionAccuracy.High; Geoposition currentPosition = await geolocator.GetGeopositionAsync(TimeSpan.FromMinutes(1), TimeSpan.FromSeconds(10)); #if WINDOWS_APP myMap = FindChildControl <Map>(ResponsibleAreaSection, "myMap") as Map; myMap.Credentials = "AgRNfxvPZHZijcTen8d_YdjOczkXbxKLoIegltoNSdqhGqHmq5PpeZxDvyFw4HM6"; myMap.ZoomLevel = 10; myMap.MapType = MapType.Road; myMap.Center = new Bing.Maps.Location(currentPosition.Coordinate.Latitude, currentPosition.Coordinate.Longitude); loadgraph(); ToggleButton AllBtn = FindChildControl <ToggleButton>(ResponsibleAreaSection, "AllBtn") as ToggleButton; ToggleButton CholeraBtn = FindChildControl <ToggleButton>(ResponsibleAreaSection, "CholeraBtn") as ToggleButton; ToggleButton RotavirusBtn = FindChildControl <ToggleButton>(ResponsibleAreaSection, "RotavirusBtn") as ToggleButton; ToggleButton SalmonellaBtn = FindChildControl <ToggleButton>(ResponsibleAreaSection, "SalmonellaBtn") as ToggleButton; ToggleButton ShigellaBtn = FindChildControl <ToggleButton>(ResponsibleAreaSection, "ShigellaBtn") as ToggleButton; ToggleButton OtherBtn = FindChildControl <ToggleButton>(ResponsibleAreaSection, "OtherBtn") as ToggleButton; AllBtn.IsEnabled = false; CholeraBtn.IsChecked = false; RotavirusBtn.IsChecked = false; SalmonellaBtn.IsChecked = false; ShigellaBtn.IsChecked = false; OtherBtn.IsChecked = false; check_all = 1; loadDisease(); loadDisaster(); loadRF(); #endif #if WINDOWS_PHONE_APP InitializeMap(); #endif } catch (Exception ex) { throw ex; } }