The "State Identification Game" was released in 2012 and has gotten a lot of attention from both gamers and developers.
The concept is the game is very simple. The game shows the outline of a random U.S. state and asks you to identify the state. The outline of the state and surrounding states as well as water bodies (major lakes and oceans) can all be used as clues to identify the state. It sounds simple, but I did in fact miss a few before practicing a little bit.
The compiled game can be downloaded here --
State Identification Game Using MapPoint - Can You Do It? - Blogs - MapPoint Forums
In this article, we will publish the code used to set up the game as well as the code for the game itself.
Game Setup
There were two main steps involved in setting up the game and making sure it would work. 1) Figuring out the MapFeatures layers & codes to turn off labels and extraneous symbols. (Obviously the purpose of the game would be defeated if the name of the state was prominently displayed on the map!) and 2) Ensure that the map zooms to the correct geography for all states. There were a couple states such as "New York" for which MapPoint would zoom to the city of the same name rather than the state.
So, the first thing I tackled was the MapFeatures layer names and code. MapFeatures is MapPoint's internal object name for controlling the map layers which is done in the interface via the Map Settings pane introduced with MapPoint 2010 ( Cool MapPoint 2010 Maps! ).
This is the code used to list all the layers and the current detail level.
I pasted the list into an Excel worksheet to view the list. I realized that to turn off all "label" layers, I would simply need to see if the last six characters in the layer names is "Labels". Also, the map looks better with city points turned off, so the resulting code to actually manipulate the labels is:Code:Private Sub EnumerateMapFeatures() Set APP = CreateObject("MapPoint.Application") APP.Visible = True Set MAP = APP.ActiveMap Dim MF As MapFeature Stop 'to set some detail levels For Each MF In MAP.MapFeatures Debug.Print MF.Name & "|" & MF.Index & "|" & MF.DetailLevel Next '1 = default, 2 = more, 3 = none End Sub
For more information on programming with the MapFeatures collection, see: http://www.mp2kmag.com/a158--mapfeatures.mappoint.htmlCode:Private Sub TurnOffAllLabels() Dim MF As MapFeature For Each MF In MAP.MapFeatures If Right(MF.Name, 6) = "Labels" Or MF.Name = "Populated Places - Town/Other Place (0 - 99,999) - Symbols" Then MF.DetailLevel = 3 Next End Sub
To loop over a list of the U.S. states to test to make sure the program zooms to the correct geography, the code is below. You can see the code to wait three seconds before going to the next state.
Download the spreadsheet with source code discussed above here http://www.MapForums.com/MapPoint_Game_Setup.zipCode:Do While Cells(row, 1) <> "" Set loc = MAP.FindPlaceResults(Cells(row, 1) & ", United States")(1) loc.Goto newHour = Hour(Now()) newMinute = Minute(Now()) newSecond = Second(Now()) + 3 waitTime = TimeSerial(newHour, newMinute, newSecond) Application.Wait waitTime row = row + 1 Loop
You can see there is also a worksheet listing countries. The game could easily be adapted as a Country Identification Game! Both the Country list and the U.S. State list data were copied from Wikipedia.
In the next article we will discuss the actual code for the game.