Index: /applications/editors/josm/plugins/slippymap/josm-slippymap.launch
===================================================================
--- /applications/editors/josm/plugins/slippymap/josm-slippymap.launch	(revision 22848)
+++ /applications/editors/josm/plugins/slippymap/josm-slippymap.launch	(revision 22848)
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<launchConfiguration type="org.eclipse.jdt.launching.localJavaApplication">
+<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
+<listEntry value="/JOSM/src/org/openstreetmap/josm/gui/MainApplication.java"/>
+</listAttribute>
+<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
+<listEntry value="1"/>
+</listAttribute>
+<stringAttribute key="org.eclipse.jdt.launching.JRE_CONTAINER" value="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JDK 6"/>
+<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.openstreetmap.josm.gui.MainApplication"/>
+<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="slippymap"/>
+</launchConfiguration>
Index: /applications/editors/josm/plugins/slippymap/src/org/openstreetmap/josm/plugins/slippymap/SlippyMapLayer.java
===================================================================
--- /applications/editors/josm/plugins/slippymap/src/org/openstreetmap/josm/plugins/slippymap/SlippyMapLayer.java	(revision 22847)
+++ /applications/editors/josm/plugins/slippymap/src/org/openstreetmap/josm/plugins/slippymap/SlippyMapLayer.java	(revision 22848)
@@ -38,6 +38,4 @@
 import org.openstreetmap.josm.actions.RenameLayerAction;
 import org.openstreetmap.josm.data.Bounds;
-import org.openstreetmap.josm.data.Preferences.PreferenceChangeEvent;
-import org.openstreetmap.josm.data.Preferences.PreferenceChangedListener;
 import org.openstreetmap.josm.data.coor.LatLon;
 import org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor;
@@ -57,5 +55,5 @@
  *
  */
-public class SlippyMapLayer extends Layer implements PreferenceChangedListener, ImageObserver,
+public class SlippyMapLayer extends Layer implements ImageObserver,
     TileLoaderListener {
     boolean debug = false;
@@ -263,11 +261,8 @@
                     public void layerRemoved(Layer oldLayer) {
                     	MapView.removeLayerChangeListener(this);
-                        Main.pref.removePreferenceChangeListener(SlippyMapLayer.this);
                     }
                 });
             }
         });
-
-        Main.pref.addPreferenceChangeListener(this);
     }
 
@@ -879,6 +874,4 @@
         }
 
-        int fontHeight = g.getFontMetrics().getHeight();
-
         g.setColor(Color.DARK_GRAY);
 
@@ -962,5 +955,4 @@
             ts.loadAllTiles(false); // make sure there are tile objects for all tiles
         Tile clickedTile = null;
-        Point p1 = null, p2 = null;
         for (Tile t1 : ts.allTiles()) {
             Tile t2 = tempCornerTile(t1);
@@ -1040,30 +1032,3 @@
         return x * 45.0 / Math.pow(2.0, zoom - 3) - 180.0;
     }
-
-    /*
-     * (non-Javadoc)
-     *
-     * @seeorg.openstreetmap.josm.data.Preferences.PreferenceChangedListener#
-     * preferenceChanged(java.lang.String, java.lang.String)
-     */
-    public void preferenceChanged(PreferenceChangeEvent event) {
-        if (event.getKey().startsWith(SlippyMapPreferences.PREFERENCE_PREFIX)) {
-            // System.err.println(this + ".preferenceChanged('" + key + "', '"
-            // + newValue + "') called");
-            // when fade background changed, no need to clear tile storage
-            // TODO move this code to SlippyMapPreferences class.
-            if (!event.getKey().equals(SlippyMapPreferences.PREFERENCE_FADE_BACKGROUND)) {
-                autoZoomPopup.setSelected(SlippyMapPreferences.getAutozoom());
-            }
-            if (event.getKey().equals(SlippyMapPreferences.PREFERENCE_TILE_SOURCE)) {
-                newTileStorage();
-            }
-            redraw();
-        }
-    }
-
-    @Override
-    public void destroy() {
-        Main.pref.removePreferenceChangeListener(SlippyMapLayer.this);
-    }
 }
