From f2ef59264a07ea108cd226f12599411edf8ca794 Mon Sep 17 00:00:00 2001 From: crschmidt Date: Sat, 25 Aug 2007 07:42:11 +0000 Subject: [PATCH] add support for specifying the GeoRSS popup size as an option to the layer. Default behavior stays the same, but you can now specify popupSize as a layer option to the GeoRSS constructor. (Closes #883) git-svn-id: http://svn.openlayers.org/trunk/openlayers@4041 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf --- lib/OpenLayers/Layer/GeoRSS.js | 10 ++++++- tests/Layer/test_GeoRSS.html | 50 ++++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+), 1 deletion(-) diff --git a/lib/OpenLayers/Layer/GeoRSS.js b/lib/OpenLayers/Layer/GeoRSS.js index e2c53d236e..5c2c010b34 100644 --- a/lib/OpenLayers/Layer/GeoRSS.js +++ b/lib/OpenLayers/Layer/GeoRSS.js @@ -40,6 +40,13 @@ OpenLayers.Layer.GeoRSS = OpenLayers.Class(OpenLayers.Layer.Markers, { * for this GeoRSS layer. */ icon: null, + + /** + * APIProperty: popupSize + * {} This determines the size of GeoRSS popups. If + * not provided, defaults to 250px by 120px. + */ + popupSize: null, /** * Constructor: OpenLayers.Layer.GeoRSS @@ -171,7 +178,8 @@ OpenLayers.Layer.GeoRSS = OpenLayers.Class(OpenLayers.Layer.Markers, { data.icon = this.icon == null ? OpenLayers.Marker.defaultIcon() : this.icon.clone(); - data.popupSize = new OpenLayers.Size(250, 120); + + data.popupSize = this.popupSize ? this.popupSize.clone() : new OpenLayers.Size(250, 120); if ((title != null) && (description != null)) { contentHTML = '
[x]
'; contentHTML += '
'; diff --git a/tests/Layer/test_GeoRSS.html b/tests/Layer/test_GeoRSS.html index 9e3ef47c64..3e25b4b605 100644 --- a/tests/Layer/test_GeoRSS.html +++ b/tests/Layer/test_GeoRSS.html @@ -80,6 +80,56 @@ t.eq(map.popups.length, 1, "1st popup gone, 2nd Popup opened correctly"); }); } + function test_Layer_GeoRSS_popups (t) { + t.plan( 8 ); + layer = new OpenLayers.Layer.GeoRSS('Test Layer', georss_txt); + var map = new OpenLayers.Map('map'); + var baseLayer = new OpenLayers.Layer.WMS("Test Layer", + "http://octo.metacarta.com/cgi-bin/mapserv?", + {map: "/mapdata/vmap_wms.map", layers: "basic"}); + map.addLayer(baseLayer); + map.addLayer(layer); + map.setCenter(new OpenLayers.LonLat(0,0),0); + var event = {}; + t.delay_call( 1, function() { + t.ok(layer.markers[0].events, "First marker has an events object"); + t.eq(layer.markers[0].events.listeners['click'].length, 1, "Marker events has one object"); + layer.markers[0].events.triggerEvent('click', event); + t.eq(map.popups.length, 1, "Popup opened correctly"); + t.eq(map.popups[0].size.w, 250, "Popup sized correctly x"); + t.eq(map.popups[0].size.h, 120, "Popup sized correctly y"); + layer.markers[1].events.triggerEvent('click', event); + t.eq(map.popups.length, 1, "1st popup gone, 2nd Popup opened correctly"); + t.eq(map.popups[0].size.w, 250, "Popup sized correctly x"); + t.eq(map.popups[0].size.h, 120, "Popup sized correctly y"); + }); + + } + function test_Layer_GeoRSS_resizedPopups(t) { + layer = new OpenLayers.Layer.GeoRSS('Test Layer', georss_txt, {'popupSize': new OpenLayers.Size(200,100)}); + t.plan( 8 ); + var map = new OpenLayers.Map('map'); + var baseLayer = new OpenLayers.Layer.WMS("Test Layer", + "http://octo.metacarta.com/cgi-bin/mapserv?", + {map: "/mapdata/vmap_wms.map", layers: "basic"}); + map.addLayer(baseLayer); + map.addLayer(layer); + map.setCenter(new OpenLayers.LonLat(0,0),0); + var event = {}; + t.delay_call( 1, function() { + t.ok(layer.markers[0].events, "First marker has an events object"); + t.eq(layer.markers[0].events.listeners['click'].length, 1, "Marker events has one object"); + layer.markers[0].events.triggerEvent('click', event); + t.eq(map.popups.length, 1, "Popup opened correctly"); + t.eq(map.popups[0].size.w, 200, "Popup sized correctly x"); + t.eq(map.popups[0].size.h, 100, "Popup sized correctly y"); + map.popups[0].size.w=300; + layer.markers[1].events.triggerEvent('click', event); + t.eq(map.popups.length, 1, "1st popup gone, 2nd Popup opened correctly"); + t.eq(map.popups[0].size.w, 200, "Popup sized correctly x"); + t.eq(map.popups[0].size.h, 100, "Popup sized correctly y"); + }); + } function test_04_Layer_GeoRSS_icon(t) { t.plan( 3 );