/// <summary> /// Request pois with the position and the category. /// </summary> /// <param name="coordinate">Specifies the starting position</param> /// <param name="Category">Specifies the end position</param> public async void RequestPOI(Geocoordinates coordinate, string Category) { try { // Set the category s_maps.PlaceSearchFilter.Category.Id = Category; /// Request pois with the position and the category. var response = await s_maps.CreatePlaceSearchRequest(coordinate, 500).GetResponseAsync(); // Get the places IEnumerator <Place> place = response.GetEnumerator(); // Create the list for places PlaceList = new List <Place>(); while (place.MoveNext()) { // Add the place to the list PlaceList.Add(place.Current); } // Sort by distance PlaceList = PlaceList.OrderBy(x => x.Distance).ToList(); for (int i = 0; i < PlaceList.Count; i++) { // Create pins with the places and add it to marker list MarkerList.Add(new global::Tizen.Maps.Pin(PlaceList[i].Coordinates)); // Show the markers if (view == ViewPage.POI) { s_mapview.Add(MarkerList[i]); } // Add a handler to click the marker MarkerList[i].Clicked += (sender, e) => { SetCurrentMarker((Marker)sender); }; } // Set the current marker if (view == ViewPage.POI) { SetCurrentMarker(MarkerList[0]); } } catch (Exception e) { // Display logs with the error message Log.Debug("Map", e.Message.ToString()); } // Set the viewpage if (view == ViewPage.POI) { view = ViewPage.POISELECTED; } }
/// <summary> /// Searches for places of specified type in given area. /// </summary> /// <param name="area">Area to look for places.</param> /// <param name="placeType">Type of place.</param> /// <returns>Response from find place service.</returns> public async Task <FindPlaceResponse> GetPlacesAsync(Model.Area area, PlaceType placeType) { try { var placeCategory = new PlaceCategory(); placeCategory.Id = placeType.GetPlaceCategoryId(); using (_mapService.PlaceSearchFilter = new PlaceFilter()) { _mapService.PlaceSearchFilter.Category = placeCategory; Geocoordinates geoTopLeft = new Geocoordinates( area.TopLeftPoint.Latitude, area.TopLeftPoint.Longitude); Geocoordinates geoBottomRight = new Geocoordinates( area.BottomRightPoint.Latitude, area.BottomRightPoint.Longitude); var request = _mapService.CreatePlaceSearchRequest(new Area(geoTopLeft, geoBottomRight)); _loggerService.Verbose($"{request}"); var response = await request.GetResponseAsync(); _loggerService.Verbose($"{response}"); var results = response .Select(r => new PlaceSearchResult(r.Name, AddressToString(r.Address))) .ToList(); results.ForEach(result => _loggerService.Verbose($"{result}")); return(new FindPlaceResponse(true, results)); } } catch (Exception e) { bool notFound = e.Message.Contains(NotFoundError); return(new FindPlaceResponse(notFound)); } }