title: JMapViewer OSM map cannot be dragged
body: <p>I am trying to figure out which mapping tools work best for my java swing based OSM map. Earlier I made a functioning map on the basis of <a href="http://mappanel.svn.sourceforge.net/viewvc/mappanel/com.roots.map/src/com/roots/map/MapPanel.java?revision=37&amp;view=markup" rel="nofollow">MapPanel</a>. Later I could almost clone the application and merely replace MapPanel with <a href="http://www.koders.com/java/fidC94F88CBDBF7178364503105DBA9941391242FC3.aspx?s=TileMap" rel="nofollow">JMapViewer</a> to get this working as well. I prefer the latter as it has the functionality of putting markers and polygons on the map. The drawback however is that for some reason I cannot drag the map with the mouse. In the package of JMapViewer there is a Demo class which displays the same behaviour. How can I make the OSM map draggable within JMapViewer?</p>
  
  <p>Edit: This code will draw a map that can be displayed in a panel <em>and</em> make the map draggable by adding a <code>mapController</code> and <code>setMovementMouseButton()</code>.</p>
  
  <pre><code>private JMapViewer drawOpenStreetMap(double lon, double lat, int zoom) {
      mapViewer = new JMapViewer();
      mapViewer.setZoom(zoom);
      mapViewer.setDisplayPositionByLatLon(lat, lon, zoom);
      mapViewer.repaint();
      DefaultMapController mapController = new DefaultMapController(mapViewer);
      mapController.setMovementMouseButton(MouseEvent.BUTTON1);
      mapViewer.addMapMarker(new MapMarkerDot(52, 5.5));
      return mapViewer;
  }
  </code></pre>