| | 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 | */ |
| | 50 | mapfish.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 | } |