0

JAVA/SWING /jxmapviewer I want to render map without internet ,I use jxmapviewer library but can't read osm file . i see they use OSMTileFactoryInfo to load zip osm but i don't know how or what the type of zip file must i have.

    public static void main(String\[\] args) {
   
        TileFactoryInfo info = new OSMTileFactoryInfo("ZIP archive", "jar:file:/C:/Users/HP/Documents/syria-latest-free.shp.zip!");
        TileFactory tileFactory = new DefaultTileFactory(info); 
    // Setup JXMapViewer
    final JXMapViewer mapViewer = new JXMapViewer();
    mapViewer.setTileFactory(tileFactory);

    GeoPosition frankfurt = new GeoPosition(50.11, 8.68);

    // Set the focus
    mapViewer.setZoom(7);
    mapViewer.setAddressLocation(frankfurt);

    // Add interactions
    MouseInputListener mia = new PanMouseInputListener(mapViewer);
    mapViewer.addMouseListener(mia);
    mapViewer.addMouseMotionListener(mia);
    mapViewer.addMouseWheelListener(new ZoomMouseWheelListenerCursor(mapViewer));

    // Display the viewer in a JFrame
    final JFrame frame = new JFrame();
    frame.setLayout(new BorderLayout());
    frame.add(new JLabel("Use left mouse button to pan and mouse wheel to zoom"), BorderLayout.NORTH);
    frame.add(mapViewer);
    frame.setSize(800, 600);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setTitle("JXMapviewer2 Example 9 - Offline maps");
    frame.setVisible(true);
}

}

m19v
  • 1,800
  • 4
  • 11
  • 26
hani bani
  • 1
  • 3
  • I think `OSMTileFactoryInfo` expects a file with pre-rendered map tiles (images) whereas you specify a shp file (which contains raw data, not pre-rendered tiles). – scai Nov 02 '22 at 12:12
  • can you offer any site for those files you talk about – hani bani Nov 02 '22 at 12:19
  • Unfortunately I can't. However, you could start to [render your own tiles](https://wiki.openstreetmap.org/wiki/Rendering). For example with Maperitive. – scai Nov 03 '22 at 11:21

0 Answers0