HI
How to code Location sensor using with Mappoint in c#?
please help
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...
HI
How to code Location sensor using with Mappoint in c#?
please help
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 ~
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]
Sorry about that.
Code:private: System::Void axMappointControl1_MouseMoveEvent(System::Object * sender, AxInterop::MapPoint::_IMappointCtrlEvents_MouseMoveEvent * 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"); }
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.
There are currently 1 users browsing this thread. (0 members and 1 guests)