<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-6331038517213839518</id><updated>2012-02-16T10:38:02.602-08:00</updated><category term='Map'/><category term='Zoom'/><category term='Distance'/><category term='Address Parsing'/><category term='Hit Detection'/><category term='Street Address'/><category term='ActiveX'/><category term='POI'/><category term='Find Nearby'/><category term='TimeZone'/><category term='Routing'/><category term='Pushpin'/><category term='Marker'/><category term='Driving Directions'/><category term='Optimization'/><title type='text'>Programming MapPoint</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://www.programmingmappoint.net/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6331038517213839518/posts/default'/><link rel='alternate' type='text/html' href='http://www.programmingmappoint.net/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Chandu Thota</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp3.blogger.com/_1Rk3b_BLUlo/SFoLsjlBG3I/AAAAAAAAAGk/yJD6Hp3tM80/S220/chandu600x600.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>20</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-6331038517213839518.post-8467257212151857190</id><published>2010-12-27T12:34:00.000-08:00</published><updated>2010-12-27T12:34:27.852-08:00</updated><title type='text'>How to find a place/address using MapPoint?</title><content type='html'>When you think of mapping in general, the first thing that comes to mind is finding a location and their associated latitude/longitude - whether it is a place (as in a point of interest) or an address. A place is a general location that is referred by its commonly known name; on the other hand the address is a more detailed specification of a location. For example, one of the most known places in Seattle around the world is “Space Needle”, but the actual address of the Space Needle is 498 Broad St, Seattle, WA 98109. &lt;br /&gt;&lt;br /&gt;Using MapPoint you can find both places and addresses among other things.&lt;br /&gt;&lt;br /&gt;The code snippet below shows how to find a place:&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;//Create an instance of ApplicationClass&lt;br /&gt;MapPoint.ApplicationClass app = new MapPoint.ApplicationClass();&lt;br /&gt;//Get a reference to the Map instance via the ActiveMap property&lt;br /&gt;MapPoint.Map map = app.ActiveMap;&lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;The MapClass exposes a method, FindPlaceResults, which returns all places that matches the input query. This method takes place name as string as an input and returns FindResults, which is a collection of locations found. The following code shows the FindPlaceResults method call:&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;//Call FindPlaceResults on the MapClass instance&lt;br /&gt;MapPoint.FindResults findResults = map.FindPlaceResults(“Space Needle”);&lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;Similarly, you can find addresses using the FindAddressResults method, as shown below:&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;//Create an instance of the MapPoint application class&lt;br /&gt;MapPoint.ApplicationClass app = new MapPoint.ApplicationClass();&lt;br /&gt;//Get the Map object from the application object&lt;br /&gt;MapPoint.Map map = app.ActiveMap;&lt;br /&gt;//Call the FindAddressResults method&lt;br /&gt;MapPoint.FindResults findResults = map.FindAddressResults(&lt;br /&gt;                                        "498 Broad St", &lt;br /&gt;                                        "Seattle", &lt;br /&gt;                                        string.Empty, &lt;br /&gt;                                        "WA", &lt;br /&gt;                                        "98109", &lt;br /&gt;                            MapPoint.GeoCountry.geoCountryUnitedStates);&lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;Finally, if you don’t know if an input is a place (POI) or an address, use FindResults method, as shown below:&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;//Works with finding addresses&lt;br /&gt;MapPoint.FindResults findAddressResults &lt;br /&gt;    =  map.FindResults("498 Broad St, Seattle, WA, 98109");&lt;br /&gt;//Works with finding places&lt;br /&gt;MapPoint.FindResults findPlaceResults &lt;br /&gt;    =  map.FindResults("Space Needle");&lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;Now you just have to iterate through find results to get the location information in each case.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6331038517213839518-8467257212151857190?l=www.programmingmappoint.net' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.programmingmappoint.net/feeds/8467257212151857190/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.programmingmappoint.net/2010/12/how-to-find-placeaddress-using-mappoint.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6331038517213839518/posts/default/8467257212151857190'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6331038517213839518/posts/default/8467257212151857190'/><link rel='alternate' type='text/html' href='http://www.programmingmappoint.net/2010/12/how-to-find-placeaddress-using-mappoint.html' title='How to find a place/address using MapPoint?'/><author><name>Chandu Thota</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp3.blogger.com/_1Rk3b_BLUlo/SFoLsjlBG3I/AAAAAAAAAGk/yJD6Hp3tM80/S220/chandu600x600.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6331038517213839518.post-5225864265879241170</id><published>2010-12-27T12:33:00.000-08:00</published><updated>2010-12-27T12:33:25.278-08:00</updated><title type='text'>How to access FindResult collection members from a Find call?</title><content type='html'>Find method calls (both FindPlaceResults and FindAddressResults) in MapPoint returns the FindResults instance that contains all the locations that matched the input query. Each location that matched the input place is represented as an instance of MapPoint.Location class in the FindResults object. Even though the FindResults class is essentially a collection of Location objects, its behavior is quite different (blame the COM legacy) from any .NET collection in that you can’t really access the members of the collection with their index as you would in a generic .NET collection.&lt;br /&gt;&lt;br /&gt;Having said that you can still access the collection members in the following ways:&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Using the Get accessor method&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;Collections are implemented using two special accessor methods called get_Item and set_Item. These special methods are generated by the .NET compiler for every publicly exposed property. In case of FindResults instance, even though the Items read-only property is not exposed in the interoperable assembly, get_Item method is still implemented internally. The only differences from the conventional .NET get_Item method are that this method takes the index value as an object passed by reference (for COM marshalling purposes) and the index starts from 1 instead of 0. &lt;br /&gt;The following code shows how to use the get_Item accessor method to iterate through the list of Location objects in the FindResults collection:&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;//Create an object to hold index value&lt;br /&gt;object index = null;&lt;br /&gt;//Start with index 1 instead of 0&lt;br /&gt;for(int i=1; i&lt;=findResults.Count; i++){    //Box the integer value as an object    index = i;    //Pass the index as a reference to the get_Item accessor method    MapPoint.Location loc = findResults.get_Item(ref index) as MapPoint.Location;    if(loc != null)        //do something intersting}&lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Using an enumerator &lt;/b&gt;&lt;br /&gt;&lt;br /&gt;You can also access the list of Locations from FindResults instance using the enumeration. The FindResults instance exposes a method, GetEnumerator, to get an enumerated list of locations. Using this enumerator instance, you can loop through the list of locations as shown below:&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;//Get an enumerator using the GetEnumerator method&lt;br /&gt;IEnumerator locationEnumerator = findResults.GetEnumerator();&lt;br /&gt;//Loop through the location instances to get the names&lt;br /&gt;while(locationEnumerator.MoveNext())&lt;br /&gt;{&lt;br /&gt;    MapPoint.Location loc = locationEnumerator.Current as MapPoint.Location;&lt;br /&gt;    //do something interesting&lt;br /&gt;}&lt;br /&gt;&lt;/blockquote&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6331038517213839518-5225864265879241170?l=www.programmingmappoint.net' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.programmingmappoint.net/feeds/5225864265879241170/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.programmingmappoint.net/2010/12/how-to-access-findresult-collection.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6331038517213839518/posts/default/5225864265879241170'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6331038517213839518/posts/default/5225864265879241170'/><link rel='alternate' type='text/html' href='http://www.programmingmappoint.net/2010/12/how-to-access-findresult-collection.html' title='How to access FindResult collection members from a Find call?'/><author><name>Chandu Thota</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp3.blogger.com/_1Rk3b_BLUlo/SFoLsjlBG3I/AAAAAAAAAGk/yJD6Hp3tM80/S220/chandu600x600.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6331038517213839518.post-5084570329831149884</id><published>2010-12-27T12:32:00.001-08:00</published><updated>2010-12-27T12:32:10.521-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Find Nearby'/><category scheme='http://www.blogger.com/atom/ns#' term='POI'/><title type='text'>How to find nearby points of interest (POI) using MapPoint?</title><content type='html'>Location class from MapPoint object model exposes the FindNearby method to find POI around a location. The only parameter that the FindNearby method takes is distance as type System.Double. &lt;br /&gt;&lt;br /&gt;The distance must be greater than zero and less than or equal to 50 miles. The default unit of measurement for distance is in Miles. Code snippet shown below is a good example of how to use that method:&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;//Call the find nearby on the current location&lt;br /&gt;MapPoint.FindResults poiResults = location.FindNearby(distance);&lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;As you can see the result is again a FindResults class that encapsulates a collection of locations. You can get the details of the location including the POI category (such as a restaurant or a gas station etc) using the PlaceCategory. &lt;br /&gt;&lt;br /&gt;The PlaceCategory class encapsulates a category name and is exposed as PlaceCategory property from the Location class.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6331038517213839518-5084570329831149884?l=www.programmingmappoint.net' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.programmingmappoint.net/feeds/5084570329831149884/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.programmingmappoint.net/2010/12/how-to-find-nearby-points-of-interest.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6331038517213839518/posts/default/5084570329831149884'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6331038517213839518/posts/default/5084570329831149884'/><link rel='alternate' type='text/html' href='http://www.programmingmappoint.net/2010/12/how-to-find-nearby-points-of-interest.html' title='How to find nearby points of interest (POI) using MapPoint?'/><author><name>Chandu Thota</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp3.blogger.com/_1Rk3b_BLUlo/SFoLsjlBG3I/AAAAAAAAAGk/yJD6Hp3tM80/S220/chandu600x600.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6331038517213839518.post-7437073454738261800</id><published>2010-12-27T12:31:00.001-08:00</published><updated>2010-12-27T12:31:26.431-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Street Address'/><category scheme='http://www.blogger.com/atom/ns#' term='Address Parsing'/><title type='text'>How to parse an address using MapPoint?</title><content type='html'>Map class has a method, ParseStreetAddress that parses a string into a valid street address represented as the StreetAddress class. The StreetAddress class has the Street, City, OtherCity, PostalCode, Region and Country properties that represent various parts of an address. The Value property of the StreetAddress class gives the full address as one string. &lt;br /&gt;&lt;br /&gt;The following code shows how to parse a string into a valid address:&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;//Create an instance of the MapPoint application class&lt;br /&gt;MapPoint.ApplicationClass app = new MapPoint.ApplicationClass();&lt;br /&gt;//Get the Map object from the application object&lt;br /&gt;MapPoint.Map map = app.ActiveMap;&lt;br /&gt;//Parse the address&lt;br /&gt;MapPoint.StreetAddress address = &lt;br /&gt;    map.ParseStreetAddress("498 Broad St, Seattle, WA, 98109");&lt;br /&gt;&lt;br /&gt;//Now get the values from the &lt;br /&gt;//StreetAddress properties&lt;br /&gt;string streetName = address.Street;&lt;br /&gt;string city = address.City;&lt;br /&gt;&lt;/blockquote&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6331038517213839518-7437073454738261800?l=www.programmingmappoint.net' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.programmingmappoint.net/feeds/7437073454738261800/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.programmingmappoint.net/2010/12/how-to-parse-address-using-mappoint.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6331038517213839518/posts/default/7437073454738261800'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6331038517213839518/posts/default/7437073454738261800'/><link rel='alternate' type='text/html' href='http://www.programmingmappoint.net/2010/12/how-to-parse-address-using-mappoint.html' title='How to parse an address using MapPoint?'/><author><name>Chandu Thota</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp3.blogger.com/_1Rk3b_BLUlo/SFoLsjlBG3I/AAAAAAAAAGk/yJD6Hp3tM80/S220/chandu600x600.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6331038517213839518.post-8302894241770052522</id><published>2010-12-27T12:30:00.002-08:00</published><updated>2010-12-27T12:30:51.359-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Distance'/><title type='text'>How to calculate distance between two locations using MapPoint?</title><content type='html'>The Location class has the DistanceTo method that calculates the distance to a given location. Keep in mind that the distance calculated using this method is not the same as the driving distance; this method only gives you an along-the-straight-line-distance (or “as the crow flies”) between the two locations. &lt;br /&gt;&lt;br /&gt;The DistanceTo method takes another location as an argument; the following code shows how to calculate distance between two locations:&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;//Get the from location&lt;br /&gt;MapPoint.Location fromLocation &lt;br /&gt;        = this.findResults.get_Item(ref fromIndex) as MapPoint.Location;&lt;br /&gt;//Get the to location&lt;br /&gt;MapPoint.Location toLocation &lt;br /&gt;        = poiResults.get_Item(ref poiIndex) as MapPoint.Location;&lt;br /&gt;//Calculate the distance between the from location and&lt;br /&gt;//to location using the DistanceTo method &lt;br /&gt;double distance = fromLocation.DistanceTo(toLocation);&lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;Another way of calculating the distance between two locations is to call the Distance method on active Map object as shown below: &lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;double distance = app.ActiveMap.Distance(startLocation, endLocation);&lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;Both startLocation and endLocation are of MapPoint.Location type objects.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6331038517213839518-8302894241770052522?l=www.programmingmappoint.net' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.programmingmappoint.net/feeds/8302894241770052522/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.programmingmappoint.net/2010/12/how-to-calculate-distance-between-two.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6331038517213839518/posts/default/8302894241770052522'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6331038517213839518/posts/default/8302894241770052522'/><link rel='alternate' type='text/html' href='http://www.programmingmappoint.net/2010/12/how-to-calculate-distance-between-two.html' title='How to calculate distance between two locations using MapPoint?'/><author><name>Chandu Thota</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp3.blogger.com/_1Rk3b_BLUlo/SFoLsjlBG3I/AAAAAAAAAGk/yJD6Hp3tM80/S220/chandu600x600.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6331038517213839518.post-6128906961121876636</id><published>2010-12-27T12:30:00.000-08:00</published><updated>2010-12-27T12:30:08.168-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Map'/><category scheme='http://www.blogger.com/atom/ns#' term='ActiveX'/><title type='text'>How to display a map using MapPoint?</title><content type='html'>You can build visual Map based applications in Windows environment using MapPoint ActiveX Control. When you drag and drop the MapPoint control on to your Windows form, the reference to the MapPoint interoperable assembly is automatically added to your project along with the control. &lt;br /&gt;&lt;br /&gt;The drag and drop operation also creates and adds an instance of MapPoint control to your code file, as shown below:&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;private AxMapPoint.AxMappointControl axMappointControl1;&lt;/blockquote&gt;&lt;br /&gt;Before you use the AxMappointControl, you need to initialize the control by creating new map coverage. You do this by calling the NewMap method on the AxMappointControl class. This method takes the map region of type GeoMapRegion enumeration as an argument. There are two valid region values for the map region in MapPoint: GeoMapRegion.geoMapNorthAmerica for North American maps and GeoMapRegion.geoMapEurope for European maps. &lt;br /&gt;&lt;br /&gt;The following code shows initializing the control to show the North American map:&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;axMappointControl1.NewMap(MapPoint.GeoMapRegion.geoMapNorthAmerica);&lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;After initializing the map control, you can access the map object via the ActiveMap property, as shown below:&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;MapPoint.Map map = axMappointControl1.ActiveMap;&lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;Once you have the map object, you can find and navigate to a specific location as shown below:&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;//Define a location instance&lt;br /&gt;MapPoint.Location currentLocation = null;&lt;br /&gt;//Get the current location from FindResults method&lt;br /&gt;...&lt;br /&gt;currentLocation = findResults.get_Item(ref index);&lt;br /&gt;&lt;br /&gt;//Go to the current location on the map&lt;br /&gt;currentLocation.GoTo();&lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;Calling the GoTo method zooms in to the location with best possible view on the map and centers the map on that location.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6331038517213839518-6128906961121876636?l=www.programmingmappoint.net' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.programmingmappoint.net/feeds/6128906961121876636/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.programmingmappoint.net/2010/12/how-to-display-map-using-mappoint.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6331038517213839518/posts/default/6128906961121876636'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6331038517213839518/posts/default/6128906961121876636'/><link rel='alternate' type='text/html' href='http://www.programmingmappoint.net/2010/12/how-to-display-map-using-mappoint.html' title='How to display a map using MapPoint?'/><author><name>Chandu Thota</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp3.blogger.com/_1Rk3b_BLUlo/SFoLsjlBG3I/AAAAAAAAAGk/yJD6Hp3tM80/S220/chandu600x600.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6331038517213839518.post-16627291305800296</id><published>2010-12-27T12:29:00.000-08:00</published><updated>2010-12-27T12:29:03.380-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Pushpin'/><category scheme='http://www.blogger.com/atom/ns#' term='Marker'/><title type='text'>How to add a pushpin (or a map marker) to the map using MapPoint?</title><content type='html'>A pushpin in MapPoint is represented by the Pushpin class. The Name property of a Pushpin object can be used to annotate the Pushpin. You can also add notes to the Pushpin using the Pushpin.Notes property. &lt;br /&gt;&lt;br /&gt;A Pushpin is essentially symbol (icon) on the map; MapPoint provides a number of symbols to be used with Pushpins. These symbols are indexed and their number should be used to indicate the symbol of a given Pushpin; For example the default symbol is black pushpin represented by the number 0. The valid range for the standard symbols is 0-255. &lt;br /&gt;&lt;br /&gt;To add a pushpin to a location, you just have to call the Map.AddPushpin method, as shown below:&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;//Get map center location&lt;br /&gt;MapPoint.Location location =  axMappointControl1.ActiveMap.Location;&lt;br /&gt;//Add a pushpin at this location&lt;br /&gt;MapPoint.Pushpin pushpin = axMappointControl1.ActiveMap.AddPushpin(&lt;br /&gt;                                                     location, "Center");&lt;br /&gt;//Assign a symbol&lt;br /&gt;pushpin.Symbol = 64;&lt;br /&gt;//Select and highlight the location&lt;br /&gt;pushpin.Select();&lt;br /&gt;pushpin.Highlight = true;&lt;br /&gt;//Write annotation&lt;br /&gt;pushpin.Note = "This is my favorite place!";&lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;Now if you want to open the “info window” for the pushpin, you can use the Pushpin.BallonState enumeration.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6331038517213839518-16627291305800296?l=www.programmingmappoint.net' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.programmingmappoint.net/feeds/16627291305800296/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.programmingmappoint.net/2010/12/how-to-add-pushpin-or-map-marker-to-map.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6331038517213839518/posts/default/16627291305800296'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6331038517213839518/posts/default/16627291305800296'/><link rel='alternate' type='text/html' href='http://www.programmingmappoint.net/2010/12/how-to-add-pushpin-or-map-marker-to-map.html' title='How to add a pushpin (or a map marker) to the map using MapPoint?'/><author><name>Chandu Thota</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp3.blogger.com/_1Rk3b_BLUlo/SFoLsjlBG3I/AAAAAAAAAGk/yJD6Hp3tM80/S220/chandu600x600.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6331038517213839518.post-4617242666741646751</id><published>2010-12-27T12:28:00.000-08:00</published><updated>2010-12-27T12:28:20.352-08:00</updated><title type='text'>How to pan a MapPoint Map?</title><content type='html'>The MapPoint ActiveX Control provides you with a fully interactive map to perform actions such as panning, zooming and tracking mouse clicks and so on. &lt;br /&gt;&lt;br /&gt;To pan a map you would use Map.Pan method. This method takes two arguments: &lt;br /&gt;1. PanDirection: Indicates the direction of the pan operation; this property is of type MapPoint.GeoPanCmd enumeration. This enumeration contains values that represent directional values such as east, west, north, south, north-east and so on. &lt;br /&gt;2. PanFactor: Indicates amount of pan. Even though there are no limits to the pan factor, you have to keep in mind that this value is dependent on the altitude of your map. To give you an idea of what I mean, at 1 mile (lower altitudes), a pan factor of 1 pans the map by 0.2 miles, but the same pan factor at 50 miles (a higher altitude) pans the map by 10 miles!&lt;br /&gt;&lt;br /&gt;The following code shows how to call the Pan method:&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;axMappointControl1.ActiveMap.Pan(MapPoint.GeoPanCmd.geoWest, 1);&lt;/blockquote&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6331038517213839518-4617242666741646751?l=www.programmingmappoint.net' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.programmingmappoint.net/feeds/4617242666741646751/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.programmingmappoint.net/2010/12/how-to-pan-mappoint-map.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6331038517213839518/posts/default/4617242666741646751'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6331038517213839518/posts/default/4617242666741646751'/><link rel='alternate' type='text/html' href='http://www.programmingmappoint.net/2010/12/how-to-pan-mappoint-map.html' title='How to pan a MapPoint Map?'/><author><name>Chandu Thota</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp3.blogger.com/_1Rk3b_BLUlo/SFoLsjlBG3I/AAAAAAAAAGk/yJD6Hp3tM80/S220/chandu600x600.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6331038517213839518.post-3947795533705351950</id><published>2010-12-27T12:27:00.001-08:00</published><updated>2010-12-27T12:27:32.347-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Zoom'/><title type='text'>How to zoom in and zoom out a MapPoint Map?</title><content type='html'>MapPoint ActiveX Control offers two methods to perform zoom operations on the maps. &lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;1.ZoomIn method – This method zooms the map view closer by reducing the map altitude&lt;br /&gt;2.ZoomOut method – This methods zooms the map view farther by increasing the map altitude&lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;These two methods zoom in/out in steps. There are ten levels of zoom effect that you can achieve using these two methods. The levels are defined based on the map altitude and each time when you call zoom methods, map’s altitude is modified accordingly and re-rendered to show the map at that altitude. &lt;br /&gt;The following code shows how to call a ZoomIn method:&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;axMappointControl1.ActiveMap.ZoomIn();&lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;Now, if you want to zoom into a particular level from your current view, say, you want to zoom to street level directly without calling ZoomIn method multiple times, you can do that by modifying the map altitude, as shown below:&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;//Zoom directly into Street Level by setting 3 mile altitude&lt;br /&gt;axMappointControl1.ActiveMap.Altitude = 3;&lt;br /&gt;&lt;/blockquote&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6331038517213839518-3947795533705351950?l=www.programmingmappoint.net' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.programmingmappoint.net/feeds/3947795533705351950/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.programmingmappoint.net/2010/12/how-to-zoom-in-and-zoom-out-mappoint.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6331038517213839518/posts/default/3947795533705351950'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6331038517213839518/posts/default/3947795533705351950'/><link rel='alternate' type='text/html' href='http://www.programmingmappoint.net/2010/12/how-to-zoom-in-and-zoom-out-mappoint.html' title='How to zoom in and zoom out a MapPoint Map?'/><author><name>Chandu Thota</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp3.blogger.com/_1Rk3b_BLUlo/SFoLsjlBG3I/AAAAAAAAAGk/yJD6Hp3tM80/S220/chandu600x600.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6331038517213839518.post-1217843089945595544</id><published>2010-12-27T12:26:00.001-08:00</published><updated>2010-12-27T12:26:30.326-08:00</updated><title type='text'>How to convert a location/point to X/Y coordinates using MapPoint?</title><content type='html'>If you want to process user’s interaction with maps in MapPoint ActiveX Control, you need to know when and where a mouse is clicked to obtain the location corresponding to a mouse click.&lt;br /&gt;The Map object provides a way to convert a location on the map to a point on the screen. By using Map object’s LocationToX and LocationToY methods, you can obtain X and Y coordinates for any given location. &lt;br /&gt;&lt;br /&gt;You need to make separate calls for each X and Y coordinate for any given location, as shown below:&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;//Get the center of the map&lt;br /&gt;MapPoint.Location location = axMappointControl1.ActiveMap.Location;&lt;br /&gt;//Get x and y coordinates&lt;br /&gt;int x = axMappointControl1.ActiveMap.LocationToX(location);&lt;br /&gt;int y = axMappointControl1.ActiveMap.LocationToY(location);&lt;br /&gt;//Display the center coordinates&lt;br /&gt;MessageBox.Show(String.Format("Map is centered at ({0}, {1})", &lt;br /&gt;                                       x.ToString(), y.ToString()));&lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;Keep in mind that the LocationToX and LocationToY methods assume that a particular location is on the current map screen limits; if the location is not present in the ActiveX Control map screen limits, these methods fail. To avoid errors in a case like this, it’s always a good idea to use Location.GoTo() method before getting the coordinates.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6331038517213839518-1217843089945595544?l=www.programmingmappoint.net' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.programmingmappoint.net/feeds/1217843089945595544/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.programmingmappoint.net/2010/12/how-to-convert-locationpoint-to-xy.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6331038517213839518/posts/default/1217843089945595544'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6331038517213839518/posts/default/1217843089945595544'/><link rel='alternate' type='text/html' href='http://www.programmingmappoint.net/2010/12/how-to-convert-locationpoint-to-xy.html' title='How to convert a location/point to X/Y coordinates using MapPoint?'/><author><name>Chandu Thota</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp3.blogger.com/_1Rk3b_BLUlo/SFoLsjlBG3I/AAAAAAAAAGk/yJD6Hp3tM80/S220/chandu600x600.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6331038517213839518.post-6197405175516786838</id><published>2010-12-27T12:25:00.001-08:00</published><updated>2010-12-27T12:25:50.026-08:00</updated><title type='text'>How to obtain location for the X/Y coordinates using MapPoint?</title><content type='html'>If you want to process user’s interaction with maps in MapPoint ActiveX Control, you need to know when and where a mouse is clicked to obtain the location corresponding to a mouse click. &lt;br /&gt;Map object exposes the XYToLocation method to obtain a location at a given point on the map view on the screen. This method takes X and Y screen coordinates and returns the location corresponding to that point. So, in order to use this method you need to trap the mouse click and capture the X and Y coordinates. &lt;br /&gt;&lt;br /&gt;You can do that using the Map object’s BeforeClick event. This event occurs when a user clicks on the map but before MapPoint ActiveX Control actually processes that mouse click. You would have to wire-up this event in the InitializeComponent method of your application, as shown below:&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;axMappointControl1.BeforeClick += &lt;br /&gt;            new AxMapPoint._IMappointCtrlEvents_BeforeClickEventHandler(                                                                                       &lt;br /&gt;                                         axMappointControl1_BeforeClick);&lt;br /&gt;&lt;/blockquote&gt;Once you have wired up the event, the axMapPointControl1_BeforeClick method should be implemented so that you capture the mouse click coordinates, as shown below:&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;private void axMappointControl1_BeforeClick(object sender, &lt;br /&gt;                           AxMapPoint._IMappointCtrlEvents_BeforeClickEvent e)&lt;br /&gt;{&lt;br /&gt;    int XCoord = e.x;&lt;br /&gt;    int YCoord = e.y;&lt;br /&gt;    MapPoint.Location location = &lt;br /&gt;               axMappointControl1.ActiveMap.XYToLocation(XCoord, YCoord);&lt;br /&gt;    if(location != null)&lt;br /&gt;    {&lt;br /&gt;        //Do some processing with location&lt;br /&gt;        . . .&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;/blockquote&gt;This event captures only single clicks from the mouse; if you want to capture double clicks from your mouse, you have to wire-up BeforeDblClick event. BeforeDlbClick event occurs when a user double-clicks on the map but before MapPoint ActiveX Control actually processes that double click.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6331038517213839518-6197405175516786838?l=www.programmingmappoint.net' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.programmingmappoint.net/feeds/6197405175516786838/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.programmingmappoint.net/2010/12/how-to-obtain-location-for-xy.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6331038517213839518/posts/default/6197405175516786838'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6331038517213839518/posts/default/6197405175516786838'/><link rel='alternate' type='text/html' href='http://www.programmingmappoint.net/2010/12/how-to-obtain-location-for-xy.html' title='How to obtain location for the X/Y coordinates using MapPoint?'/><author><name>Chandu Thota</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp3.blogger.com/_1Rk3b_BLUlo/SFoLsjlBG3I/AAAAAAAAAGk/yJD6Hp3tM80/S220/chandu600x600.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6331038517213839518.post-9178688957833111222</id><published>2010-12-27T12:24:00.001-08:00</published><updated>2010-12-27T12:24:36.229-08:00</updated><title type='text'>How to disable Map interaction in MapPoint?</title><content type='html'>Let’s say that you wanted a “static” map for your application – then you need to disable the map for user interaction; unfortunately, there is no straight forward way of doing it rather than disabling all events by overriding them.&lt;br /&gt;&lt;br /&gt;Here are all the events that you need to take care of:&lt;br /&gt;&lt;br /&gt;1. Turn-off the edge panning by setting the AllowEdgePan to false, as shown below: &lt;br /&gt;&lt;br /&gt;2. Mouse down event – Need to capture any mouse down event and display a message saying this is a read only Map.&lt;br /&gt;&lt;br /&gt;3. Pan and Zoom via Mouse wheel and Arrow keys – You can take care of this action by overriding the AfterViewChange event by restoring the original center of the map and altitude.&lt;br /&gt;The AfterViewChange event handler restores both map center and altitude; this method takes care of both pan clicks and zoom (via the mouse wheel scroll); but keep in mind that performance may be affected by the mouse wheel scroll events.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6331038517213839518-9178688957833111222?l=www.programmingmappoint.net' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.programmingmappoint.net/feeds/9178688957833111222/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.programmingmappoint.net/2010/12/how-to-disable-map-interaction-in.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6331038517213839518/posts/default/9178688957833111222'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6331038517213839518/posts/default/9178688957833111222'/><link rel='alternate' type='text/html' href='http://www.programmingmappoint.net/2010/12/how-to-disable-map-interaction-in.html' title='How to disable Map interaction in MapPoint?'/><author><name>Chandu Thota</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp3.blogger.com/_1Rk3b_BLUlo/SFoLsjlBG3I/AAAAAAAAAGk/yJD6Hp3tM80/S220/chandu600x600.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6331038517213839518.post-8530252408089360979</id><published>2010-12-27T12:23:00.001-08:00</published><updated>2010-12-27T12:23:43.782-08:00</updated><title type='text'>How to avoid Memory Leaks in MapPoint Programming?</title><content type='html'>MapPoint object model is originally designed and implemented using COM technologies. So, even if you write your code in managed using the COM Interoperable assemblies, the MapPoint Application instance will not be collected by the .NET runtime garbage collector. &lt;br /&gt;&lt;br /&gt;So, in order to avoid memory leaks, before quitting your application, you have to manually make sure to quit the MapPoint Application by calling the Quit method on the MapPoint.Application object, as shown below:&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;//Define MapPoint Application instance&lt;br /&gt;MapPoint.Application app = null;&lt;br /&gt;//Obtain app references either via MapPoint.ApplicationClass or&lt;br /&gt;//MapPoint.AxMapPointControl.ActiveMap.Application&lt;br /&gt;. . .&lt;br /&gt;&lt;br /&gt;//Clean up the MapPoint Application before you exit&lt;br /&gt;if(app != null)&lt;br /&gt;{&lt;br /&gt;    app.Quit();&lt;br /&gt;    app = null;&lt;br /&gt;}&lt;br /&gt;&lt;/blockquote&gt;The Quit method discards the current map and unloads all other items such as add-ins etc before exiting the application. However, calling this method prompts the user whether they want to save the map before discarding it. If you don’t want this behavior you can set the Saved property to true on the application’s active Map object, as shown below:&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;app.ActiveMap.Saved = true;&lt;/blockquote&gt;&lt;br /&gt;Setting this value does not prompt the user to make a decision to save or discard the current map.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6331038517213839518-8530252408089360979?l=www.programmingmappoint.net' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.programmingmappoint.net/feeds/8530252408089360979/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.programmingmappoint.net/2010/12/how-to-avoid-memory-leaks-in-mappoint.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6331038517213839518/posts/default/8530252408089360979'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6331038517213839518/posts/default/8530252408089360979'/><link rel='alternate' type='text/html' href='http://www.programmingmappoint.net/2010/12/how-to-avoid-memory-leaks-in-mappoint.html' title='How to avoid Memory Leaks in MapPoint Programming?'/><author><name>Chandu Thota</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp3.blogger.com/_1Rk3b_BLUlo/SFoLsjlBG3I/AAAAAAAAAGk/yJD6Hp3tM80/S220/chandu600x600.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6331038517213839518.post-957775510957458498</id><published>2010-12-27T12:22:00.001-08:00</published><updated>2010-12-27T12:22:43.031-08:00</updated><title type='text'>How to get Location from latitude/longitude in MapPoint?</title><content type='html'>Using the Map class GetLocation method, you can easily find a location that corresponds to a given latitude and longitude. This method takes latitude and longitude as System.Double values and returns a Location instance that represents the input latitude and longitude. This method also takes the altitude as an argument, but it is mainly used at the time when the location is displayed on a map, so, you can freely pass 1 mile for the time being. &lt;br /&gt;&lt;br /&gt;The following code shows how to find a location using latitude and longitude:&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;//Get the reference to the active map instance&lt;br /&gt;MapPoint.Map map = app.ActiveMap;&lt;br /&gt;//Call the GetLocation method to find location&lt;br /&gt;//using the latitude and longitude&lt;br /&gt;MapPoint.Location location = &lt;br /&gt;        m.GetLocation(41.33896, -122.43433, 1);&lt;br /&gt;&lt;/blockquote&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6331038517213839518-957775510957458498?l=www.programmingmappoint.net' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.programmingmappoint.net/feeds/957775510957458498/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.programmingmappoint.net/2010/12/how-to-get-location-from.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6331038517213839518/posts/default/957775510957458498'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6331038517213839518/posts/default/957775510957458498'/><link rel='alternate' type='text/html' href='http://www.programmingmappoint.net/2010/12/how-to-get-location-from.html' title='How to get Location from latitude/longitude in MapPoint?'/><author><name>Chandu Thota</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp3.blogger.com/_1Rk3b_BLUlo/SFoLsjlBG3I/AAAAAAAAAGk/yJD6Hp3tM80/S220/chandu600x600.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6331038517213839518.post-4113969988751501937</id><published>2010-12-27T12:21:00.001-08:00</published><updated>2010-12-27T12:21:24.688-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Hit Detection'/><title type='text'>Hit-Detection in MapPoint</title><content type='html'>Hit-Detection is one of the coolest features of MapPoint API. The Map object in MapPoint has the method, ObjectsFromPoint, which allows you to perform a hit-detenction around any given point (x and y coordinates) on the screen. What it means is that this method returns an array of “objects” wrapped in a FindResults instance. For example, if you call this method at lower altitudes, it returns locations with street addresses, if you go to higher altitudes and call this method, it returns larger geographic areas such as postal code, county, time-zone of the point and so on. &lt;br /&gt;The following snippet shows how to call the ObjectsFromPoint method for any given Location:&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;//Get Location from latitude and longitude&lt;br /&gt;MapPoint.Location location = &lt;br /&gt;       app.ActiveMap.GetLocation(mylatitude, mylongitude, altitude);&lt;br /&gt;&lt;br /&gt;/Now use the Map.ObjectsFromPoint method to get points from the &lt;br /&gt;//above location&lt;br /&gt;MapPoint.FindResults findresults = &lt;br /&gt;     app.ActiveMap.ObjectsFromPoint(&lt;br /&gt;            app.ActiveMap.LocationToX(location),&lt;br /&gt;            app.ActiveMap.LocationToY(location));&lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;The ObjectsFromPoint method, or hit-detection, is very versatile and can be used for many purposes such as querying for address of a given location, determining time-zone, querying a territory and so on.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6331038517213839518-4113969988751501937?l=www.programmingmappoint.net' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.programmingmappoint.net/feeds/4113969988751501937/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.programmingmappoint.net/2010/12/hit-detection-in-mappoint.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6331038517213839518/posts/default/4113969988751501937'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6331038517213839518/posts/default/4113969988751501937'/><link rel='alternate' type='text/html' href='http://www.programmingmappoint.net/2010/12/hit-detection-in-mappoint.html' title='Hit-Detection in MapPoint'/><author><name>Chandu Thota</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp3.blogger.com/_1Rk3b_BLUlo/SFoLsjlBG3I/AAAAAAAAAGk/yJD6Hp3tM80/S220/chandu600x600.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6331038517213839518.post-8489549348560488751</id><published>2010-12-27T12:20:00.000-08:00</published><updated>2010-12-27T12:20:13.616-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Hit Detection'/><category scheme='http://www.blogger.com/atom/ns#' term='TimeZone'/><title type='text'>How to determine a time-zone for a given location using MapPoint?</title><content type='html'>Determining time-zone for any given location can be done using the ObjectsFromPoint (or so called Hit-Detection) method. When this method is called at lower altitudes (usually around 2-3 miles), it returns the time-zone as one of the FindResults objects. Using this technique you can check if the FindResults contains a time-zone or not by looking for the string “GMT” in the name of the each found result, as shown below:&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;string place = "San Francisco, CA";&lt;br /&gt;//Find the locatoin first&lt;br /&gt;MapPoint.FindResults findResults&lt;br /&gt;    = axMappointControl1.ActiveMap.FindResults(place);&lt;br /&gt;if(findResults != null &amp;&amp; findResults.Count &gt; 0)&lt;br /&gt; {&lt;br /&gt;  object index = 1;&lt;br /&gt;  MapPoint.Location location =&lt;br /&gt;  findResults.get_Item(ref index) as MapPoint.Location;&lt;br /&gt;  //Zoom into it&lt;br /&gt;  location.GoTo();&lt;br /&gt;  //Set low altitudes&lt;br /&gt;  axMappointControl1.ActiveMap.Altitude = 2;&lt;br /&gt; //Now get points from the location&lt;br /&gt; MapPoint.FindResults points &lt;br /&gt;     = axMappointControl1.ActiveMap.ObjectsFromPoint(&lt;br /&gt;          axMappointControl1.ActiveMap.LocationToX(location),&lt;br /&gt;          axMappointControl1.ActiveMap.LocationToY(location));&lt;br /&gt; if(points != null &amp;&amp; points.Count &gt; 0)&lt;br /&gt;  {&lt;br /&gt;    for(int i=1;i&lt;=points.Count;i++)    {     object index2 = i;     //Get location     MapPoint.Location loc      = points.get_Item(ref index2) as MapPoint.Location;    //Look for GMT in the name of the location    if(loc.Name.IndexOf("GMT") &gt; 0)&lt;br /&gt;    {&lt;br /&gt;      MessageBox.Show(loc.Name);&lt;br /&gt;      break;&lt;br /&gt;     }&lt;br /&gt;   }&lt;br /&gt; }&lt;br /&gt;&lt;/blockquote&gt;That’s it!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6331038517213839518-8489549348560488751?l=www.programmingmappoint.net' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.programmingmappoint.net/feeds/8489549348560488751/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.programmingmappoint.net/2010/12/how-to-determine-time-zone-for-given.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6331038517213839518/posts/default/8489549348560488751'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6331038517213839518/posts/default/8489549348560488751'/><link rel='alternate' type='text/html' href='http://www.programmingmappoint.net/2010/12/how-to-determine-time-zone-for-given.html' title='How to determine a time-zone for a given location using MapPoint?'/><author><name>Chandu Thota</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp3.blogger.com/_1Rk3b_BLUlo/SFoLsjlBG3I/AAAAAAAAAGk/yJD6Hp3tM80/S220/chandu600x600.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6331038517213839518.post-5291891235844597716</id><published>2010-12-27T12:19:00.000-08:00</published><updated>2010-12-27T12:19:13.675-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Hit Detection'/><category scheme='http://www.blogger.com/atom/ns#' term='Street Address'/><title type='text'>How to determine street address for a given latitude/longitude using MapPoint?</title><content type='html'>One of the limitations of the GetLocation method is that you cannot always get the address of a given set of latitude and longitude. The work-around for this limitation is to use the hit-detection technique around the given latitude and longitude.&lt;br /&gt;&lt;br /&gt;There are a couple of ways to do the hit-detection:&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;1.Panning around at the same altitude to see if we find a street addresses&lt;br /&gt;2.Zooming in and out trying find locations with street addresses&lt;br /&gt;3.Route to a known place (such as a POI or Point of Interest or Address) and the found location automatically snaps to a nearest street.&lt;br /&gt;&lt;/blockquote&gt;In my book I have discussed a very efficient way in detail to detect street-address that minimizes the accuracy errors as well as optimizes for the performance.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6331038517213839518-5291891235844597716?l=www.programmingmappoint.net' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.programmingmappoint.net/feeds/5291891235844597716/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.programmingmappoint.net/2010/12/how-to-determine-street-address-for.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6331038517213839518/posts/default/5291891235844597716'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6331038517213839518/posts/default/5291891235844597716'/><link rel='alternate' type='text/html' href='http://www.programmingmappoint.net/2010/12/how-to-determine-street-address-for.html' title='How to determine street address for a given latitude/longitude using MapPoint?'/><author><name>Chandu Thota</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp3.blogger.com/_1Rk3b_BLUlo/SFoLsjlBG3I/AAAAAAAAAGk/yJD6Hp3tM80/S220/chandu600x600.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6331038517213839518.post-8086796836118029549</id><published>2010-12-27T12:15:00.000-08:00</published><updated>2010-12-27T12:15:13.210-08:00</updated><title type='text'>Routing using MapPoint</title><content type='html'>MapPoint provides a simple but extensive API to calculate routes using locations. Route in MapPoint is represented as a MapPoint.Route object.  You can access a Route object via the ActuveRoute property of a Map object as shown below:&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;MapPoint.Route route = axMappointControl1.ActiveMap.ActiveRoute;&lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;After obtaining valid route object, you can perform actions such as calculating routes, optimizing routes and personalizing routes and so on. Under the hood, a route is essentially a collection of locations that are connected via some kind of a street or ferry or a highway. These locations in a route are known as waypoints and represented using the MapPoint.Waypoint class. A valid route always contains two or more waypoints. Waypoints in a route are represented as the Route.Waypoints collection. So you use the Waypoints collection to add new waypoints as shown below:&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;//Get hold of route object&lt;br /&gt;MapPoint.Route route = axMappointControl1.ActiveMap.ActiveRoute;&lt;br /&gt;//Add the location to the ActiveRoute&lt;br /&gt;route.Waypoints.Add(loc, loc.Name);&lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;You can use the MapPoint.Waypoint object in many ways to specify a route or even modify an existing route. If you want to change the location that is represented by a Waypoint object, you need to use the Waypoint.Anchor property. This property is of type object due to the reason that it can be a Location or Pushpin. So, if you are assigning a new location to a waypoint, you can do it as shown below:&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;//Obtain a waypoint from a given route&lt;br /&gt;object index = 1;&lt;br /&gt;MapPoint.Waypoint waypoint = route.Waypoints.get_Item(ref index);&lt;br /&gt;//Assign a new location&lt;br /&gt;waypoint.Anchor = newlocation;&lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;You may also have noticed that a Waypoint object also exposes the Location property, which returns the Location object that it corresponds to; however, keep in mind that this property is a read-only property and you cannot change the location using this property.&lt;br /&gt;Using the Waypoint object’s SegmentPreferences property, you can set the segment preference indicating if you prefer a shorter route or a quicker route and so on. &lt;br /&gt;&lt;br /&gt;This is really useful if you have preferences for a segment in a route. This property is of type MapPoint.GeoSegmentPreferences enumeration which has the following values:&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;1.geoSegmentQuickest – This option let’s you calculate a route based on the quickest route available between two locations.&lt;br /&gt;2.geoSegmentShortest – This option lets you calculate a route based on shortest distance between two locations&lt;br /&gt;3.geoSegmentPreferred – This option lets you calculate a route based on the route preferences set using the DriverProfile object at the Route object level (which we will discuss shortly).&lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;The default value is always geoSegmentQuickest and you can set a different value as shown below:&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;object index = 2;&lt;br /&gt;MapPoint.Waypoint waypoint = route.Waypoints.get_Item(ref index);&lt;br /&gt;waypoint.SegmentPreferences = MapPoint.GeoSegmentPreferences.geoSegmentQuickest;&lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;Actually, there is one last thing that you need to understand about waypoints and SegementPreferences; a waypoint represents only one location; but a route segment represents two locations. So what happens if you set two different segment preferences for each location in a single segment? The answer is that the waypoint (location) that is at the beginning of the segment always decides the segment’s route preference. &lt;br /&gt;Waypoints are categorized into three types: &lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;1.Start point&lt;br /&gt;2.End point&lt;br /&gt;3.Intermediate stop&lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;You can access this information for a given Waypoint object using the Type property. This property is of MapPoint.GeoWayPointType enumeration. This property is useful in determining the type of a waypoint in analyzing a route or processing the driving directions.&lt;br /&gt;&lt;br /&gt;You can set a Waypoint’s preferred arrival and departure times using the PreferredArrival and PreferredDeparture properties respectively; MapPoint uses this information while calculating the driving directions to adjust the itinerary. Finally you can specify stop time using the StopTime property. This property is of type double and takes value expressed in hours as a fraction of day (24 hours).&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6331038517213839518-8086796836118029549?l=www.programmingmappoint.net' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.programmingmappoint.net/feeds/8086796836118029549/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.programmingmappoint.net/2010/12/routing-using-mappoint.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6331038517213839518/posts/default/8086796836118029549'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6331038517213839518/posts/default/8086796836118029549'/><link rel='alternate' type='text/html' href='http://www.programmingmappoint.net/2010/12/routing-using-mappoint.html' title='Routing using MapPoint'/><author><name>Chandu Thota</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp3.blogger.com/_1Rk3b_BLUlo/SFoLsjlBG3I/AAAAAAAAAGk/yJD6Hp3tM80/S220/chandu600x600.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6331038517213839518.post-2336417886460284920</id><published>2010-12-27T12:12:00.001-08:00</published><updated>2010-12-27T12:12:52.570-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Routing'/><category scheme='http://www.blogger.com/atom/ns#' term='Driving Directions'/><category scheme='http://www.blogger.com/atom/ns#' term='Optimization'/><title type='text'>How to optimize a route using MapPoint</title><content type='html'>You can optimize a route if it has more than one way points as intermediate stops. Optimization of a route is useful if you want to order waypoints (of type intermediate stops) so that the total distance you drive in a route is minimized. You can optimize a route by calling the Optimize method on the waypoints collection, as shown below:&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;//Optimize the route&lt;br /&gt;route.Waypoints.Optimize();&lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;Note that Optimize method does not alter the start and end points; it only re-orders the intermediate stops. If you do not have more than two waypoints, calling this method does not have effect on the waypoint order.&lt;br /&gt;&lt;br /&gt;You can find out if a waypoints collection is optimized or not by using WayPoints.IsOptimized property. When the Optimize method is called and a route is successfully optimized, the RouteAfterOptimize event is fired; the following code shows how to wire-up this event:&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;this.axMappointControl1.RouteAfterOptimize &lt;br /&gt;    +=new AxMapPoint._IMappointCtrlEvents_RouteAfterOptimizeEventHandler(&lt;br /&gt;                            axMappointControl1_RouteAfterOptimize);&lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;The following code shows how a simple implementation of this event handler:&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;private void axMappointControl1_RouteAfterOptimize(object sender, &lt;br /&gt;    AxMapPoint._IMappointCtrlEvents_RouteAfterOptimizeEvent e)&lt;br /&gt;{&lt;br /&gt;    //Now display the waypoints in correct order&lt;br /&gt;    DisplayCorrectRouteOrder(e.pRoute);        &lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;You can use this event to record the new order of the waypoints or display the new order of the waypoints.&lt;br /&gt;&lt;br /&gt;Remember though, that calling the Optimize method does not calculate driving directions, it only re-orders the intermediate stop waypoints. So in order to get the driving directions, you need to calculate the route as a separate step.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6331038517213839518-2336417886460284920?l=www.programmingmappoint.net' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.programmingmappoint.net/feeds/2336417886460284920/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.programmingmappoint.net/2010/12/how-to-optimize-route-using-mappoint.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6331038517213839518/posts/default/2336417886460284920'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6331038517213839518/posts/default/2336417886460284920'/><link rel='alternate' type='text/html' href='http://www.programmingmappoint.net/2010/12/how-to-optimize-route-using-mappoint.html' title='How to optimize a route using MapPoint'/><author><name>Chandu Thota</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp3.blogger.com/_1Rk3b_BLUlo/SFoLsjlBG3I/AAAAAAAAAGk/yJD6Hp3tM80/S220/chandu600x600.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6331038517213839518.post-410340857742520687</id><published>2010-12-27T12:10:00.000-08:00</published><updated>2010-12-27T12:10:57.261-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Routing'/><category scheme='http://www.blogger.com/atom/ns#' term='Driving Directions'/><title type='text'>How to calculate driving directions using MapPoint?</title><content type='html'>You can calculate a route for a given set of waypoints using the Route object’s Calculate method, as shown below:&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;//Calculate the route&lt;br /&gt;route.Calculate();&lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;When you call this method you need to make sure you have at least two waypoints added to the route object; otherwise an exception is thrown. It is also important to note that this method also throws an exception when two waypoints are not connected by any routable means. When this method is successfully completed, the RouteAfterCalculate event is fired; you can use this event in several ways such as displaying driving directions and storing route cost into a database and so on. The following code shows how to wire up the RouteAfterCalculate event:&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;this.axMappointControl1.RouteAfterCalculate+=&lt;br /&gt;         new AxMapPoint._IMappointCtrlEvents_RouteAfterCalculateEventHandler(&lt;br /&gt;                                       axMappointControl1_RouteAfterCalculate);&lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;And the following code snippet shows a sample implementation of the event handler method:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;private void axMappointControl1_RouteAfterCalculate(object sender, &lt;br /&gt;        AxMapPoint._IMappointCtrlEvents_RouteAfterCalculateEvent e)&lt;br /&gt;{&lt;br /&gt;    //Display diriving directions&lt;br /&gt;    DisplayDrivingDirections(e.pRoute);&lt;br /&gt;}&lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;Now, after calculating driving directions, you can get the detailed instructions from the directions using the route object’s Directions property, as shown below:&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;foreach(MapPoint.Direction direction in route.Directions)&lt;br /&gt;{&lt;br /&gt;     . . .&lt;br /&gt;}&lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;The Directions property is a collection of Direction objects. The Direction class several properties such as driving instructions, starting time, distance and so on. Along with all these properties, the Direction object also provides the FindNearby method to find nearby points of interests; since a direction object connects two locations, this FindNearby works as a “find along route” instead of a FindNearby around a specific point. This method is useful in route planning tasks such as “where to stop for gas &amp; food along a route” scenarios.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6331038517213839518-410340857742520687?l=www.programmingmappoint.net' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.programmingmappoint.net/feeds/410340857742520687/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.programmingmappoint.net/2010/12/how-to-calculate-driving-directions.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6331038517213839518/posts/default/410340857742520687'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6331038517213839518/posts/default/410340857742520687'/><link rel='alternate' type='text/html' href='http://www.programmingmappoint.net/2010/12/how-to-calculate-driving-directions.html' title='How to calculate driving directions using MapPoint?'/><author><name>Chandu Thota</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp3.blogger.com/_1Rk3b_BLUlo/SFoLsjlBG3I/AAAAAAAAAGk/yJD6Hp3tM80/S220/chandu600x600.jpg'/></author><thr:total>0</thr:total></entry></feed>
