For the latest version of JMP Help, visit JMP.com/help.


Scripting Guide > Scripting Graphs > Create Background Maps
Publication date: 11/29/2021

Create Background Maps

Background maps can be scripted in JSL. You can write a script that creates a graph and then turns on the background map in the script.

There are two types of background maps: Images() and Boundaries(). Each of these takes a parameter, which is the name of the map to use. The name is one of the maps listed in the window.

For Images(), the choices are Simple Earth, Detailed Earth, NASA, Street Map Service, and Web Map Service. If you use Web Map Service, then there are two additional parameters: the WMS URL and the layer supported by the WMS server.

For Boundaries(), the choices vary since boundaries can be user-defined. A typical choice is World.

The following example uses the Simple Earth as an image and World as a boundary:

dt = Open( "$SAMPLE_DATA/Air Traffic.jmp" );
dt << Graph Builder(
	Size( 1101, 603 ),
	Show Control Panel( 0 ),
	Variables( X( :Longitude ), Y( :Latitude ) ),
	Elements( Points( X, Y, Legend( 8 ) ) ),
	SendToReport(
		Dispatch(
			{},
			"Graph Builder",
			Frame Box,
			{Background Map( Images( "Simple Earth" ), Boundaries( "World" ) ),
			Grid Line Order( 3 ), Reference Line Order( 4 )}
		)
	)
);

Figure 12.31 shows an excerpt from the map:

Figure 12.31 JSL Scripting Example 

JSL Scripting Example

To change the script to use a WMS server, the command would look like this:

Background Map ( Images ( "Web Map Service", "http://sedac.ciesin.columbia.edu/geoserver/wms", "gpw-v3:gpw-v3-population-density_2000" ), Boundaries ( "US States" ) )

To see which layers are available on a WMS server, install the WMS Explorer Add-In. Download the add-in from the JMP File Exchange at https://community.jmp.com/docs/DOC-6095. Note that some WMS servers are not reliable. If the server is down, or if the user does not have an Internet connection, the WMS map does not appear.

Tips:

To see the syntax for the JSL script, add a background map through the user interface. Then from the red triangle menu, select Save Script > To Script Window to see the script that is generated.

To specify image and boundary names in the JSL script, use the names shown in the Set Background Map window. (Right-click a map and select Graph > Background Map).

Look at sample data to find examples of background map scripts. Select Help > Sample Data Library and open Napoleons March.jmp, Pollutants Map.jmp, or San Francisco Crime.jmp. Right-click the map table script and select Edit to see the Background Map() function.

Want more information? Have questions? Get answers in the JMP User Community (community.jmp.com).