Geographical Maps in BRIDGES

How does the Map API work BRIDGES?

Maps in BRIDGES are retrieved from GeoJSON descriptions of the map geometry. Currently, we support both the US map and World map. The current interface permits US maps to be colored by state or by county. The color can reflect any user chosen attibute, such as population, sales, crime rates, etc. and is dependent on the data being mapped to the state.

Counties for the US map can also be displayed and attributes assigned similar to states. For instance, election data can be mapped to each county for a more detailed look of voting patterns over the years.

In addition, maps can be a background for other BRIDGES data structures. For instance, you can image graph problems being solved as a function of the US cities (Minimum Spanning Tree, Traveling Salesman Problem, etc.)

In this tutorial, we will illustrate the basic UI capabilities of BRIDGES Maps that will be helpful in building map based assignments.






This tutorial gives an introduction to the use of maps in BRIDGES.

See also

  1. Color [Java] [C++] [Python]
  2. USMap [Java] [C++] [Python]
  3. USState [Java] [C++] [Python]
  4. USCounty [Java] [C++] [Python]
  5. WorldMap [Java] [C++] [Python]

1. Getting Started: Build a US Map with State boundaries

In the first part of the tutorial, we will create a US map of all states showing each state's boundary. A city is marked as a linked list node and will be the data structure for this tutorial. The map uses a default color for each state's boundary and a default fill color for each state.

If you follow the URL given to you when the application runs, it will get to the Bridges webpage that shows your output. You do not need to be logged into your BRIDGES account to see the output. If you are logged into your account, the output will show up in your gallery.

Java
C++
Python

2. Drawing US Map with all counties

The map you created in the first part had just the states drawn as polygons. Here will add the counties for each state. The map continues to use default attributes for boundary and fill colors.

Check out the links to the classes (listed above) that supports these attributes and also details the possible colors and shapes you can use and how to specify them.

Here is the code that generated the map output with counties.

Java
C++
o
Python

3. Advanced Features: Displaying specific states, choosing attributes.

In the last part of this tutorial, we show some advanced and customizable features with maps. We show the ability to select specific states to be drawn with custom attributes with boundary and fill colors. This will be needed when the colors are related to a data attribute, for instance, population size, election results in each county, per-capita income, business sales by state, etc. In these instances, we need to look at each state or county and apply a specific color representing the data attribute. This tutorial illustrates how to iterate through the counties of a state and set fill/boundary colors at the state or county level.

Java
C++
Python

4. Overlaying a Data Structure on a Map.

BRIDGES also supports displaying a map behind a standard BRIDGES Data Structure. This is only supported for node based visualization like linked lists and graphs. You display your data structure as usual. You set the location of the nodes of your data structures using latitude and longitude coordinates. Instead of passing the Map as a data structure, you pass it as an overlay.

In the following exmaple, we set a node at the location of Charlotte, NC in Mecklenburg County.

Java
C++
Python

5. Using World Maps

You can also show or overlay on a map of the world rather than a map of the US by using the WorldMap object. It has fewer features, so one just needs to create a WorldMap object and pass it to Bridges.setMap().

Well done! You’ve just created your first Bridges based Map! Congrats on completing this tutorial

Going Further

Check Bridges assignment page for map based assignments