diff --git a/lib/OpenLayers/Events.js b/lib/OpenLayers/Events.js index 80a95ff7ee..cab2027e8a 100644 --- a/lib/OpenLayers/Events.js +++ b/lib/OpenLayers/Events.js @@ -406,7 +406,6 @@ OpenLayers.Events = OpenLayers.Class({ initialize: function (object, element, eventTypes, fallThrough) { this.object = object; this.element = element; - this.eventTypes = eventTypes; this.fallThrough = fallThrough; this.listeners = {}; @@ -416,11 +415,13 @@ OpenLayers.Events = OpenLayers.Class({ this.handleBrowserEvent, this ); + this.eventTypes = []; + // if eventTypes is specified, create a listeners list for each // custom application event. - if (this.eventTypes != null) { - for (var i = 0; i < this.eventTypes.length; i++) { - this.addEventType(this.eventTypes[i]); + if (eventTypes != null) { + for (var i = 0; i < eventTypes.length; i++) { + this.addEventType(eventTypes[i]); } } @@ -454,10 +455,13 @@ OpenLayers.Events = OpenLayers.Class({ * * Parameters: * eventName - {String} + * dontAddMe - {Boolean} */ addEventType: function(eventName) { if (!this.listeners[eventName]) { this.listeners[eventName] = []; + + this.eventTypes.push(eventName); } }, diff --git a/lib/OpenLayers/Map.js b/lib/OpenLayers/Map.js index 3e553afa9d..4fa5c8e246 100644 --- a/lib/OpenLayers/Map.js +++ b/lib/OpenLayers/Map.js @@ -404,6 +404,7 @@ OpenLayers.Map = OpenLayers.Class({ this.id = OpenLayers.Util.createUniqueID("OpenLayers.Map_"); this.div = OpenLayers.Util.getElement(div); + OpenLayers.Element.addClass(this.div, 'olMap'); // the viewPortDiv is the outermost div we modify var id = this.div.id + "_OpenLayers_ViewPort"; diff --git a/tests/Map.html b/tests/Map.html index 2c1542c037..6acc365388 100644 --- a/tests/Map.html +++ b/tests/Map.html @@ -7,7 +7,7 @@ var map; function test_Map_constructor (t) { - t.plan( 10 ); + t.plan( 11 ); map = new OpenLayers.Map('map'); var baseLayer = new OpenLayers.Layer.WMS("Test Layer", @@ -15,6 +15,8 @@ {map: "/mapdata/vmap_wms.map", layers: "basic"}); map.addLayer(baseLayer); + t.ok( OpenLayers.Element.hasClass(map.div, "olMap"), "Map div has olMap class"); + t.ok( map instanceof OpenLayers.Map, "new OpenLayers.Map returns object" ); if (!isMozilla) { t.ok( true, "skipping element test outside of Mozilla"); diff --git a/theme/default/style.css b/theme/default/style.css index 757d0b87ea..909aeeaeb0 100644 --- a/theme/default/style.css +++ b/theme/default/style.css @@ -1,3 +1,8 @@ +div.olMap { + padding: 0px!important; + margin: 0px!important; +} + div.olMapViewport { text-align: left; }