Changeset 462

Show
Ignore:
Timestamp:
04/25/08 10:36:30 (5 years ago)
Author:
fvanderbiest
Message:

fixed #111 : added mapfish.Util.getIconUrl in order to retrieve layerTree icons

Location:
trunk/MapFish/client/mfbase/mapfish
Files:
2 added
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/MapFish/client/mfbase/mapfish/core/Util.js

    r415 r462  
    3232    return Math.min.apply({}, array); 
    3333}; 
     34 
     35/** 
     36 * Function: getIconUrl 
     37 * Builds the URL for a layer icon, based on a WMS GetLegendGraphic request. 
     38 *  
     39 * Parameters: 
     40 * wmsUrl - {String} The URL of a WMS server. 
     41 * options - {Object} The options to set in the request: 
     42 *                    'layer' - the name of the layer for which the icon is requested (required) 
     43 *                    'rule' - the name of a class for this layer (this is set to the layer name if not specified) 
     44 *                    'format' - "image/png" by default 
     45 *                    ...  
     46 *  
     47 * Returns: 
     48 * {String} The URL at which the icon can be found. 
     49 */ 
     50mapfish.Util.getIconUrl = function(wmsUrl, options) { 
     51    if (!options.layer) { 
     52        OpenLayers.Console.warn( 
     53            'Missing required layer option in mapfish.Util.getIconUrl'); 
     54        return ''; 
     55    } 
     56    if (!options.rule) { 
     57        options.rule = options.layer; 
     58    } 
     59    var url = wmsUrl + ((wmsUrl.indexOf('?') != (wmsUrl.length - 1)) ? '?' : ''); 
     60    var options = OpenLayers.Util.extend({ 
     61        layer: "", 
     62        rule: "", 
     63        service: "WMS", 
     64        version: "1.1.1", 
     65        request: "GetLegendGraphic", 
     66        format: "image/png", 
     67        width: 16, 
     68        height: 16 
     69    }, options); 
     70    options = OpenLayers.Util.upperCaseObject(options); 
     71    return url + OpenLayers.Util.getParameterString(options); 
     72} 
  • trunk/MapFish/client/mfbase/mapfish/tests/list-tests.html

    r441 r462  
    11<ul id="testlist">  
     2    <li>core/test_Util.html</li> 
    23    <li>widgets/tree/test_LayerTree.html</li> 
    34    <li>widgets/tree/test_LayerTree_separator.html</li>