Determining Time Zone using MapPoint 2004

by Chandu Thota

Related link: http://www.csthota.com




Some of the MapPoint 2004 developers have asked me if there is a way to determine time zone of a location using MapPoint 2004. Well, there is no direct method that gives you time zone of a location but, using the ObjectsFromPoint method, you can determine time zone. The following code sample shows how:



string place = "Redmond, WA";
//Find the locatoin first
MapPoint.FindResults findResults
= axMappointControl1.ActiveMap.FindResults(place);
if(findResults != null && findResults.Count > 0)
{
object index = 1;
MapPoint.Location location =
findResults.get_Item(ref index) as MapPoint.Location;
//Zoom into it
location.GoTo();
//Set low altitudes
axMappointControl1.ActiveMap.Altitude = 2;
//Now get points from the location
MapPoint.FindResults points
= axMappointControl1.ActiveMap.ObjectsFromPoint(
axMappointControl1.ActiveMap.LocationToX(location),
axMappointControl1.ActiveMap.LocationToY(location));
if(points != null && points.Count > 0)
{
for(int i=1;i<=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") > 0)
{
MessageBox.Show(loc.Name);
break;
}
}
}


That's it!



Now, this worked on MapPoint 2004 NA and I haven't tested it on EU version. Do you know a better way of finding Time Zone from a given location using MapPoint 2004? Discuss it here!


1 Comments

MP2Kmag
2004-12-11 08:13:41
Leon Schell's article
Leon Schell devised a method for attacking this published on MP2Kmag Feb. '04 -
http://www.mp2kmag.com/a104--time.zone.mappoint.html


Eric