Index: /applications/editors/josm/plugins/slippymap/src/org/openstreetmap/josm/plugins/slippymap/SlippyMapPlugin.java
===================================================================
--- /applications/editors/josm/plugins/slippymap/src/org/openstreetmap/josm/plugins/slippymap/SlippyMapPlugin.java	(revision 22847)
+++ /applications/editors/josm/plugins/slippymap/src/org/openstreetmap/josm/plugins/slippymap/SlippyMapPlugin.java	(revision 22848)
@@ -1,5 +1,9 @@
 package org.openstreetmap.josm.plugins.slippymap;
 
+import java.util.List;
+
 import org.openstreetmap.josm.Main;
+import org.openstreetmap.josm.data.Preferences.PreferenceChangeEvent;
+import org.openstreetmap.josm.data.Preferences.PreferenceChangedListener;
 import org.openstreetmap.josm.gui.MapFrame;
 import org.openstreetmap.josm.gui.preferences.PreferenceSetting;
@@ -13,14 +17,16 @@
  *
  */
-public class SlippyMapPlugin extends Plugin
+public class SlippyMapPlugin extends Plugin implements PreferenceChangedListener
 {
     public SlippyMapPlugin(PluginInformation info)
     {
     	super(info);
+    	Main.pref.addPreferenceChangeListener(this);
     }
 
-    public void mapFrameInitialized(MapFrame oldFrame, MapFrame newFrame)
+    @Override
+	public void mapFrameInitialized(MapFrame oldFrame, MapFrame newFrame)
     {
-        if (newFrame != null){
+        if (newFrame != null && SlippyMapPreferences.getMapSource() != SlippyMapPreferences.NO_DEFAULT_TILE_SOURCE) {
             SlippyMapLayer smlayer;
             smlayer = new SlippyMapLayer();
@@ -40,3 +46,39 @@
     }
 
+    /*
+     * (non-Javadoc)
+     *
+     * @seeorg.openstreetmap.josm.data.Preferences.PreferenceChangedListener#
+     * preferenceChanged(java.lang.String, java.lang.String)
+     */
+    public void preferenceChanged(PreferenceChangeEvent event) {
+    	if (!Main.isDisplayingMapView()) {
+    		return;
+    	}
+    	List<SlippyMapLayer> layes = Main.map.mapView.getLayersOfType(SlippyMapLayer.class);
+    	assert layes.size() <= 1;
+    	SlippyMapLayer layer = layes.isEmpty()?null:layes.get(0);
+
+        if (event.getKey().equals(SlippyMapPreferences.PREFERENCE_TILE_SOURCE)) {
+        	if (layer == null && SlippyMapPreferences.getMapSource() != SlippyMapPreferences.NO_DEFAULT_TILE_SOURCE) {
+        		Main.map.mapView.addLayer(new SlippyMapLayer());
+        	} else if (layer != null && SlippyMapPreferences.getMapSource() == SlippyMapPreferences.NO_DEFAULT_TILE_SOURCE) {
+        		Main.map.mapView.removeLayer(layer);
+        	} else if (layer == null && SlippyMapPreferences.getMapSource() == SlippyMapPreferences.NO_DEFAULT_TILE_SOURCE) {
+        		// Do nothing
+        	} else {
+        		layer.newTileStorage();
+        	}
+        } else  if (event.getKey().startsWith(SlippyMapPreferences.PREFERENCE_PREFIX) && layer != null) {
+            // System.err.println(this + ".preferenceChanged('" + key + "', '"
+            // + newValue + "') called");
+            // when fade background changed, no need to clear tile storage
+            // TODO move this code to SlippyMapPreferences class.
+            if (!event.getKey().equals(SlippyMapPreferences.PREFERENCE_FADE_BACKGROUND)) {
+                layer.autoZoomPopup.setSelected(SlippyMapPreferences.getAutozoom());
+            }
+            layer.redraw();
+        }
+    }
+
 }
Index: /applications/editors/josm/plugins/slippymap/src/org/openstreetmap/josm/plugins/slippymap/SlippyMapPreferenceSetting.java
===================================================================
--- /applications/editors/josm/plugins/slippymap/src/org/openstreetmap/josm/plugins/slippymap/SlippyMapPreferenceSetting.java	(revision 22847)
+++ /applications/editors/josm/plugins/slippymap/src/org/openstreetmap/josm/plugins/slippymap/SlippyMapPreferenceSetting.java	(revision 22848)
@@ -2,4 +2,9 @@
 
 import static org.openstreetmap.josm.tools.I18n.tr;
+
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.util.ArrayList;
+import java.util.List;
 
 import javax.swing.Box;
@@ -11,12 +16,6 @@
 import javax.swing.JSpinner;
 import javax.swing.SpinnerNumberModel;
-import java.awt.event.ActionListener;
-import java.awt.event.ActionEvent;
-import java.util.Collection;
 
-import org.openstreetmap.gui.jmapviewer.*;
-import org.openstreetmap.gui.jmapviewer.interfaces.*;
-
-import org.openstreetmap.josm.gui.preferences.PreferenceDialog;
+import org.openstreetmap.gui.jmapviewer.interfaces.TileSource;
 import org.openstreetmap.josm.gui.preferences.PreferenceSetting;
 import org.openstreetmap.josm.gui.preferences.PreferenceTabbedPane;
@@ -34,5 +33,5 @@
      */
     private JComboBox tileSourceCombo;
-    
+
     private JCheckBox autozoomActive = new JCheckBox(tr("autozoom"));
     private JCheckBox autoloadTiles = new JCheckBox(tr("autoload tiles"));
@@ -40,5 +39,5 @@
     private JSpinner minZoomLvl = new JSpinner();
     private JSlider fadeBackground = new JSlider(0, 100);
-    
+
     public void addGui(PreferenceTabbedPane gui)
     {
@@ -47,5 +46,6 @@
         //String description = tr("A plugin that adds to JOSM new layer. This layer could render external tiles.");
         JPanel slippymapTab = gui.createPreferenceTab("slippymap.png", tr("SlippyMap"), tr("Settings for the SlippyMap plugin."));
-        Collection<TileSource> allSources = SlippyMapPreferences.getAllMapSources();
+        List<TileSource> allSources = new ArrayList<TileSource>(SlippyMapPreferences.getAllMapSources());
+        allSources.add(0, SlippyMapPreferences.NO_DEFAULT_TILE_SOURCE);
         //Collection<String> allSources = SlippyMapPreferences.getAllMapNames();
         tileSourceCombo = new JComboBox(allSources.toArray());
@@ -55,17 +55,17 @@
         slippymapTab.add(GBC.glue(5, 0), GBC.std());
         slippymapTab.add(tileSourceCombo, GBC.eol().fill(GBC.HORIZONTAL));
-        
+
         slippymapTab.add(new JLabel(tr("Auto zoom: ")), GBC.std());
         slippymapTab.add(GBC.glue(5, 0), GBC.std().fill(GBC.HORIZONTAL));
         slippymapTab.add(autozoomActive, GBC.eol().fill(GBC.HORIZONTAL));
-        
+
         slippymapTab.add(new JLabel(tr("Autoload Tiles: ")), GBC.std());
         slippymapTab.add(GBC.glue(5, 0), GBC.std().fill(GBC.HORIZONTAL));
         slippymapTab.add(autoloadTiles, GBC.eol().fill(GBC.HORIZONTAL));
-        
+
         slippymapTab.add(new JLabel(tr("Min zoom lvl: ")), GBC.std());
         slippymapTab.add(GBC.glue(5, 0), GBC.std().fill(GBC.HORIZONTAL));
         slippymapTab.add(this.minZoomLvl, GBC.eol().fill(GBC.HORIZONTAL));
-        
+
         slippymapTab.add(new JLabel(tr("Max zoom lvl: ")), GBC.std());
         slippymapTab.add(GBC.glue(5, 0), GBC.std().fill(GBC.HORIZONTAL));
@@ -75,5 +75,5 @@
         slippymapTab.add(GBC.glue(5, 0), GBC.std().fill(GBC.HORIZONTAL));
         slippymapTab.add(this.fadeBackground, GBC.eol().fill(GBC.HORIZONTAL));
-        
+
         slippymapTab.add(Box.createVerticalGlue(), GBC.eol().fill(GBC.VERTICAL));
 
@@ -128,5 +128,5 @@
         this.fadeBackground.setValue(Math.round(SlippyMapPreferences.getFadeBackground()*100f));
     }
-    
+
     /**
      * <p>
@@ -139,5 +139,5 @@
     public boolean ok()
     {
-        SlippyMapPreferences.setMapSource((TileSource)this.tileSourceCombo.getSelectedItem());
+    	SlippyMapPreferences.setMapSource((TileSource)this.tileSourceCombo.getSelectedItem());
         SlippyMapPreferences.setAutozoom(this.autozoomActive.isSelected());
         SlippyMapPreferences.setAutoloadTiles(this.autoloadTiles.isSelected());
Index: /applications/editors/josm/plugins/slippymap/src/org/openstreetmap/josm/plugins/slippymap/SlippyMapPreferences.java
===================================================================
--- /applications/editors/josm/plugins/slippymap/src/org/openstreetmap/josm/plugins/slippymap/SlippyMapPreferences.java	(revision 22847)
+++ /applications/editors/josm/plugins/slippymap/src/org/openstreetmap/josm/plugins/slippymap/SlippyMapPreferences.java	(revision 22848)
@@ -1,11 +1,14 @@
 package org.openstreetmap.josm.plugins.slippymap;
 
+import static org.openstreetmap.josm.tools.I18n.tr;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import org.openstreetmap.gui.jmapviewer.OsmTileSource;
+import org.openstreetmap.gui.jmapviewer.OsmTileSource.AbstractOsmTileSource;
+import org.openstreetmap.gui.jmapviewer.interfaces.TileSource;
 import org.openstreetmap.josm.Main;
-import java.util.List;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Map;
-import org.openstreetmap.gui.jmapviewer.*;
-import org.openstreetmap.gui.jmapviewer.interfaces.*;
 
 /**
@@ -18,4 +21,5 @@
 public class SlippyMapPreferences
 {
+	public static final String NO_DEFAULT_TILE_SOURCE_NAME = "{%no_default%}";
     public static final String PREFERENCE_PREFIX   = "slippymap";
 
@@ -35,4 +39,5 @@
     public static final int DEFAULT_MIN_ZOOM = 2;
 
+
     public static TileSource getMapSource()
     {
@@ -42,21 +47,25 @@
     public static TileSource getMapSource(String name)
     {
+    	if (NO_DEFAULT_TILE_SOURCE_NAME.equals(name)) {
+    		return NO_DEFAULT_TILE_SOURCE; // User don't want to load slippy layer on startup
+    	}
+
         List<TileSource> sources = SlippyMapPreferences.getAllMapSources();
-        TileSource source = sources.get(0);
+
         if (name == null || "".equals(name)) {
-            name = source.getName();
-            Main.pref.put(PREFERENCE_TILE_SOURCE, name);
-        }
+            Main.pref.put(PREFERENCE_TILE_SOURCE, sources.get(0).getName());
+            return sources.get(0);
+        }
+
         for (TileSource s : sources) {
-            if (!name.equals(s.getName()))
-                continue;
-            source = s;
-            break;
-        }
-        return source;
+            if (name.equals(s.getName()))
+            	return s;
+        }
+
+        return sources.get(0);
     }
 
     public static void setMapSource(TileSource source) {
-    	Main.pref.put(SlippyMapPreferences.PREFERENCE_TILE_SOURCE, source.getName());
+    	Main.pref.put(SlippyMapPreferences.PREFERENCE_TILE_SOURCE, source == NO_DEFAULT_TILE_SOURCE?NO_DEFAULT_TILE_SOURCE_NAME:source.getName());
     }
 
@@ -236,4 +245,10 @@
     }
 
+    public static TileSource NO_DEFAULT_TILE_SOURCE = new AbstractOsmTileSource(tr("(none)"), "") {
+		public TileUpdate getTileUpdate() {
+			return null;
+		}
+    };
+
     public static class Coastline extends OsmTileSource.AbstractOsmTileSource {
         public Coastline() {
@@ -266,9 +281,11 @@
         }
 
-        public int getMaxZoom() {
+        @Override
+		public int getMaxZoom() {
             return 21;
         }
 
-        public String getTilePath(int zoom, int tilex, int tiley) {
+        @Override
+		public String getTilePath(int zoom, int tilex, int tiley) {
             return "z=" + zoom + "&x=" + tilex + "&y=" + tiley;
         }
@@ -278,5 +295,5 @@
         }
     }
-    
+
 
     public static class HaitiImagery extends OsmTileSource.AbstractOsmTileSource {
@@ -285,9 +302,11 @@
         }
 
-        public int getMaxZoom() {
+        @Override
+		public int getMaxZoom() {
             return 21;
         }
 
-        public String getTilePath(int zoom, int tilex, int tiley) {
+        @Override
+		public String getTilePath(int zoom, int tilex, int tiley) {
         	return "/" + zoom + "/" + tilex + "/" + tiley + ".png";
         }
