none
capture coordinates of a place from a silverlight bing maps application, and then obtain the location information

    Question

  • hi am new to use bing maps in a silverlight application, and followed the guide on this page http://belensaez.wordpress.com/2011/09/01/bing-maps-servicios-soap-listo/ 

    I have a map which get the coordenas and then try to use them. but do not understand my mistake, I describe in this video

    https://www.youtube.com/watch?v=lZlC894fCHY&feature=youtu.be


    Carlos Jose Gonzalez Arenas

    Thursday, May 01, 2014 4:15 AM

Answers

  • I went digging through some of my 5 year old code an managed to find this:

    private void MyMap_MouseClick(object sender, MapMouseEventArgs e)
    {
    	Location location;
    	if (MyMap.TryViewportPointToLocation(e.ViewportPoint, out location))
    	{
    		LatLongLabel.Text = String.Format("Latitude: {0:#.######}, Longitude: {0:#.######}", location.Latitude, location.Longitude);
    
    		ReverseGeocodeRequest reverseGeocodeRequest = new ReverseGeocodeRequest();
    
    		// Set the credentials using a valid Bing Maps key
    		reverseGeocodeRequest.Credentials = new Credentials();
    		reverseGeocodeRequest.Credentials.ApplicationId = ApplicationKey;
    
    		reverseGeocodeRequest.Location = location;
    
    		// Make the reverse geocode request
    		GeocodeServiceClient geocodeService = 
    			new GeocodeServiceClient("BasicHttpBinding_IGeocodeService");
    		geocodeService.ReverseGeocodeCompleted += new EventHandler<ReverseGeocodeCompletedEventArgs>(geocodeService_ReverseGeocodeCompleted);
    		geocodeService.ReverseGeocodeAsync(reverseGeocodeRequest);
    	}
    }
    
    private void geocodeService_ReverseGeocodeCompleted(object sender, ReverseGeocodeCompletedEventArgs e)
    {
    	// The result is a GeocodeResponse object
    	GeocodeResponse geocodeResponse = e.Result;
    	ResultViewer.Children.Clear();
    
    	if (geocodeResponse.Results.Count > 0)
    	{
    		for (int i = 0; i < geocodeResponse.Results.Count; i++)
    		{
    			TextBlock result = new TextBlock();
    			result.Text = geocodeResponse.Results[i].DisplayName;
    			ResultViewer.Children.Add(result);
    		}
    	}
    }
    

    However you shouldn't use the SOAP services. We took the documentation for them offline for a reason. Had you used the REST services you would of been done by now.


    http://rbrundritt.wordpress.com

    Thursday, May 01, 2014 3:54 PM
    Owner

