开发者

JXMapKit help to get started

I recently came across JXMapKit, I'm not a strong programmer but would like to use this in my application. I'm using Eclipse and have build GUI application. I would like to incorporate JXMapKit into my GUI. I have ArrayList of latitutude/longitude using the coordinates I want to display overlay of开发者_运维百科 a path on the map.

From what I read it can be easily incorporated into Swing but haven't found examples simple enough for me to understand and get me started. I created a new project and just wanted to bring up the map but ran into errors. From what I understood it couldn't load tiles? Could it be a bad jar file or do I need to set tile provider? Thanks in advance for any help.

import javax.swing.JFrame;
import org.jdesktop.swingx.JXMapKit;
import org.jdesktop.swingx.JXMapKit.DefaultProviders;

public class MapTest {
    public static void createGui(){
        JFrame frame = new JFrame();
        frame.setVisible(true);
        frame.setSize(400, 400);
        JXMapKit mapViewer = new JXMapKit();
        mapViewer.setDefaultProvider(DefaultProviders.OpenStreetMaps);
        mapViewer.setDataProviderCreditShown(true);
        frame.add(mapViewer);
    }

    public static void main(String[] args){
        createGui();
    }
}

and these are the errors:

Failed to load a tile at url: http://tile.openstreetmap.org/6/32/21.png
 java.lang.NoSuchMethodError: org.jdesktop.swingx.util.PaintUtils.loadCompatibleImage(Ljava/io/InputStream;)Ljava/awt/image/BufferedImage;
 at org.jdesktop.swingx.mapviewer.DefaultTileFactory$TileRunner.run(DefaultTileFactory.java:375)
 at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
 at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
 at java.util.concurrent.FutureTask.run(Unknown Source)
 at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
 at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
 at java.lang.Thread.run(Unknown Source)

If I take out the setDefaultProvider set to OpenStreetMaps it'll still fail to load the default provider.


mapViewer.setDefaultProvider(DefaultProviders.OpenStreetMaps);

change for

mapViewer.setDefaultProvider(org.jdesktop.swingx.JXMapKit.DefaultProviders.OpenStreetMaps);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