/* Copyright (c) 2006-2011 by OpenLayers Contributors (see authors.txt for * full list of contributors). Published under the Clear BSD license. * See http://svn.openlayers.org/trunk/openlayers/license.txt for the * full text of the license. */ /** * @requires OpenLayers/Tile/Image.js */ /** * Constant: OpenLayers.Tile.Image.IFrame * Mixin for tiles that use form-encoded POST requests to get images from * remote services. Images will be loaded using HTTP-POST into an IFrame. * * This mixin will be applied to instances * configured with set. * * Inherits from: * - */ OpenLayers.Tile.Image.IFrame = { /** * Property: useIFrame * {Boolean} true if we are currently using an IFrame to render POST * responses, false if we are using an img element to render GET responses. */ useIFrame: null, /** * Property: blankImageUrl * {String} This is only used as background image for the eventPane, so we * don't care that this doesn't actually result in a blank image on all * browsers */ blankImageUrl: "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAQAIBRAA7", /** * Method: updateBackBuffer * Update the , and return a new or reposition the * backBuffer. When a backbuffer is returned, the tile's markup is not * available any more. * * Returns: * {HTMLDivElement} the tile's markup in a cloned element, or undefined if * no backbuffer is currently available or needed */ updateBackBuffer: function() { this.url = this.layer.getURL(this.bounds); var usedIFrame = this.useIFrame; this.useIFrame = this.maxGetUrlLength !== null && !this.layer.async && this.url.length > this.maxGetUrlLength; var fromIFrame = usedIFrame && !this.useIFrame; var toIFrame = !usedIFrame && this.useIFrame; if (fromIFrame || toIFrame) { // switch between get (image) and post (iframe) this.clear(); if (this.imgDiv && this.imgDiv.parentNode === this.frame) { this.frame.removeChild(this.imgDiv); } this.imgDiv = null; if (fromIFrame) { // remove eventPane this.frame.removeChild(this.frame.firstChild); this.resetBackBuffer(); } } if (!this.useIFrame) { OpenLayers.Tile.Image.prototype.updateBackBuffer.apply(this, arguments); } }, /** * Method: createImage * Creates the content for the frame on the tile. */ createImage: function() { if (this.useIFrame === true) { if (!this.frame.childNodes.length) { var eventPane = document.createElement("div"), style = eventPane.style; style.position = "absolute"; style.width = "100%"; style.height = "100%"; style.zIndex = 1; style.backgroundImage = "url(" + this.blankImageUrl + ")"; this.frame.appendChild(eventPane); } var id = this.id + '_iFrame', iframe; if (parseFloat(navigator.appVersion.split("MSIE")[1]) < 9) { // Older IE versions do not set the name attribute of an iFrame // properly via DOM manipulation, so we need to do it on our own with // this hack. iframe = document.createElement('