// Create a simple handler for the SpeechRecognized event.
 void sr_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
 {
     MessageBox.Show(e.Result.Text );
     var request = new GeocodingRequest();
     request.Address = e.Result.Text;
     request.Sensor = "false";
     var response = GeocodingService.GetResponse(request);
     if (response.Status == ServiceResponseStatus.Ok)
     {
         currentSelectedLocation = response.Results.First();
     }
     updateMap();
     //================
     //var result = (GeocodingResult)currentSelectedLocation;
     //fullAddress.Text = result.FormattedAddress;
     //var location = result.Geometry.Location;
     //var map = new StaticMap();
     //map.Center = location.Latitude.ToString() + "," + location.Longitude.ToString();
     //txtLatitude.Text = location.Latitude.ToString();
     //txtLongitude.Text = location.Longitude.ToString();
     //map.Zoom =
     //(zoomLevels.SelectedItem == null) ? "10" : zoomLevels.Text.ToString();
     //map.Markers = map.Center;
     //map.Size = "1000" + "x" + "485";
     //map.MapType =
     //(mapTypeCombo.SelectedItem == null) ? "roadmap" : mapTypeCombo.Text.ToString();
     //map.Sensor = "false";
     //String urlToMap = map.ToUri().AbsoluteUri.ToString();
     //mapViewer.Navigate(urlToMap);
 }
Example #2
0
        /// <summary>
        /// Sends the specified request to the Google Maps Geocoding web
        /// service and parses the response as an GeocodingResponse
        /// object.
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public static GeocodingResponse GetResponse(GeocodingRequest request)
        {
            var uri = request.ToUri(ApiUrl);

            if (Debug)
            {
                Console.WriteLine(uri.ToString());
            }
            return(Http.Get(uri).As <GeocodingResponse>());
        }
Example #3
0
		private void searchButton_Click(object sender, RoutedEventArgs e)
		{
			var request = new GeocodingRequest();
			request.Address = searchTextBox.Text;
			request.Sensor = "false";
			var response = GeocodingService.GetResponse(request);

			if (response.Status == ServiceResponseStatus.Ok)
			{
				resultsTreeView.ItemsSource = response.Results.ToTree();
			}
		}
 private void button1btnSearch_Click(object sender, EventArgs e)
 {
     var request = new GeocodingRequest();
     request.Address = txtLocation.Text;
     request.Sensor = "false";
     var response = GeocodingService.GetResponse(request);
     if (response.Status == ServiceResponseStatus.Ok)
     {
         currentSelectedLocation = response.Results.First();
     }
     updateMap();
 }
Example #5
0
        public GeocodingResult GeocodeSearch(string address)
        {
            GeocodingRequest request = new GeocodingRequest();
            request.Address = address;
            request.Region = "AU";
            request.Sensor = "true";
            GeocodingResponse response = new GeocodingResponse();
            response = GeocodingService.GetResponse(request);

            if (response.Results.FirstOrDefault().IsNotNull())
            {
                return response.Results.First();
            }
            else
            {
                //MessageBox.Show(@"No Results Found for Term: " + address, @"No Results");
                return null;
            }
        }
        /// <summary>
        /// sends a geocode request and returns the response
        /// </summary>
        /// <param name="address"></param>
        /// <returns></returns>
        private GeocodingResponse geocodeRequest(string address)
        {
            var request = new GeocodingRequest();
            request.Address = address;
            request.Sensor = "false";
            return GeocodingService.GetResponse(request);

            //XmlDocument a = Geocode(addressSearchText.Text);
            //MessageBox.Show(a.ToString());

        }
Example #7
0
		/// <summary>
		/// Sends the specified request to the Google Maps Geocoding web
		/// service and parses the response as an GeocodingResponse
		/// object.
		/// </summary>
		/// <param name="request"></param>
		/// <returns></returns>
		public static GeocodingResponse GetResponse(GeocodingRequest request)
		{
			var uri =request.ToUri(ApiUrl);
			if (Debug) Console.WriteLine(uri.ToString());
			return Http.Get(uri).As<GeocodingResponse>();
		}
Example #8
0
        /// <summary>
        /// Sends the specified request to the Google Maps Geocoding web
        /// service and parses the response as an GeocodingResponse
        /// object.
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public static GeocodingResponse GetResponse(GeocodingRequest request)
        {
            var url = new Uri(ApiUrl, request.ToUri());

            return(Http.Get(url).As <GeocodingResponse>());
        }
        private void txtLocation_TextChanged(object sender, EventArgs e)
        {
            String str = txtLocation.Text;
            String[] input =str.Split(new char[' ']);
            try
            {
                if (input[input.Length - 1] == "search")
                {
                    var request = new GeocodingRequest();
                    request.Address = txtLocation.Text;
                    request.Sensor = "false";
                    var response = GeocodingService.GetResponse(request);
                    if (response.Status == ServiceResponseStatus.Ok)
                    {
                        currentSelectedLocation = response.Results.First();
                    }

                    updateMap();
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("exception caught");
            }
        }