none
Getting the Points(lat/longs) on the map....On left click of muse RRS feed

  • Question

  • Hi,

     m   having The Problem to get the points on the maps ..just on left click of mouse .

    /////my code is as...........

      GeocodeService.Location lo = new GeocodeService.Location();


                  
                    LatitudeOfPoint =lo.Latitude;
                    LongitudeOfPoint =lo.Longitude;

    ....i m using the MouseLeftButtonDown as event handler in the map.

    Thanks in advance

    Friday, June 1, 2012 7:04 AM

Answers

  • Which map control are you using? Note that in all the map controls the mouse event returns a pixel coordinate. This needs to be converted to a map cooridinate. Each map control has a method to do this. This will give you the coordinates. If you want to then find the address for that coordinate you will need to pass it through the Reverse Geocoding service.

    http://rbrundritt.wordpress.com

    Friday, June 1, 2012 8:21 AM
  • Are you using the Bing Maps AJAX v7, WPF, Silverlight, Windows Phone, or Windows 8 map control/API.

    http://rbrundritt.wordpress.com

    Friday, June 1, 2012 1:11 PM
  • Ok, you will want to use the map.TryViewportPointToLocation method to convert the mouse pixel coordinates to a map coordinate.

    http://rbrundritt.wordpress.com

    • Marked as answer by prakash_light Tuesday, June 5, 2012 9:18 AM
    Friday, June 1, 2012 1:37 PM

All replies

  • Which map control are you using? Note that in all the map controls the mouse event returns a pixel coordinate. This needs to be converted to a map cooridinate. Each map control has a method to do this. This will give you the coordinates. If you want to then find the address for that coordinate you will need to pass it through the Reverse Geocoding service.

    http://rbrundritt.wordpress.com

    Friday, June 1, 2012 8:21 AM
  • Are you Talking about the .dll(s)

    then

                         Microsoft.maps.Mapcontrol

                        Microsoft.maps.Mapcontrol.common

    ...or if not plz..can u a bit clearer..than this....?

    Thanx in advance

    Friday, June 1, 2012 8:51 AM
  • Are you using the Bing Maps AJAX v7, WPF, Silverlight, Windows Phone, or Windows 8 map control/API.

    http://rbrundritt.wordpress.com

    Friday, June 1, 2012 1:11 PM
  • m using SILVERLIGHT

    Thnx

    prakash

    Friday, June 1, 2012 1:30 PM
  • Ok, you will want to use the map.TryViewportPointToLocation method to convert the mouse pixel coordinates to a map coordinate.

    http://rbrundritt.wordpress.com

    • Marked as answer by prakash_light Tuesday, June 5, 2012 9:18 AM
    Friday, June 1, 2012 1:37 PM
  • Hi Richard,

                   My Scenario is.......

                                                            1. I have a pair of lat/long(starting point).

                                                            2. Next is to click on the MAP get the points just after clicking event

                                                            3. Immediately Draw the route path between these points

                                                            4. follow the step 2-to-4  until the end point(I have one already).

    Thanks & Regards

    prakash kumar

     

    Tuesday, June 5, 2012 9:26 AM
  • can u elaborate  please map.TryViewportPointToLocation method to convert the mouse pixel coordinates to a map coordinate.

    Thanks & Regards

    prakash kumar

    Tuesday, June 5, 2012 9:30 AM
  • Hi Richard,

                    can i use  ViewportPointToLocation(Point) method instead of  TryViewportPointToLocation(Point,Location) in my context.

    Thanks & Regards

    Prakash kumar

    Tuesday, June 5, 2012 9:50 AM
  • hi,

    here is a simple code to get the points and convert to the lat/long

                  Point point = e.GetPosition( your_MapName);
                    Microsoft.Maps.MapControl.Location loaction = your_MapName.ViewportPointToLocation(point);

    Wednesday, June 13, 2012 4:57 AM
  • You should be getting the pixel coordinates from the mouse event. Here is a simple example:

    MyMap.MouseClick += (s, e) =>
    {
    	Location l;
    	if (MyMap.TryViewportPointToLocation(e.ViewportPoint, out l))
    	{
    		//l is now your map coordinate
    	}
    };


    http://rbrundritt.wordpress.com

    Wednesday, June 13, 2012 9:25 AM