Community of VE/MapPoint Users and Developers
This is a discussion on C#: MapPoint 2004 - Check Regions within the MapPoint 2006/2009 Discussion forums, part of the Map Forums category; I too have the same problem. I need to have a C# program determine in which US State contains a ...
| |||||||
| Register | Blogs | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| |||
| Re: C#: MapPoint 2004 - Check Regions
I too have the same problem. I need to have a C# program determine in which US State contains a specific location specified in latitude,longitude. Can this be determined from the results supplied by GetLocation? This is my very first attempt to use MapPoint from a program, so I'm a total newbie. I have MP2006 however, not MP2004. |
| |||
| Re: C#: MapPoint 2004 - Check Regions
Hi, This can easy be done, this is example: Code: Location loc = MP.ActiveMap.GetLocation(lat, lon, alt);
FindResults StreetResults = MP.ActiveMap.ObjectsFromPoint(MP.ActiveMap.LocationToX(loc), MP.ActiveMap.LocationToY(loc));
foreach (object o in StreetResults) {
loc = o as Location;
if (loc != null && loc.StreetAddress != null)
Console.WriteLine("country: " + loc.StreetAddress.Country);
}
__________________ rgds, Wilfried Mestdagh www.mestdagh.biz MapPoint coding demo Order MapPoint 2009 with Routing and User Tools Spreadsheet |
| |||
| Re: C#: MapPoint 2004 - Check Regions
Thank you, Wilfried. I will try this ASAP. Actually it is the region name (State, for US) I am seeking, not the country name, but I will pursue this approach. Ideally, it would be great to be able to request a specific Location Type, eg. geoShowByRegion1 to get the US State name. Would this work if the lat,long. is not near any street? I will be performing these calls using computed lat,long coordinates as part of a search to find the nearest region (State) boundary along a given path, by stepping along the path until the State name changes. (Unless there is an easier way to locate the distance to the border in a given direction.) Last edited by kaborka; 12-21-2006 at 02:14 PM. |
| |||
| Re: C#: MapPoint 2004 - Check Regions
Hi, There is a Region property too. So if a US State is the same as a Region (in my language a State is not a region but more like a Country) then you probably can yous that property. Please feedback about this As for you other question you go high altitude. 10 Miles or so even a little higher then you will have always StreetAddresses (with a larger delusion of precision) (you should always check for null value, if it is null ho higher).
__________________ rgds, Wilfried Mestdagh www.mestdagh.biz MapPoint coding demo Order MapPoint 2009 with Routing and User Tools Spreadsheet |
| |||
| Re: C#: MapPoint 2004 - Check Regions
Alas, I could not get this solution to work. I set MP.Units = 0 (miles) and called GetLocation(33, -118, 10) to obtain a point over Los Angeles, CA. None of the objects returned by FindResults had a nonempty Region value. It found a couple of highways (I-5 and US-395) and an object with Name = North America. It also returned an object with Name "San Diego", but its StreetAdress was null. I tried a lower altitude (1 mi), but that did not help. Any suggestions? |
| |||
| Re: C#: MapPoint 2004 - Check Regions
Hi, and when StreetAddress is not null, then still both Region and Country are null ?
__________________ rgds, Wilfried Mestdagh www.mestdagh.biz MapPoint coding demo Order MapPoint 2009 with Routing and User Tools Spreadsheet |
| |||
| Re: C#: MapPoint 2004 - Check Regions
I found the problem. The approach does work. It turns out that my choice of coordinates was wrong. I rounded the coordinates of Los Angeles incorrectly. 33N,118W is in fact over the ocean! MP was unable to find any useful objects. When I used 34N,118W and confirmed by loc.Goto() this was in fact over the city, the algorithm worked perfectly. I also checked to see what it returned when the loc was not in a city. I tried 34N,110W and saw this was over the desert in Arizona. Although MP found no location object with a nonnull StreetAddress, it did return a Location of Type geoShowByRegion1, whose Name property was "Arizona". It would seem I can alternatively determine the State by looking for a geoShowByRegion1 Location with a valid US State name. I will now investigate the possibility of finding a more efficient means of locating the State boundary crossings along a great circle route, which is the actual problem at hand. At least it seems this iterative solution will work if I choose test locations along the route. Thank you very much for your help with this! Last edited by kaborka; 12-22-2006 at 02:24 PM. |
| |||
| Re: C#: MapPoint 2004 - Check Regions
Hi, Thank you for feedback. To check out I did some experiments, and it seems that the Location objects in the collection are included geoShowByRegion1, geoShowByRegion2, geoShowByCountry, geoShowByDefault ever, if I'm on a street, city, or not. So I think in your case it is enough to check the type on geoShowByRegion1 and check the Name property.
__________________ rgds, Wilfried Mestdagh www.mestdagh.biz MapPoint coding demo Order MapPoint 2009 with Routing and User Tools Spreadsheet |
| |||
| Re: C#: MapPoint 2004 - Check Regions
__________________ rgds, Wilfried Mestdagh www.mestdagh.biz MapPoint coding demo Order MapPoint 2009 with Routing and User Tools Spreadsheet |
![]() |
| Tags |
| check, mappoint 2004, regions |
| ||||
| Posted By | For | Type | Date | |
| MapPoint Articles - MP2K Magazine | This thread | Refback | 12-16-2006 02:16 AM | |
| Wisconsin Map and Map of Wisconsin - MapPoint State Map Gallery - MP2K Magazine | This thread | Refback | 12-14-2006 07:59 AM | |
| The Magazine for MapPoint - MP2K Magazine | This thread | Refback | 12-12-2006 05:37 AM | |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
| |
| ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Check out if GPS pos is on a Route | kristijan | MapPoint 2006/2009 Discussion | 11 | 04-19-2006 11:46 AM |
| How do I check to see if there is mappoint installed on a sy | dew1969 | MapPoint 2006/2009 Discussion | 3 | 02-18-2004 11:05 AM |
| Territories, regions help please | norty303 | MapPoint 2006/2009 Discussion | 0 | 11-14-2003 10:56 AM |
| Territories - Regions - Reps and other great ideas. | Anonymous | Wish List | 0 | 03-21-2003 01:43 PM |
| MapPoint 2002 Retrieve all regions of a country VB6 | Wim | MapPoint 2006/2009 Discussion | 0 | 11-15-2002 10:45 AM |