made permalink control more configurable by adding an argParserClass property and separating the logic for generating the key-value pairs from the div and link generation. Original patch by tcoulter. r=euzuro,me (closes #1489)
git-svn-id: http://svn.openlayers.org/trunk/openlayers@7881 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -108,6 +108,32 @@
|
||||
OpenLayers.Util.getElement('edit_permalink').href = './edit.html?zoom=2&lat=0&lon=1.75781&layers=B';
|
||||
t.eq(OpenLayers.Util.getElement('permalink').href, OpenLayers.Util.getElement('edit_permalink').href, "Panning sets permalink with existing zoom in base");
|
||||
}
|
||||
|
||||
function test_Control_Permalink_customized(t) {
|
||||
t.plan(2);
|
||||
|
||||
var argParserClass = OpenLayers.Class(OpenLayers.Control.ArgParser, {
|
||||
CLASS_NAME: "CustomArgParser"
|
||||
});
|
||||
|
||||
control = new OpenLayers.Control.Permalink(null, "./edit.html", {
|
||||
argParserClass: argParserClass,
|
||||
createParams: function(center, zoom, layers) {
|
||||
var params = OpenLayers.Control.Permalink.prototype.createParams.apply(control, arguments);
|
||||
params.customParam = "foo";
|
||||
return params;
|
||||
}
|
||||
});
|
||||
map = new OpenLayers.Map('map');
|
||||
layer = new OpenLayers.Layer.WMS('Test Layer', "http://octo.metacarta.com/cgi-bin/mapserv", {map: '/mapdata/vmap_wms.map', layers: 'basic', format: 'image/jpeg'});
|
||||
map.addLayer(layer);
|
||||
if (!map.getCenter()) map.zoomToMaxExtent();
|
||||
map.addControl(control);
|
||||
map.pan(5, 0, {animate:false});
|
||||
|
||||
t.eq(this.map.controls[this.map.controls.length-1].CLASS_NAME, "CustomArgParser", "Custom ArgParser added correctly.");
|
||||
t.eq(control.div.firstChild.getAttribute("href"), "./edit.html?zoom=2&lat=0&lon=1.75781&layers=B&customParam=foo", "Custom parameter encoded correctly.");
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
Reference in New Issue
Block a user