public static void main(String[] args) {
        JXMapViewer mapViewer = new JXMapViewer();

        // Display the viewer in a JFrame
        JFrame frame = new JFrame("JXMapviewer2 Example 8");
        frame.getContentPane().add(mapViewer);
        frame.setSize(800, 600);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setVisible(true);

        // Create a TileFactoryInfo for OpenStreetMap
        TileFactoryInfo info = new OSMTileFactoryInfo();
        final DefaultTileFactory tileFactory = new DefaultTileFactory(info);
        tileFactory.addTileListener(new TileListener() {

            @Override
            public void tileLoaded(Tile tile) {
                if (tileFactory.getPendingTiles() == 0) {
                    System.out.println("All tiles loaded!");
                }

            }
        });
        mapViewer.setTileFactory(tileFactory);

        GeoPosition frankfurt = new GeoPosition(50, 7, 0, 8, 41, 0);
        GeoPosition wiesbaden = new GeoPosition(50, 5, 0, 8, 14, 0);
        GeoPosition mainz = new GeoPosition(50, 0, 0, 8, 16, 0);

        // Create a track from the geo-positions
        List<GeoPosition> track = Arrays.asList(frankfurt, wiesbaden, mainz);

        // Set the focus
        mapViewer.zoomToBestFit(new HashSet<GeoPosition>(track), 0.7);
    }
public static void main ( String [ ] args ) { JXMapViewer mapViewer = new JXMapViewer ( ) ; JFrame frame = new JFrame ( "JXMapviewer2 Example 8" ) ; frame . getContentPane ( ) . add ( mapViewer ) ; frame . setSize ( 800 , 600 ) ; frame . setDefaultCloseOperation ( JFrame . EXIT_ON_CLOSE ) ; frame . setVisible ( true ) ; TileFactoryInfo info = new OSMTileFactoryInfo ( ) ; final DefaultTileFactory tileFactory = new DefaultTileFactory ( info ) ; tileFactory . addTileListener ( new TileListener ( ) { @ Override public void tileLoaded ( Tile tile ) { if ( tileFactory . getPendingTiles ( ) == 0 ) { System . out . println ( "All tiles loaded!" ) ; } } } ) ; mapViewer . setTileFactory ( tileFactory ) ; GeoPosition frankfurt = new GeoPosition ( 50 , 7 , 0 , 8 , 41 , 0 ) ; GeoPosition wiesbaden = new GeoPosition ( 50 , 5 , 0 , 8 , 14 , 0 ) ; GeoPosition mainz = new GeoPosition ( 50 , 0 , 0 , 8 , 16 , 0 ) ; List < GeoPosition > track = Arrays . asList ( frankfurt , wiesbaden , mainz ) ; mapViewer . zoomToBestFit ( new HashSet < GeoPosition > ( track ) , 0.7 ) ; }
@param args the program args (ignored)