Geertjan's Blog

  • May 8, 2012

OpenMap & NetBeans Platform

Geertjan Wielenga
Product Manager

OpenMap is an open-source map technology. Integrated into the NetBeans Platform, you can click on a map (below one of the sample maps that comes with the OpenMap download is shown), and then use Lookup to publish items of interest for display in other windows, which can be undocked at startup (and the application can start in full screen mode) with tabs removed, creating the start of a typical mapping solution, such as used in air traffic control systems:

(My mouse isn't shown in the screenshot above, but it is on Ouagadougou in Burkina Faso. Hi Constantine and other NetBeans users in Ouagadougou!) 

Here's the code in the MapTopComponent, which is in the "editor" position above, with the tab removed, so that it covers the whole frame of the application: 

public final class MapTopComponent extends TopComponent {
private final InstanceContent ic = new InstanceContent();
public MapTopComponent() {
setLayout(new BorderLayout());
try {
MapPanel mapPanel = new BasicMapPanel();
MapHandler mapHandler = mapPanel.getMapHandler();
mapHandler.add(new LayerHandler());
MapBean mapBean = mapPanel.getMapBean();
MouseDelegator mouseDelegator = new MouseDelegator();
SelectMouseMode selectMouseMode = new SelectMouseMode();
final MyMapMouseListener myMapMouseListener = new MyMapMouseListener();
ShapeLayer shapeLayer = new ShapeLayer() {
public synchronized MapMouseListener getMapMouseListener() {
return myMapMouseListener;
Properties shapeLayerProps = new Properties();
shapeLayerProps.put("lineColor", "000000");
shapeLayerProps.put("fillColor", "BDDE83");
shapeLayerProps.put("shapeFile", "org/myatc/initializer/dcwpo-browse.shp");
shapeLayerProps.put("spatialIndex", "org/myatc/initializer/dcwpo-browse.ssx");
//Assign properties to ShapeLayer:
//Assign ShapeLayer to MapHandler:
add(mapPanel.getMapBean(), BorderLayout.CENTER);
} catch (MultipleSoloMapComponentException msmce) {
associateLookup(new AbstractLookup(ic));
public class MyMapMouseListener implements MapMouseListener {
public String[] getMouseModeServiceList() {
return new String[]{SelectMouseMode.modeID};
public boolean mouseClicked(MouseEvent e) {
MapMouseEvent mme = (MapMouseEvent) e;
//LatLonPoint latLonPoint = LatLonPoint.getFloat(mme.getLatLon());
//UTMPoint utmPoint = UTMPoint.LLtoUTM(latLonPoint);
//Publish something into Lookup:
ic.set(Collections.singleton(mme.getLatLon()), null);
return true;
public boolean mousePressed(MouseEvent e) {return true;}
public boolean mouseReleased(MouseEvent e) {return true;}
public void mouseEntered(MouseEvent e) {}
public void mouseExited(MouseEvent e) {}
public boolean mouseDragged(MouseEvent e) {return true;}
public boolean mouseMoved(MouseEvent e) {return true;}
public void mouseMoved() {}

Join the discussion

Comments ( 3 )
  • Ranga Thursday, May 31, 2012

    just one word - cool!

  • guest Thursday, June 28, 2012

    Greetings, I am interested in making the integration of OpenMap with NetBean platform, I tried to reproduce the guide published in this article but I have not managed to do, could give me the source of this example.

  • guest Wednesday, July 11, 2012

    woder if openmap can show the streets and streetname?

Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.