[76] | 1 | /* Copyright (c) 2006-2010 by OpenLayers Contributors (see authors.txt for |
---|
| 2 | * full list of contributors). Published under the Clear BSD license. |
---|
| 3 | * See http://svn.openlayers.org/trunk/openlayers/license.txt for the |
---|
| 4 | * full text of the license. */ |
---|
| 5 | |
---|
| 6 | |
---|
| 7 | /** |
---|
| 8 | * @requires OpenLayers/Layer/WMS.js |
---|
| 9 | * @requires OpenLayers/Tile/Image/IFrame.js |
---|
| 10 | */ |
---|
| 11 | |
---|
| 12 | /** |
---|
| 13 | * Class: OpenLayers.Layer.WMS.Post |
---|
| 14 | * Instances of OpenLayers.Layer.WMS.Post are used to retrieve data from OGC |
---|
| 15 | * Web Mapping Services via HTTP-POST (application/x-www-form-urlencoded). |
---|
| 16 | * Create a new WMS layer with the <OpenLayers.Layer.WMS.Post> constructor. |
---|
| 17 | * |
---|
| 18 | * Inherits from: |
---|
| 19 | * - <OpenLayers.Layer.WMS> |
---|
| 20 | */ |
---|
| 21 | OpenLayers.Layer.WMS.Post = OpenLayers.Class(OpenLayers.Layer.WMS, { |
---|
| 22 | |
---|
| 23 | /** |
---|
| 24 | * Property: tileClass |
---|
| 25 | * {Object} Class, used to create tiles. |
---|
| 26 | */ |
---|
| 27 | tileClass: null, |
---|
| 28 | |
---|
| 29 | /** |
---|
| 30 | * APIProperty: unsupportedBrowsers |
---|
| 31 | * {Array} Array with browsers, which should use the HTTP-GET protocol |
---|
| 32 | * instead of HTTP-POST for fetching tiles from a WMS . |
---|
| 33 | * Defaults to ["mozilla", "firefox", "opera"], because Opera is not able |
---|
| 34 | * to show transparent images in IFrames and Firefox/Mozilla has some ugly |
---|
| 35 | * effects of viewport-shaking when panning the map. Both browsers, Opera |
---|
| 36 | * and Firefox/Mozilla, have no problem with long urls, which is the reason |
---|
| 37 | * for using POST instead of GET. The strings to pass to this array are |
---|
| 38 | * the ones returned by <OpenLayers.Util.getBrowserName()>. |
---|
| 39 | */ |
---|
| 40 | unsupportedBrowsers: ["mozilla", "firefox", "opera"], |
---|
| 41 | |
---|
| 42 | /** |
---|
| 43 | * Property: SUPPORTED_TRANSITIONS |
---|
| 44 | * {Array} |
---|
| 45 | * no supported transitions for this type of layer, because it is not |
---|
| 46 | * possible to modify the initialized tiles (iframes) |
---|
| 47 | */ |
---|
| 48 | SUPPORTED_TRANSITIONS: [], |
---|
| 49 | |
---|
| 50 | /** |
---|
| 51 | * Constructor: OpenLayers.Layer.WMS.Post |
---|
| 52 | * Creates a new WMS layer object. |
---|
| 53 | * |
---|
| 54 | * Example: |
---|
| 55 | * (code) |
---|
| 56 | * var wms = new OpenLayers.Layer.WMS.Post( |
---|
| 57 | * "NASA Global Mosaic", |
---|
| 58 | * "http://wms.jpl.nasa.gov/wms.cgi", |
---|
| 59 | * {layers: "modis, global_mosaic"}); |
---|
| 60 | * (end) |
---|
| 61 | * |
---|
| 62 | * Parameters: |
---|
| 63 | * name - {String} A name for the layer |
---|
| 64 | * url - {String} Base url for the WMS |
---|
| 65 | * (e.g. http://wms.jpl.nasa.gov/wms.cgi) |
---|
| 66 | * params - {Object} An object with key/value pairs representing the |
---|
| 67 | * GetMap query string parameters and parameter values. |
---|
| 68 | * options - {Object} Hashtable of extra options to tag onto the layer. |
---|
| 69 | */ |
---|
| 70 | initialize: function(name, url, params, options) { |
---|
| 71 | var newArguments = []; |
---|
| 72 | newArguments.push(name, url, params, options); |
---|
| 73 | OpenLayers.Layer.WMS.prototype.initialize.apply(this, newArguments); |
---|
| 74 | |
---|
| 75 | this.tileClass = OpenLayers.Util.indexOf( |
---|
| 76 | this.unsupportedBrowsers, OpenLayers.Util.getBrowserName()) != -1 |
---|
| 77 | ? OpenLayers.Tile.Image |
---|
| 78 | : OpenLayers.Tile.Image.IFrame; |
---|
| 79 | }, |
---|
| 80 | |
---|
| 81 | /** |
---|
| 82 | * Method: addTile |
---|
| 83 | * addTile creates a tile, initializes it and adds it as iframe to the |
---|
| 84 | * layer div. |
---|
| 85 | * |
---|
| 86 | * Parameters: |
---|
| 87 | * bounds - {<OpenLayers.Bounds>} |
---|
| 88 | * position - {<OpenLayers.Pixel>} |
---|
| 89 | * |
---|
| 90 | * Returns: |
---|
| 91 | * {<OpenLayers.Tile.Image.IFrame>} The added OpenLayers.Tile.Image.IFrame |
---|
| 92 | */ |
---|
| 93 | addTile: function(bounds,position) { |
---|
| 94 | return new this.tileClass( |
---|
| 95 | this, position, bounds, null, this.tileSize); |
---|
| 96 | }, |
---|
| 97 | |
---|
| 98 | CLASS_NAME: 'OpenLayers.Layer.WMS.Post' |
---|
| 99 | }); |
---|