/// <summary> /// Method to set Map /// </summary> /// <param name="coordinateCollectionSub"></param> /// <param name="count"></param> private void SetMap(GPSurgeriesCollection coordinateCollectionSub, int count) { if (count == 0) { GPSurgeriesFeedData coordinate = coordinateCollectionSub.First(); if (!IsFromSaved) { MyMap.Center = new GeoCoordinate(Convert.ToDouble(coordinate.Latitude), Convert.ToDouble(coordinate.Longitude)); } else { MyMap.Center = App.LocalServiceCentreCoordinates; MyMap.ZoomLevel = App.LocalServiceZoomLevel; IsFromSaved = false; } } foreach (GPSurgeriesFeedData coordinate in coordinateCollectionSub) { IsPlotted = true; Pushpin pushpin = new Pushpin(); pushpin.Content = " +"; pushpin.Tap += new EventHandler<System.Windows.Input.GestureEventArgs>(PushpinTap); MapLayer layer = new MapLayer(); MapOverlay overlay = new MapOverlay(); pushpin.Tag = coordinate.Name + "_" + coordinate.PostCode + "_" + coordinate.Addressline1 + "_" + coordinate.Addressline2 + "_" + coordinate.Addressline3 + "_" + coordinate.Addressline4 + "_" + coordinate.Addressline5 + "_" + coordinate.Telephone + "_" + coordinate.Latitude + "_" + coordinate.Longitude; overlay.Content = pushpin; overlay.GeoCoordinate = new GeoCoordinate(Convert.ToDouble(coordinate.Latitude), Convert.ToDouble(coordinate.Longitude)); overlay.PositionOrigin = new Point(0.0, 1.0); layer.Add(overlay); MyMap.Layers.Add(layer); } }
/// <summary> /// Method to set Map /// </summary> /// <param name="coordinateCollectionSub"></param> /// <param name="count"></param> private void SetMap(GPSurgeriesCollection coordinateCollectionSub, int count) { if (count == 0) { GPSurgeriesFeedData coordinate = coordinateCollectionSub.First(); if (!IsFromSaved) { MyMap.Center = new GeoCoordinate(Convert.ToDouble(coordinate.Latitude), Convert.ToDouble(coordinate.Longitude)); } else { MyMap.Center = App.LocalServiceCentreCoordinates; MyMap.ZoomLevel = App.LocalServiceZoomLevel; IsFromSaved = false; } } foreach (GPSurgeriesFeedData coordinate in coordinateCollectionSub) { IsPlotted = true; Pushpin pushpin = new Pushpin(); pushpin.Content = " +"; pushpin.Tap += new EventHandler <System.Windows.Input.GestureEventArgs>(PushpinTap); MapLayer layer = new MapLayer(); MapOverlay overlay = new MapOverlay(); pushpin.Tag = coordinate.Name + "_" + coordinate.PostCode + "_" + coordinate.Addressline1 + "_" + coordinate.Addressline2 + "_" + coordinate.Addressline3 + "_" + coordinate.Addressline4 + "_" + coordinate.Addressline5 + "_" + coordinate.Telephone + "_" + coordinate.Latitude + "_" + coordinate.Longitude; overlay.Content = pushpin; overlay.GeoCoordinate = new GeoCoordinate(Convert.ToDouble(coordinate.Latitude), Convert.ToDouble(coordinate.Longitude)); overlay.PositionOrigin = new Point(0.0, 1.0); layer.Add(overlay); MyMap.Layers.Add(layer); } }
/// <summary> /// Method to parse xml data of organisations /// </summary> /// <param name="xmlFeed"></param> void ParseSubMenuList(XElement xmlFeed) { GPSurgeriesCollection coordinateCollectionSub = new GPSurgeriesCollection(); try { XNamespace s = "http://syndication.nhschoices.nhs.uk/services"; foreach (XElement curElement in xmlFeed.Descendants("entry").Descendants("content").Descendants(s + "organisationSummary")) { try { GPSurgeriesFeedData gp = new GPSurgeriesFeedData(); var newData = new organisationSummary(); var newDataCoordinates = new organisationSummaryGeographicCoordinates(); newData.name = (curElement.Element(s + "name")).Value.ToString(); string[] addresslines = new string[5]; string postcode = string.Empty; int i = 0; foreach (XElement curElementCoordinates in curElement.Descendants(s + "address")) { foreach (XElement SubcurElementCoordinates in curElementCoordinates.Descendants(s + "addressLine")) { addresslines[i] = SubcurElementCoordinates.Value; i++; } postcode = curElementCoordinates.Element(s + "postcode").Value.ToString(); } string[] contact = new string[3]; i = 0; foreach (XElement curElementCoordinates in curElement.Descendants(s + "contact")) { foreach (XElement SubcurElementCoordinates in curElementCoordinates.Descendants(s + "telephone")) { contact[i] = SubcurElementCoordinates.Value; i++; } } foreach (XElement curElementCoordinates in curElement.Descendants(s + "geographicCoordinates")) { newDataCoordinates.latitude = Convert.ToDecimal((curElementCoordinates.Element(s + "latitude")).Value); newDataCoordinates.longitude = Convert.ToDecimal((curElementCoordinates.Element(s + "longitude")).Value); } gp.Name = newData.name; gp.Addressline1 = addresslines[0] == null ? "?" : addresslines[0]; gp.Addressline2 = addresslines[1] == null ? "?" : addresslines[1]; gp.Addressline3 = addresslines[2] == null ? "?" : addresslines[2]; gp.Addressline4 = addresslines[3] == null ? "?" : addresslines[3]; gp.Addressline5 = addresslines[4] == null ? "?" : addresslines[4]; gp.PostCode = postcode == null ? "?" : postcode; gp.Telephone = contact[0]; gp.Latitude = newDataCoordinates.latitude; gp.Longitude = newDataCoordinates.longitude; coordinateCollectionSub.Add(gp); newFeedList.Add(gp); } catch (FormatException fe) { #if DEBUG System.Diagnostics.Debug.WriteLine(fe); #endif } catch (Exception e) { #if DEBUG System.Diagnostics.Debug.WriteLine(e); #endif } } //GPSurgeriesCollection colln = newFeedList; SetMap(coordinateCollectionSub, count); count++; } catch (Exception ex) { #if DEBUG System.Diagnostics.Debug.WriteLine(ex); #endif } }