Exemple #1
0
        public async Task <Bitmap> GetMapResponseDataAsync(String type, String zoom)
        {
            CurrentCoordinate currentCoordinate = new CurrentCoordinate();

            currentCoordinate.CalculateCurrentCoordinates();
            String currentCoordinates = CoordinatesConverter.GetConvertedCoordinates(currentCoordinate.Latitude, currentCoordinate.Longitude);

            placesList.AddRange(await new NearbyPlacesList().GetNearbyPlacesListAsync(type));
            placesList.ToArray();
            String url = ConfigurationManager.AppSettings["GoogleStaticMapApiUrl"] + "&size=" + mapSize
                         + "&center=" + currentCoordinates + "&zoom=" + zoom
                         + "&" + ConfigurationManager.AppSettings["GoogleStaticMapApiKey"];

            for (int i = 0; i < 5; i++)
            {
                url += "&" + ConfigurationManager.AppSettings["GoogleStaticMapApiMarker"] + (i + 1) + "%7C" + placesList[i].Coordinates;
            }
            Uri             uri          = new Uri(url);
            HttpWebRequest  httpRequest  = (HttpWebRequest)HttpWebRequest.Create(uri);
            HttpWebResponse httpResponse = (HttpWebResponse)httpRequest.GetResponse();
            Stream          imageStream  = httpResponse.GetResponseStream();
            Bitmap          image        = new Bitmap(imageStream);

            httpResponse.Close();
            imageStream.Close();
            return(image);
        }
Exemple #2
0
        public async Task <GooglePlacesApiResponse> GetApiResponseData(String type)
        {
            CurrentCoordinate currentCoordinate = new CurrentCoordinate();

            currentCoordinate.CalculateCurrentCoordinates();
            String             currentCoordinates = CoordinatesConverter.GetConvertedCoordinates(currentCoordinate.Latitude, currentCoordinate.Longitude);
            HttpClient         client             = new HttpClient();
            HttpRequestMessage requestMessage     = new HttpRequestMessage(HttpMethod.Get,
                                                                           ConfigurationManager.AppSettings["GooglePlacesApiUrl"] + "&location="
                                                                           + currentCoordinates + "&type=" + type + "&"
                                                                           + ConfigurationManager.AppSettings["GooglePlacesApiKey"]);

            HttpResponseMessage responseMessage = await client.SendAsync(requestMessage);

            GooglePlacesApiResponse responseData = JsonConvert.DeserializeObject <GooglePlacesApiResponse>(await responseMessage.Content.ReadAsStringAsync());

            return(responseData);
        }