All replies

  • It's not really clear what you are looking to do. So far looking at your video it looks like you are getting the coordinates of where the user has clicked. If you want to get the address of the location the user clicked then you will need to reverse geocode the coordinates using a Bing Maps Service. I see you are looking at an old blog post on the legacy Bing Maps SOAP services. These services are not recommended for new developments. You should be using the Bing Maps REST services which are much faster and have more features. You can find information on how to use the REST services in .NET here: http://msdn.microsoft.com/en-us/library/jj819168.aspx

    Also, it's worth noting that it is not a good idea to create new applications using Silverlight. There has been little investment in the future of Silverlight and Microsoft has already announced an end of life date for it. I highly recommend using one of the many Bing Maps controls for HTML/AJAX, Windows Store Apps, Windows Phone, or WPF.


    http://rbrundritt.wordpress.com

    Thursday, May 01, 2014 8:51 AM
    Owner
  • tengo las coordenadas y estan en este tipo

    worldCoords que es del tipo Microsoft.Maps.MapControl.Location luego se las paso al

     point que es del tipo GeocodeService.Location, cuando hago la asignacion no se porque tengo el error

    Nullexception. si esta no esta vacia.

    ///

    I have the coordinates in worldCoords and are in such type

     Microsoft.Maps.MapControl.Location that is then I give 

      GeocodeService.Location point type, after making the assignment is not because I have the error 

    Nullexception. if this is not empty.



    Carlos Jose Gonzalez Arenas

    Thursday, May 01, 2014 11:11 AM
  • I could solve the problem was because there was no point initialized, nevertheless , I am stuck with this error

    GeocodeService.GeocodeServiceClient 'does not Contain a definition for' reverseGeocode reverseGeocode ' accepting a first argument of type GeoCodingReverse.GeocodeService.GeocodeServiceClient ' 'and no extension method found' ( are you missing a using directive or an assembly reference ? )

    when trying to pass data to the service point2

     string results = "";
                string key = "AiFZBJ-o_s13MXi0aRShyPs0J-Qwq0b_ZT8kcV6ENqzSngdocYdxwAk9nuBHC1W9";
                 
                ReverseGeocodeRequest reverseGeocodeRequest = new ReverseGeocodeRequest();
    
                // Asignamos los credenciales en base a la clave de Bing Maps
                reverseGeocodeRequest.Credentials = new GeocodeService.Credentials();
                reverseGeocodeRequest.Credentials.ApplicationId = key;
    
                // Asignamos la latitud y la longitud
                
                //string[] digits = consultaTxt.Text.Split(';');
    
                //point.Latitude = double.Parse(digits[0].Trim());
                //point.Longitude = double.Parse(digits[1].Trim());
    
                reverseGeocodeRequest.Location = point2;
    
                // Realizamos la petición
                GeocodeServiceClient geocodeService = new GeocodeServiceClient("BasicHttpBinding_IGeocodeService");
                GeocodeResponse geocodeResponse = geocodeService.ReverseGeocode(reverseGeocodeRequest);
    please, help me, I really need to move forward with this, I would appreciate your help

    Carlos Jose Gonzalez Arenas

    Thursday, May 01, 2014 12:06 PM
  • I went digging through some of my 5 year old code an managed to find this:

    private void MyMap_MouseClick(object sender, MapMouseEventArgs e)
    {
    	Location location;
    	if (MyMap.TryViewportPointToLocation(e.ViewportPoint, out location))
    	{
    		LatLongLabel.Text = String.Format("Latitude: {0:#.######}, Longitude: {0:#.######}", location.Latitude, location.Longitude);
    
    		ReverseGeocodeRequest reverseGeocodeRequest = new ReverseGeocodeRequest();
    
    		// Set the credentials using a valid Bing Maps key
    		reverseGeocodeRequest.Credentials = new Credentials();
    		reverseGeocodeRequest.Credentials.ApplicationId = ApplicationKey;
    
    		reverseGeocodeRequest.Location = location;
    
    		// Make the reverse geocode request
    		GeocodeServiceClient geocodeService = 
    			new GeocodeServiceClient("BasicHttpBinding_IGeocodeService");
    		geocodeService.ReverseGeocodeCompleted += new EventHandler<ReverseGeocodeCompletedEventArgs>(geocodeService_ReverseGeocodeCompleted);
    		geocodeService.ReverseGeocodeAsync(reverseGeocodeRequest);
    	}
    }
    
    private void geocodeService_ReverseGeocodeCompleted(object sender, ReverseGeocodeCompletedEventArgs e)
    {
    	// The result is a GeocodeResponse object
    	GeocodeResponse geocodeResponse = e.Result;
    	ResultViewer.Children.Clear();
    
    	if (geocodeResponse.Results.Count > 0)
    	{
    		for (int i = 0; i < geocodeResponse.Results.Count; i++)
    		{
    			TextBlock result = new TextBlock();
    			result.Text = geocodeResponse.Results[i].DisplayName;
    			ResultViewer.Children.Add(result);
    		}
    	}
    }
    

    However you shouldn't use the SOAP services. We took the documentation for them offline for a reason. Had you used the REST services you would of been done by now.


    http://rbrundritt.wordpress.com

    Thursday, May 01, 2014 3:54 PM
    Owner
  • Hay preguntas ingenuas, preguntas tediosas, preguntas mal formuladas, preguntas planteadas con una inadecuada autocrítica.
    Pero toda pregunta es un clamor por entender el mundo;No hay preguntas estúpidas. sino tontos que no preguntan.

    ok, I was foolish trying to do. 
    SOA, WPF is for winforms or  wpf applications, and I had a Silverlight Web application, I had to use REST SERVICES.

    I apologise, anyway you has helped me a lot.

    i will print your book, it is very interesting for my project.

    i would like my city to have the "streetside" option in bing maps. what is it necessary for making it possible? 

    and i would also like to coloborate in adding some names to some streets which do not appear on the map and, at the same time,
    correct some names which are wrong. i work for the government in Victoria, Entre Ríos, Argentina and i would really like to help.  

    thanks.


    Carlos Jose Gonzalez Arenas

    Friday, May 02, 2014 1:50 AM
  • Streetside is not currently available through the Bing Maps Development API's. To correct and add names you can do this directly with our data provider here: https://mapreporter.navteq.com/

    http://rbrundritt.wordpress.com

    Friday, May 02, 2014 8:50 AM
    Owner