GSUtil.extend(GSImageMapLayer,GSTileLayer);function GSImageMapLayer(c,d,a,b){this.options={imageMapHostname:"",imageMapPathTemplate:"",imageMapMimetype:"text/html"};GSUtil.merge(b,this.options);GSImageMapLayer.baseConstructor.call(this,c,d,a,this.options);this.type="GSImageMapLayer";this.tileClass=GSImageMapTile;this.imageMapContainer=undefined}GSImageMapLayer.prototype.createContainer=function(){GSImageMapLayer.superClass.createContainer.call(this);this.imageMapContainer=GSUtil.createContainer(this.map.imageMapContainer,"GSImageMapLayer",null,null,0,0,null)};GSUtil.extend(GSImageMapTile,GSTile);function GSImageMapTile(h,c,f,d,b,a,e,g){GSImageMapTile.baseConstructor.call(this,h,c,f,d,b,a,e,g);this.imageMapId="map_"+this.id;this.imageMapWrapper=undefined;this.xhr=new GSXHR({onSuccess:GSUtil.bind(this.imageMapRequestSuccess,this),onFailure:GSUtil.bind(this.imageMapRequestFailure,this),method:"get"});this.imageMapUrl=this.parent.options.getTileUrl(this.parent.options.imageMapHostname,this.parent.options.imageMapPathTemplate,this.tileBounds,this.mpx,this.parent.options.imageMapMimetype)}GSImageMapTile.prototype.display=function(){GSImageMapTile.superClass.display.call(this);this.imageElement.style.cursor="auto";if(this.imageMapUrl){if(!document.getElementById(this.imageMapId)){this.xhr.send(this.imageMapUrl)}else{this.imageElement.useMap="#"+this.imageMapId}}};GSImageMapTile.prototype.imageMapRequestSuccess=function(a){if(!this.validateData(a)){return}this.imageMapWrapper=GSUtil.createElement("div");this.imageMapWrapper.innerHTML=a;this.parent.imageMapContainer.appendChild(this.imageMapWrapper);var b=this.imageMapWrapper.getElementsByTagName("map")[0];b.name=b.id=this.imageMapId;this.imageElement.useMap="#"+this.imageMapId};GSImageMapTile.prototype.validateData=function(a){if(!a){return false}if(a.charAt(a.length-1)=="\n"){a=a.slice(0,-1)}return(a.substring(0,4)=="<map")&&(a.slice(-4)=="map>")};GSImageMapTile.prototype.imageMapRequestFailure=function(a){if(_globals.DEBUG){console.log("ImageMap request failed: "+a)}};GSImageMapTile.prototype.release=function(){GSImageMapTile.superClass.release.call(this)};GSImageMapTile.prototype.removeFromContainer=function(){GSImageMapTile.superClass.removeFromContainer.call(this);if(this.imageMapWrapper){this.parent.imageMapContainer.removeChild(this.imageMapWrapper)}};if(window.GSModule&&GSModule.moduleLoaded){GSModule.moduleLoaded("imagemap-layer")};