How to add an online tiled layer


Follow these steps to add an online tiled layer to your map:

  1. Add the ArcGIS Runtime dependent jar files to the build path of your Java project. You will locate these files in the <ArcGIS Runtime SDK installation directory>/sdk/jars folder laid down at installation.
  2. Import the Swing map component called JMap found in the package.
  3. Add the map (JMap) to the ContentPane of the JFrame. Set the frame's window listener to ensure that the map is disposed of correctly when the window is closed.
    private JFrame theFrame;
    private JMap map;
    theFrame = new JFrame();
    theFrame.setBounds(100, 100, 450, 300);
    theFrame.getContentPane().setLayout(new BorderLayout(0, 0));
    map = new JMap();
  4. Import the tiled map service class found in the package.
  5. Create the ArcGISTiledMapServiceLayer and provide the URL to the map service endpoint. Add the layer to the map's list of layers.
    ArcGISTiledMapServiceLayer tiledLayer = new ArcGISTiledMapServiceLayer(

    Ensure that the map service has a tile cache by opening the URL endpoint in a browser and checking that the 'Single Fused Map Cache' property is true. An ArcGISTiledMapServiceLayer will not work with map services that are not cached; instead these types of services can be displayed with an ArcGISDynamicMapServiceLayer.

  6. Compile and run your application.
  7. Navigate around the map by zooming, panning and using the mouse wheel.