ArcGISLocalTiledLayer tiledLayer = new ArcGISLocalTiledLayer("/path/to/map.tpk"); tiledLayer.setName("Nautical Chart"); getLayers().add(tiledLayer);
Frame_buffer_OGL::init_ FAILED to create_ FramebufferName Frame_buffer_OGL::init_ FAILED to create_ FramebufferName Frame_buffer_OGL::init_ FAILED to create_ FramebufferName Frame_buffer_OGL::init_ FAILED to create_ FramebufferName ...
The crash on exit may be due to failing to call dispose on a JMap instance. In the latest release it is necesary to call dispose. If you look in the sample code you will see one way of doing this - disposing the JMap in the window closing event.
// Create embedding composite Composite comp = new Composite(this,SWT.EMBEDDED | SWT.DOUBLE_BUFFERED); comp.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); comp.setLayout(new FillLayout()); // Create AWT container Frame f = SWT_AWT.new_Frame(comp); JApplet japp = new JApplet(); map = new ArcMap(); // extends JMap // Add map to container f.add(japp); japp.add(map); f.setVisible(true);
// start workaround LocalTiledLayer.main(); // add map dispose listeners addDisposeListener(new DisposeListener() { @Override public void widgetDisposed(DisposeEvent e) { map.dispose(); LocalTiledLayer.dispose(); } });
I was doing some testing and accidentally discovered a janky workaround...
I was thinking that the only difference between the working samples and my application is that mine is built in Eclipse RCP with SWT, using an SWT-AWT bridge to contain the JMap ...
I have no clue whatsoever why this works... but it WORKS!
I am not using SWT on my app but I'm still seeing this, so I want to see if it can work for me. Assuming that you're using org.eclipse.swt-3.1.jar on your sample app, how did you construct the Composite "comp" object? What is "this" being passed as parent Composite?
import org.eclipse.swt.*; import org.eclipse.swt.graphics.Rectangle; import org.eclipse.swt.widgets.*; Display display = new Display (); Shell shell = new Shell (display); // insert stuff in shell shell.open (); while (!shell.isDisposed()) if (!display.readAndDispatch ()) display.sleep (); display.dispose ();
The ArcGIS map is embedded in an Eclipse RCP View Part, which is passed a Composite parent to its createPartControl interface. Another way of doing it is to just create an SWT window and build from that. The shell is a Composite you can add items directly to.
The crash on exit may be due to failing to call dispose on a JMap instance. In the latest release it is necesary to call dispose. If you look in the sample code you will see one way of doing this - disposing the JMap in the window closing event.
public class MapDisposeApp { private JFrame window; private JMap map; public MapDisposeApp() { window = new JFrame(); window.setSize(800, 600); window.setLocationRelativeTo(null); // center on screen window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); window.getContentPane().setLayout(new BorderLayout(0, 0)); window.addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent windowEvent) { super.windowClosing(windowEvent); // map.dispose(); } }); map = new JMap(); window.getContentPane().add(map); // ArcGISTiledMapServiceLayer tiledLayer = new ArcGISTiledMapServiceLayer( // "http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer"); // map.getLayers().add(tiledLayer); } /** * @param args */ public static void main(String[] args) { EventQueue.invokeLater(new Runnable() { @Override public void run() { try { MapDisposeApp application = new MapDisposeApp(); application.window.setVisible(true); } catch (Exception e) { e.printStackTrace(); } } }); } }