Basic level

Download Sample Viewer

Description

This sample shows how you license your application to use Basic level functionality. This involves setting the Client ID in your application. See http://developers.arcgis.com for details on how to obtain a Client ID.

Code snippet


    // set the Client ID
    ArcGISRuntime.setClientID("Your Client ID");

Sample Code

/* Copyright 2014 Esri

All rights reserved under the copyright laws of the United States
and applicable international laws, treaties, and conventions.

You may freely redistribute and use this sample code, with or
without modification, provided you include the original copyright
notice and use restrictions.

See the use restrictions.*/
package com.esri.client.samples.licensing;

import java.awt.BorderLayout;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

import javax.swing.JComponent;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;

import com.esri.map.JMap;
import com.esri.map.MapOptions;
import com.esri.map.MapOptions.MapType;
import com.esri.runtime.ArcGISRuntime;

/**
 * This sample shows how you license your application to use Basic functionality.
 * This involves setting the Client ID in your application.
 * <p>
 * See http://developers.arcgis.com for details on how to obtain a Client ID.
 */
public class BasicLevelApp {

  private JMap map;

  // default constructor
  public BasicLevelApp() { }

  // ------------------------------------------------------------------------
  // Core functionality
  // ------------------------------------------------------------------------
  private void initLicense() {
    // for basic license, set the Client ID
    // see http://developers.arcgis.com for details on how to obtain a Client ID.
    // ArcGISRuntime.setClientID("Your Client ID");
  }

  /**
   * Starting point of this application.
   * @param args arguments to this application.
   */
  public static void main(String[] args) {
    SwingUtilities.invokeLater(new Runnable() {
      @Override
      public void run() {
        try {
          // instance of this application
          BasicLevelApp app = new BasicLevelApp();

          // setup license
          app.initLicense();

          // create the UI, including the map, for the application.
          JFrame appWindow = app.createWindow();
          appWindow.add(app.createUI());
          appWindow.setVisible(true);
        } catch (Exception e) {
          // on any error, display the stack trace.
          e.printStackTrace();
        }
      }
    });
  }

  /**
   * Creates and displays the UI, including the map, for this application.
   */
  public JComponent createUI() throws Exception {

    // application content
    JPanel contentPane = new JPanel(new BorderLayout());

    // map options: topographic map, centered at lat-lon (0,0), zoom level 1
    MapOptions mapOptions = new MapOptions(MapType.TOPO, 0, 0, 1);

    // create the map using MapOptions
    map = new JMap(mapOptions);
    contentPane.add(map);

    return contentPane;
  }

  private JFrame createWindow() {
    JFrame window = new JFrame("Licensing - Basic");
    window.setSize(1000, 600);
    window.setLocationRelativeTo(null);
    window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    window.getContentPane().setLayout(new BorderLayout());
    window.addWindowListener(new WindowAdapter() {
      @Override
      public void windowClosing(WindowEvent windowEvent) {
        super.windowClosing(windowEvent);
        map.dispose();
      }
    });
    return window;
  }
}
Feedback on this topic?