private void updateMap(CheckMapp.Utils.PlaceNearToMap.PlacesList aWiKIAPIResponse) { int totalRecords = aWiKIAPIResponse.PlaceList.Count(); MyMap.Visibility = System.Windows.Visibility.Visible; try { ObservableCollection <CheckMapp.Utils.PlaceNearToMap.PlaceNearMap> placeToMapObjs = new ObservableCollection <CheckMapp.Utils.PlaceNearToMap.PlaceNearMap>(); for (int index = 0; index < totalRecords; index++) { placeToMapObjs.Add(new CheckMapp.Utils.PlaceNearToMap.PlaceNearMap() { Coordinate = new GeoCoordinate(Convert.ToDouble(aWiKIAPIResponse.PlaceList.ElementAt(index).Latitude, CultureInfo.InvariantCulture), Convert.ToDouble(aWiKIAPIResponse.PlaceList.ElementAt(index).Longitude, CultureInfo.InvariantCulture)), Info = aWiKIAPIResponse.PlaceList.ElementAt(index).Title, Summary = aWiKIAPIResponse.PlaceList.ElementAt(index).Summary }); } removeTempMapLayer(); int countPOI = 0; foreach (CheckMapp.Utils.PlaceNearToMap.PlaceNearMap PlaceNear in placeToMapObjs) { // If the set doesn't contains an element latitude+longitude we can show it trough pushPin nearby the phone location if (!ViewModel.PointOfInterestList.Any(x => x.Latitude == PlaceNear.Coordinate.Latitude && x.Longitude == PlaceNear.Coordinate.Longitude)) { MapLayer pinLayout = new MapLayer(); Pushpin MyPushpin = new Pushpin(); MapOverlay pinOverlay = new MapOverlay(); MyMap.Layers.Add(pinLayout); MyPushpin.GeoCoordinate = PlaceNear.Coordinate; pinOverlay.Content = MyPushpin; pinOverlay.GeoCoordinate = PlaceNear.Coordinate; pinOverlay.PositionOrigin = new Point(0, 1); pinLayout.Add(pinOverlay); MyPushpin.Content = PlaceNear.Info.Trim(); MyPushpin.Background = new SolidColorBrush(Color.FromArgb(255, 105, 105, 105)); MyPushpin.Tap += MyPushpin_Tap; MyPushpin.Tag = PlaceNear; countPOI++; } } MessageBox.Show(String.Format(AppResources.ResultPOI, countPOI), AppResources.PlaceNearYou, MessageBoxButton.OK); } catch (Exception ex) { Console.WriteLine("Exception occured while updating map : " + ex.Message); } }
private void parseResponseData(String aResponse) { CheckMapp.Utils.PlaceNearToMap.PlacesList placesListObj = new CheckMapp.Utils.PlaceNearToMap.PlacesList(); MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(aResponse)); DataContractJsonSerializer ser = new DataContractJsonSerializer(placesListObj.GetType()); placesListObj = ser.ReadObject(ms) as CheckMapp.Utils.PlaceNearToMap.PlacesList; ms.Close(); // updating UI if (placesListObj != null) { updateMap(placesListObj); } }