Section 2.4. Cleaning Up After You re Done


2.4. Cleaning Up After You're Done

The MapPoint 2004 object model was originally designed and implemented using COM technologies, so even if you use the COM Interoperable assemblies to write your code, the MapPoint 2004 Application instance will not be collected by the .NET runtime garbage collector. Before quitting your application, you must manually quit the MapPoint 2004 Application by calling the Quit method on the MapPoint.Application object:

     //Define MapPoint Application instance     MapPoint.Application app = null;     //Obtain app references either via MapPoint.ApplicationClass or     //MapPoint.AxMapPointControl.ActiveMap.Application     . . .     //Clean up the MapPoint Application before you exit     if(app != null)     {         app.Quit( );         app = null;     }

The Quit method discards the current map and unloads all other items, such as add-ins, before exiting the application. However, calling this method asks the user whether she wants to save the map before discarding it. If you don't want users to have this choice, you can set the Saved property to TRue on the application's active Map object:

     app.ActiveMap.Saved = true;

Setting this value means that the user will not be prompted to make a decision whether to save or discard the current map.

If you fail to implement the cleanup, your application may have memory leaks.


So far, we have covered major APIs offered by MapPoint 2004 for finding places, addresses, and nearby interests, along with some basic map operations, such as placing pushpins, zooming, and panning. A discussion of MapPoint 2004 programming is not complete if we don't mention latitude and longitude , so before we move on to routing and driving directions, let's look at finding addresses for latitude and longitude in MapPoint 2004.

Definition of Latitude and Longitude

Latitude measures how far north or south of the Equator a place is located. The Equator is situated at 0°, the North Pole at 90° north (or simply 90°, since a positive latitude number implies north), and the South Pole at 90° south (or -90°). Latitude measurements range from 0 to (±)90.

Longitude measures how far east or west of the Prime Meridian a place is located. The Prime Meridian runs through Greenwich, England . Longitude is measured in terms of east, implied by a positive number, or west, implied by a negative number. Longitude measurements range from 0 to (±)180.





Programming MapPoint in  .NET
Programming MapPoint in .NET
ISBN: 0596009062
EAN: 2147483647
Year: 2005
Pages: 136
Authors: Chandu Thota

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net