MapPanel

Java based browsing of openstreetmap tiles (or the like). This is a EPL (Eclipse Public License) licensed Swing-Component meant for reuse. A single file is enough to bring mapping to your (java-swing) application. Sourcecode is provided as is and without warranty.

An SWT port of the mappanel with a nicer showcase application than the swing one exists as well. Check it out.

Zoom with mousewheel and doubleclicks left/right. Use Viewmenu to float into a top-level desktop window. This application uses the openstreemap.org tileserver and is just a simple 1 classfile interactive browser for the tiledatabase. Alternatively use CTRL+2 to switch to another tileserver. API support longitude/latitude but no GIS database is hooked up right now. See javadoc comments in the MapPanel class for more details. EPL License. Contact author via stepan.rutz AT gmx.de.

Example screenshot 1

Example screenshot 2

Try a demo right now

Webstart MapPanel now
Download executable .jar file here


(In case you want to make 100% sure you get the latest version you can empty your webstart cache with the following line)
javaws -uninstall http://mappanel.sourceforge.net/mappanel.jnlp

Use menu of ctrl+1 or ctrl+2 to switch between tileservers for different rendering styles.

Note that data is loaded from external servers http://gazetteer.openstreetmap.org/, http://tile.openstreetmap.org/ and http://tah.openstreetmap.org. The MapPanel application is just a very simple Java Viewer for the data provided by openstreetmap.org. If you see error messages saying that tileservers cannot be reached this can be caused by either a complete lack of an internet connection (in which case you are out of luck) or by a restricted connection where you are forced to use a http(s) proxy-server. The later is often the case in companies which do not allow unrestricted access to the internet. In this case you need to set the system properties httpProxy.host and maybe also httpProxy.port via -D command line options. For https these properties are named https.proxyHost and https.proxyPort. You can also set these properties programmatically from java. An excellent in depth explanation can be found at
http://java.sun.com/javase/6/docs/technotes/guides/net/proxies.html.

Developer info

The entire viewer runs using standard jdk version 1.5 or newer and is just a single Java file. Sourcecode can be found below.

Using the MapPanel works as follows:

MapPanel mapPanel = new MapPanel(); // just a JPanel extension, add to any swing/awt container
mapPanel.setZoom(10); // set some zoom level (1-18 are valid)
double lon = 6.94;
double lat = 50.95;
Point position = mapPanel.computePosition(new Point2D.Double(long, lat));
mapPanel.setCenterPosition(position); // sets to the computed position
mapPanel.repaint(); // if already visible trigger a repaint here
You can check out the calls to the namefinder in the MapPanel sourcecode on how to get the lon/lat coordinates for points of interest. This is done when you search in the search-panel on the left hand side of the demo.

JavaFX

Check out this site for a quick JavaFX hack that uses the MapPanel from within JavaFX: http://mappanel.sourceforge.net/javafx/

Epilog

Acknowledgments for feedback, testing, fixing, suggestions, improvements go to: Everyone at openstreetmap.org, Ricky Clarkson, Werner de Bruijn.

Contact author: stepan.rutz AT gmx.de . Feedback etc is more than welcome.