Welcome to MapForums!

Register, sign in, or use Facebook Connect above to join in and participate in the forum.

When you are signed in, this message, the ads in this row, and the red-underlined link ads all go away.

Subscribe to receive our newsletter.
Subscribe Unsubscribe
Results 1 to 5 of 5

Location Senser

This is a discussion on Location Senser within the MapPoint Desktop Discussion forums, part of the Map Forums category; HI How to code Location sensor using with Mappoint in c#? please help...

  1. #1
    vidyakulkarni is offline Junior Member Yellow Belt
    Join Date
    Jul 2004
    Posts
    14

    Location Senser

    HI
    How to code Location sensor using with Mappoint in c#?
    please help

  2. #2
    Eric Frost's Avatar
    Eric Frost is offline Administrator Black Belt
    Join Date
    Jul 1992
    Posts
    5,094
    Blog Entries
    4
    This is VB.NET, but perhaps it will give you some ideas?

    http://www.mp2kmag.com/a66--location....mappoint.html

    Eric
    ~ Order MapPoint MapPoint 2013 Here and Get Free Access to the MapForums Downloads ~
    ~~
    ~ Upgrade to Get Access to the MapForums Downloads ~

  3. #3
    Anonymous is offline Senior Member Black Belt
    Join Date
    Jul 2002
    Posts
    5,137
    This is a C++ attempt using two labels. It works fine when first loaded but after loading another map programatically, the labels are no longer updated and reaction time slows, eg when using the mouse to select an area, the drawing of the selection box is noticably slowed. I tried disabling the mousemove event while the different map was being loaded, but it didn't help.

    [code]
    private: System::Void axMappointControl1_MouseMoveEvent(System::Object * sender, AxInterop::MapPoint::_IMappointCtrlEvents_MouseMov eEvent * e)
    {
    MapPoint::Location * loc=pMap->XYToLocation(e->x,e->y);
    //following instruction causes problems after a map is loaded programatically;
    double lat=90-180*pMap->Distance(locNorthPole,loc)/halfEarth;
    double d=pMap->Distance(pMap->GetLocation(lat,0,1),loc);
    double rlat=(lat/180)*Math::PI;
    double lon=180*Math::Acos((Math::Cos((d*2*Math::PI)/(2*halfEarth))-Math::Sin(rlat)*Math::Sin(rlat))/(Math::Cos(rlat)*Math::Cos(rlat)))/Math::PI;
    if(pMap->Distance(locSantaCruz,loc)<(halfEarth/2)) lon=-lon;
    labelLatitude->Text=lat.ToString(S"F4");
    labelLongitude->Text=lon.ToString(S"F4");
    }
    [\code]

  4. #4
    Anonymous is offline Senior Member Black Belt
    Join Date
    Jul 2002
    Posts
    5,137
    Sorry about that.

    Code:
    	private&#58; System&#58;&#58;Void axMappointControl1_MouseMoveEvent&#40;System&#58;&#58;Object *  sender, AxInterop&#58;&#58;MapPoint&#58;&#58;_IMappointCtrlEvents_MouseMoveEvent *  e&#41;
    		&#123;
    		MapPoint&#58;&#58;Location * loc=pMap->XYToLocation&#40;e->x,e->y&#41;;
    		//following instruction causes problems after a map is loaded programatically;
    		double lat=90-180*pMap->Distance&#40;locNorthPole,loc&#41;/halfEarth;
    		double d=pMap->Distance&#40;pMap->GetLocation&#40;lat,0,1&#41;,loc&#41;;
    		double rlat=&#40;lat/180&#41;*Math&#58;&#58;PI;
    		double lon=180*Math&#58;&#58;Acos&#40;&#40;Math&#58;&#58;Cos&#40;&#40;d*2*Math&#58;&#58;PI&#41;/&#40;2*halfEarth&#41;&#41;-Math&#58;&#58;Sin&#40;rlat&#41;*Math&#58;&#58;Sin&#40;rlat&#41;&#41;/&#40;Math&#58;&#58;Cos&#40;rlat&#41;*Math&#58;&#58;Cos&#40;rlat&#41;&#41;&#41;/Math&#58;&#58;PI;
    		if&#40;pMap->Distance&#40;locSantaCruz,loc&#41;<&#40;halfEarth/2&#41;&#41; lon=-lon;
    		labelLatitude->Text=lat.ToString&#40;S"F4"&#41;;
    		labelLongitude->Text=lon.ToString&#40;S"F4"&#41;;
    		&#125;

  5. #5
    Anonymous is offline Senior Member Black Belt
    Join Date
    Jul 2002
    Posts
    5,137
    Found part of my problem.

    When I loaded another map, I had to recalculate NorthPole and SantaCruz locations. This also fixed my problem where I could not calculate the lat/long of a pushpin once another map was loaded.

    Now I get lat/long printed out, except that after a while there are long periods of a second or more where the labels are not updated.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36