window.GSVectorGraphicsConstants={resourceURL:(document.location.protocol.indexOf("http")==-1?"http:":document.location.protocol)+"//api.geosmart.co.nz/images/svg-v1-rc3/"};GSUtil.extend(GSVectorGraphics,GSMapFeature);function GSVectorGraphics(a){this.options={style:{fill:"#3886d9","fill-opacity":0.3,stroke:"#3886d9","stroke-width":"1px","stroke-opacity":0.9,"stroke-linejoin":"round","stroke-linecap":"round"},textStyle:{"font-family":"Helvetica, Arial, Sans-serif","font-size":"12px","font-weight":"normal","font-style":"normal",color:"black"}};GSUtil.merge(a,this.options);GSVectorGraphics.baseConstructor.call(this,this.options);this.textEl=undefined;if(_browser.svg){this.textEl=document.createElementNS(_globals.svgns,"text");this.textEl.setAttributeNS(null,"pointer-events","none")}else{if(_browser.isIE6up){this.textEl=document.createElement(_globals.vmlnsPrefix,":textbox")}}this.resizeToLayer=false;this.isShowingInfo=false;this.setText(this.options.text,this.options["text-position"],this.options["text-style"])}GSVectorGraphics.prototype.setText=function(e,b,c){this.text=e;this.textPosition=b||new GSPoint(0,0);if(this.text){while(this.textEl.firstChild){this.textEl.removeChild(this.textEl.firstChild)}var a=document.createTextNode(this.text);this.textEl.appendChild(a)}for(var d in c){this.options.textStyle[d]=c[d]}if(_browser.svg){this.textEl.setAttributeNS(null,"font-family",this.options.textStyle["font-family"]);this.textEl.setAttributeNS(null,"font-size",this.options.textStyle["font-size"]);this.textEl.setAttributeNS(null,"font-weight",this.options.textStyle["font-weight"]);this.textEl.setAttributeNS(null,"font-style",this.options.textStyle["font-style"]);this.textEl.setAttributeNS(null,"fill",this.options.textStyle.color)}else{if(_browser.isIE6up){this.textEl.style.fontFamily=this.options.textStyle["font-family"];this.textEl.style.fontSize=this.options.textStyle["font-size"];this.textEl.style.fontWeight=this.options.textStyle["font-weight"];this.textEl.style.fontStyle=this.options.textStyle["font-style"];this.textEl.style.color=this.options.textStyle.color}}if(this.onmap&&this.text){this.renderText()}};GSVectorGraphics.prototype.renderText=function(){var a=this.getBounds();var j=this.map.translateToMapCoordinate(new GSPoint(a.minX,a.maxY));var h=this.map.translateToMapCoordinate(new GSPoint(a.maxX,a.maxY));var b=this.map.translateToMapCoordinate(new GSPoint(a.minX,a.minY));if(_browser.svg){if(this.options.textStyle["display-threshold"]<this.map.scaleIdx){this.textEl.setAttributeNS(null,"visibility","hidden");return}else{this.textEl.setAttributeNS(null,"visibility","visible")}if(this.options.textStyle["text-align"]){var e=0;switch(this.options.textStyle["text-align"]){case"left":break;case"center":var g=this.textEl.getComputedTextLength();var f=h.x-j.x;e=(f-g)/2;break;case"right":this.textEl.setAttributeNS(null,"text-anchor","end");e=h.x-j.x;break}this.textEl.setAttributeNS(null,"x",j.x+e)}else{this.textEl.setAttributeNS(null,"x",j.x+this.textPosition.x)}if(this.options.textStyle["vertical-align"]){switch(this.options.textStyle["vertical-align"]){case"top":this.textEl.setAttributeNS(null,"y",j.y+this.textEl.getBBox().height);break;case"middle":var i=this.textEl.getBBox().height;var c=b.y-j.y;var d=(c-i)/2;this.textEl.setAttributeNS(null,"y",j.y+this.textEl.getBBox().height+d);break;case"bottom":this.textEl.setAttributeNS(null,"y",b.y);break}}else{this.textEl.setAttributeNS(null,"y",j.y+this.textEl.getBBox().height+this.textPosition.y)}}else{if(_browser.isIE6up){if(this.options.textStyle["display-threshold"]<this.map.scaleIdx){this.textEl.style.visibility="hidden";return}else{this.textEl.style.visibility="visible"}this.textEl.style.position="relative";this.textEl.style.left=0;this.textEl.style.top=0;var f=Math.round(h.x)-Math.round(j.x);var c=Math.round(b.y)-Math.round(j.y);this.textEl.style.height=c+"px";if(this.options.textStyle["text-align"]){this.graphicsEl.style.textAlign=this.options.textStyle["text-align"]}else{this.textEl.style.paddingLeft=this.textPosition.x+"px"}if(this.options.textStyle["vertical-align"]){var i=parseInt(this.options.textStyle["font-size"]);switch(this.options.textStyle["vertical-align"]){case"top":this.textEl.style.top=0;break;case"middle":this.textEl.style.top=((c-i)/2)>=0?((c-i)/2):0;break;case"bottom":this.textEl.style.top=(c-i);break}}else{this.textEl.style.top=this.textPosition.y}}}};GSVectorGraphics.prototype.getBounds=function(){};GSVectorGraphics.prototype.getStyle=function(){return this.options.style};GSVectorGraphics.prototype.setStyle=function(a){for(var c in a){var b=a[c];switch(c){case"stroke":this.setStroke(b);break;case"stroke-width":this.setStrokeWidth(b);break;case"stroke-opacity":this.setStrokeOpacity(b);break;case"stroke-linecap":this.setStrokeLinecap(b);break;case"stroke-linejoin":this.setStrokeLinejoin(b);break;case"stroke-style":this.setStrokeStyle(b);break;case"fill":this.setFill(b);break;case"fill-opacity":this.setFillOpacity(b);break;case"opacity":this.setOpacity(b);break;default:this.graphicsEl.style[c]=b;break}}};GSVectorGraphics.prototype.getStroke=function(){return this.options.style.stroke};GSVectorGraphics.prototype.setStroke=function(a){this.options.style.stroke=a;return this._setStroke(a)};GSVectorGraphics.prototype._setStroke=function(a){if(_browser.svg){this.setStyleProperty("stroke",a)}else{if(_browser.isIE6up){var b=this.getChildElement(this.graphicsEl,"stroke");if(b=="none"){this.setStyleProperty("on",false,b)}else{this.setStyleProperty("color",a,b)}}}return this};GSVectorGraphics.prototype.getStrokeWidth=function(){return parseInt(this.options.style["stroke-width"])};GSVectorGraphics.prototype.setStrokeWidth=function(a){this.options.style["stroke-width"]=a;return this._setStrokeWidth(a)};GSVectorGraphics.prototype._setStrokeWidth=function(a){if(_browser.svg){this.setStyleProperty("stroke-width",a)}else{if(_browser.isIE6up){var b=this.getChildElement(this.graphicsEl,"stroke");var c=""+a;if(isNaN(parseInt(c.charAt(c.length-1),10))==false){a+="px"}this.setStyleProperty("weight",a,b)}}return this};GSVectorGraphics.prototype.getStrokeOpacity=function(){return parseFloat(this.options.style["stroke-opacity"])};GSVectorGraphics.prototype.setStrokeOpacity=function(a){this.options.style["stroke-opacity"]=a;return this._setStrokeOpacity(a)};GSVectorGraphics.prototype._setStrokeOpacity=function(a){if(_browser.svg){this.setStyleProperty("stroke-opacity",a)}else{if(_browser.isIE6up){var b=this.getChildElement(this.graphicsEl,"stroke");this.setStyleProperty("opacity",a,b)}}return this};GSVectorGraphics.prototype.getStrokeLinecap=function(){return this.options.style["stroke-linecap"]};GSVectorGraphics.prototype.setStrokeLinecap=function(a){this.options.style["stroke-linecap"]=a;return this._setStrokeLinecap(a)};GSVectorGraphics.prototype._setStrokeLinecap=function(a){if(_browser.svg){this.setStyleProperty("stroke-linecap",a)}else{if(_browser.isIE6up){var b=this.getChildElement(this.graphicsEl,"stroke");this.setStyleProperty("endcap",a,b)}}return this};GSVectorGraphics.prototype.getStrokeLinejoin=function(){return this.options.style["stroke-linejoin"]};GSVectorGraphics.prototype.setStrokeLinejoin=function(a){this.options.style["stroke-linejoin"]=a;return this._setStrokeLinejoin(a)};GSVectorGraphics.prototype._setStrokeLinejoin=function(a){if(_browser.svg){this.setStyleProperty("stroke-linejoin",a)}else{if(_browser.isIE6up){var b=this.getChildElement(this.graphicsEl,"stroke");this.setStyleProperty("joinstyle",a,b)}}return this};GSVectorGraphics.prototype.getStrokeStyle=function(){return this.options.style["stroke-style"]};GSVectorGraphics.prototype.setStrokeStyle=function(a){this.options.style["stroke-style"]=a;return this._setStrokeStyle(a)};GSVectorGraphics.prototype._setStrokeStyle=function(a){if(_browser.svg){if(a=="solid"){this.setStyleProperty("stroke-dasharray","none")}else{this.setStyleProperty("stroke-dasharray",this.options.style["stroke-width"])}}else{if(_browser.isIE6up){var b=this.getChildElement(this.graphicsEl,"stroke");if(a=="solid"){this.setStyleProperty("stroke-dasharray","1",b)}else{this.setStyleProperty("dashstyle","1 1",b)}}}return this};GSVectorGraphics.prototype.getFill=function(){return this.options.style.fill};GSVectorGraphics.prototype.setFill=function(a){this.options.style.fill=a;return this._setFill(a)};GSVectorGraphics.prototype._setFill=function(a){if(_browser.svg){this.setStyleProperty("fill",a)}else{if(_browser.isIE6up){var b=this.getChildElement(this.graphicsEl,"fill");if(a=="none"){this.setStyleProperty("on",false,b)}else{this.setStyleProperty("color",a,b)}}}return this};GSVectorGraphics.prototype.getFillOpacity=function(){return parseFloat(this.options.style["fill-opacity"])};GSVectorGraphics.prototype.setFillOpacity=function(a){this.options.style["fill-opacity"]=a;return this._setFillOpacity(a)};GSVectorGraphics.prototype._setFillOpacity=function(a){if(_browser.svg){this.setStyleProperty("fill-opacity",a)}else{if(_browser.isIE6up){var b=this.getChildElement(this.graphicsEl,"fill");this.setStyleProperty("opacity",a,b)}}return this};GSVectorGraphics.prototype.getOpacity=function(){return parseFloat(this.options.style.opacity)};GSVectorGraphics.prototype.setOpacity=function(a){this.options.style.opacity=a;return this._setOpacity(a)};GSVectorGraphics.prototype._setOpacity=function(c){if(_browser.svg){this.setStyleProperty("opacity",c)}else{if(_browser.isIE6up){var a=GSUtil.roundNumber(c*this.options.style["fill-opacity"],2);this._setFillOpacity(a);var b=GSUtil.roundNumber(c*this.options.style["stroke-opacity"],2);this._setStrokeOpacity(b)}}return this};GSVectorGraphics.prototype.setStyleProperty=function(b,d,c){if(!c){c=this.graphicsEl}var a="";if(_browser.svg){a=c.getAttributeNS(null,b);c.setAttributeNS(null,b,d)}else{if(_browser.isIE6up){a=c.getAttribute(b);c[b]=d}}if(this.onmap){this.map.container.scrollLeft=this.map.container.scrollLeft}this.broadcastMessage("shapeStyleChanged",this,b,a,d)};GSVectorGraphics.prototype.getChildElement=function(c,a){var b=null;if(_browser.svg){b=c.getElementsByTagNameNS(_globals.svgns,a)[0]}else{if(_browser.isIE6up){b=c.getElementsByTagName(a)[0]}}if(!b){if(_browser.svg){b=document.createElementNS(_globals.svgns,a)}else{if(_browser.isIE6up){b=document.createElement(_globals.vmlnsPrefix+":"+a)}}c.appendChild(b)}return b};GSVectorGraphics.prototype.setVisible=function(a){this.visible=a;if(this.graphicsEl){if(_browser.svg){this.graphicsEl.setAttributeNS(null,"visibility",(a===true?"visible":"hidden"))}else{if(_browser.isIE6up){this.graphicsEl.style.visibility=(a===true?"visible":"hidden")}}}if(this.onmap&&this.visible){this.render()}};GSVectorGraphics.prototype.addToLayer=function(a){if(!a.vectorContainer){a.vectorContainer=a.createVectorContainer()}if(_browser.svg){GSUtil.makeUnselectable(this.graphicsEl);GSUtil.makeUnselectable(this.textEl);a.vectorContainer.appendChild(this.graphicsEl);a.vectorContainer.appendChild(this.textEl)}else{if(_browser.isIE6up){if(this.resizeToLayer){this.graphicsEl.style.width=a.map.pxWidth;this.graphicsEl.style.height=a.map.pxHeight;this.graphicsEl.coordsize=a.map.pxWidth+" "+a.map.pxHeight}this.graphicsEl.setAttribute("unselectable","on");this.textEl.setAttribute("unselectable","on");a.vectorContainer.appendChild(this.graphicsEl);this.graphicsEl.appendChild(this.textEl)}}GSVectorGraphics.superClass.addToLayer.call(this,a)};GSVectorGraphics.prototype.render=function(){if(this.text){this.renderText()}};GSVectorGraphics.prototype.mapResized=function(a){if(_browser.isIE6up){if(this.resizeToLayer){this.graphicsEl.style.width=a.pxWidth;this.graphicsEl.style.height=a.pxHeight;this.graphicsEl.coordsize=a.pxWidth+" "+a.pxHeight}}this.render()};GSVectorGraphics.prototype.getInfoWindowOptions=function(){return{title:this.type}};GSVectorGraphics.prototype.remove=function(){if(this.snappable){this.layer.map.removeSnappable(this)}try{if(_browser.svg){this.layer.vectorContainer.removeChild(this.graphicsEl);this.layer.vectorContainer.removeChild(this.textEl)}else{if(_browser.isIE6up){this.graphicsEl.removeChild(this.textEl);this.layer.vectorContainer.removeChild(this.graphicsEl)}}}catch(a){}GSVectorGraphics.superClass.remove.call(this)};if(_browser.isIE6up){var ss=document.createStyleSheet();ss.cssText="v\\:group, v\\:oval, v\\:line, v\\:shape, v\\:rect, v\\:roundrect, v\\:textbox, v\\:stroke, v\\:fill { behavior: url(#default#VML);";(function(){var b=false;for(var a=0;a<document.namespaces.length;a++){if(document.namespaces[a].name=="v"){b=true;break}}if(!b){document.namespaces.add("v","urn:schemas-microsoft-com:vml")}})()}GSUtil.extend(GSPolyline,GSVectorGraphics);function GSPolyline(b,a){this.options={style:{fill:"none",stroke:"blue","stroke-opacity":0.6,"stroke-width":"7px"}};GSUtil.merge(a,this.options);GSPolyline.baseConstructor.call(this,this.options);this.type="GSPolyline";this.resizeToLayer=true;this.graphicsEl=undefined;if(_browser.svg){this.graphicsEl=document.createElementNS(_globals.svgns,"polyline")}else{if(_browser.isIE6up){this.graphicsEl=document.createElement(_globals.vmlnsPrefix+":shape")}}this.setStyle(this.options.style);this.points=b;this.points.indexOf=function(d){for(var e=0,c=this.length;e<c;e++){if(this[e]==d){return e}}return -1}}GSPolyline.prototype.clickHandler=function(a){if(!this.options.isDrawFeature){GSPolyline.superClass.clickHandler.call(this,a)}};GSPolyline.prototype.setPoints=function(a){this.points=a;this.render()};GSPolyline.prototype.getPoints=function(){return this.points};GSPolyline.prototype.addPoint=function(a){this.points.push(a);this.render()};GSPolyline.prototype.addPointAt=function(b,a){this.points.splice(a,0,b);this.render()};GSPolyline.prototype.replacePoint=function(b,c){var a=this.points.indexOf(c);this.points.splice(a,1,b);this.render()};GSPolyline.prototype.removePoint=function(a){for(var c=0,b=this.points.length;c<b;c++){if(a.equals(this.points[c])){this.points.splice(c,1);if(this.onmap){this.render()}return true}}return false};GSPolyline.prototype.removePointAt=function(a){this.points.splice(a,1);if(this.onmap){this.render()}return true};GSPolyline.prototype.render=function(){if(this.isVisible()){GSPolyline.superClass.render.call(this);if(this.points){var c=this.translateToMapPoints();if(_browser.svg){this.graphicsEl.setAttributeNS(null,"points",c);this.layer.map.container.scrollLeft=this.layer.map.container.scrollLeft}else{if(_browser.isIE6up){var b=c[0];var a=c[1];c.splice(0,2);var d="m "+b+","+a+" l "+c.join(",")+" e";this.graphicsEl.style.display="none";this.graphicsEl.path=d;this.graphicsEl.style.display=""}}}}};GSPolyline.prototype.translateToMapPoints=function(){var d=[];for(var c=0,b=this.points.length;c<b;c++){var a=this.points[c];var e=this.map.translateToMapCoordinate(a);d.push(Math.round(e.x));d.push(Math.round(e.y))}return d};GSPolyline.prototype.getBounds=function(){var a=GSUtil.getMinimum(GSUtil.getPropertyArray(this.points,"x"));var d=GSUtil.getMinimum(GSUtil.getPropertyArray(this.points,"y"));var c=GSUtil.getMaximum(GSUtil.getPropertyArray(this.points,"x"));var b=GSUtil.getMaximum(GSUtil.getPropertyArray(this.points,"y"));return new GSBounds(a,d,c,b)};GSPolyline.prototype.getInfoWindowPosition=function(){return this.points[Math.round(this.points.length/2)-1]};GSPolyline.prototype.toJson=function(){var a={type:this.type,style:GSUtil.toCC(this.options.style),points:this.getPoints(),visible:this.visible};if(this.options.text){a.text=this.options.text;a.textPosition=this.options.textPosition;a.textStyle=GSUtil.toCC(this.options.textStyle)}return GSUtil.objToJson(a)};GSPolyline.prototype.toWKT=function(){var d=[];for(var c=0,b=this.points.length;c<b;c++){var a=this.points[c];d.push(a.x+" "+a.y)}return"LINESTRING("+d.join(",")+")"};GSPolyline.prototype.toGML=function(){var d=[];for(var c=0,b=this.points.length;c<b;c++){var a=this.points[c];d.push(a.x+", "+a.y)}var e=[];e.push('<gml:LineString xmlns:gml="http://www.opengis.net/gml" srsName="EPSG:27200">');e.push("<gml:coordinates>"+d.join(" ")+"</gml:coordinates>");e.push("</gml:LineString>");return e.join("")};GSPolyline.prototype.clone=function(){var a=new GSPolyline({points:GSUtil.clone(this.points),style:GSUtil.clone(this.options.style)});return a};GSPolyline.prototype.projectPoint=function(b){var e=null;var a=null;if(this.points.length<2){throw new Exception("Polyline must contain at least two points to project a point onto it.")}for(var d=0,c=this.points.length-1;d<c;d++){var f=this._projectPointOnLineSegment(b,this.points[d],this.points[d+1]);if(e===null||f.distance<e){e=f.distance;a=f;a.start=this.points[d];a.end=this.points[d+1];if(e<=1){break}}}return a};GSPolyline.prototype._projectPointOnLineSegment=function(g,f,d){var b=f.distanceFrom(d);if(b<1){return{distance:g.distanceFrom(f),coordinate:f}}var e=((g.x-f.x)*(d.x-f.x)+(g.y-f.y)*(d.y-f.y))/Math.pow(b,2);if(e<1e-7){return{distance:g.distanceFrom(f),coordinate:f}}if(e>0.9999999){return{distance:g.distanceFrom(d),coordinate:d}}var c=new GSPoint(f.x+e*(d.x-f.x),f.y+e*(d.y-f.y));return{distance:g.distanceFrom(c),coordinate:c}};GSUtil.extend(GSPolygon,GSVectorGraphics);function GSPolygon(b,a){this.options={snapHandles:false,snappable:false,clickToEdit:false,editable:false};GSUtil.merge(a,this.options);GSPolygon.baseConstructor.call(this,this.options);this.type="GSPolygon";this.resizeToLayer=true;this.graphicsEl=undefined;if(_browser.svg){this.graphicsEl=document.createElementNS(_globals.svgns,"polygon")}else{if(_browser.isIE6up){this.graphicsEl=document.createElement(_globals.vmlnsPrefix+":shape")}}this.setStyle(this.options.style);this.handles=[];this.handles.indexOf=function(d){for(var e=0,c=this.length;e<c;e++){if(this[e]==d){return e}}return -1};this.createHandles(b);this.insertHandles=[];this.insertHandles.indexOf=function(d){for(var e=0,c=this.length;e<c;e++){if(this[e]==d){return e}}return -1};this.createInsertHandles();this.editing=false;this.selectable=true}GSPolygon.prototype.initializeContextMenu=function(){if(this.options.editable){var a;if(!this.options.clickToEdit){a=new GSMenuItem("Change shape",{action:GSUtil.bind(this.startEditing,this)});this.options.contextMenuItems.push(a)}a=new GSMenuItem("Change style...",{action:GSUtil.bind(this.showStyleInspector,this)});this.options.contextMenuItems.push(a);a=new GSMenuItem("Delete shape",{action:GSUtil.bind(this.remove,this)});this.options.contextMenuItems.push(a)}GSPolygon.superClass.initializeContextMenu.call(this)};GSPolygon.prototype.getPoints=function(){var c=[];for(var b=0,a=this.handles.length;b<a;b++){c.push(this.handles[b].point)}return c};GSPolygon.prototype.getHandles=function(){return this.handles};GSPolygon.prototype.shouldSnapHandles=function(){return this.options.snapHandles};GSPolygon.prototype.isSnappable=function(){return this.options.snappable};GSPolygon.prototype.createHandles=function(c){if(c){for(var b=0,a=c.length;b<a;b++){var d=this.createHandle(c[b]);this.handles.push(d)}}};GSPolygon.prototype.removeHandles=function(){for(var b=0,a=this.handles.length;b<a;b++){this.handles[b].remove()}this.handles.length=0};GSPolygon.prototype.createInsertHandles=function(){for(var d=0,a=this.handles.length;d<a;d++){var c=this.handles[d];var b=this.handles[(d+1)%a];var f=this.getIntermediatePoint(c.point,b.point);var e=this.createInsertHandle(f,c,b);this.insertHandles.push(e)}};GSPolygon.prototype.updateInsertHandles=function(){for(var c=0,a=this.handles.length;c<a;c++){var b=this.insertHandles[c];var f=this.handles[c].point;var e=this.handles[(c+1)%a].point;var d=this.getIntermediatePoint(f,e);b.point=d;b.render()}};GSPolygon.prototype.removeInsertHandles=function(){for(var b=0,a=this.insertHandles.length;b<a;b++){this.insertHandles[b].remove()}this.insertHandles.length=0};GSPolygon.prototype.recreateInsertHandles=function(){this.removeInsertHandles();this.createInsertHandles();this.addHandles(this.layer,this.insertHandles);for(var b=0,a=this.insertHandles.length;b<a;b++){this.insertHandles[b].setVisible(true)}};GSPolygon.prototype.isCreating=function(){return this.creating};GSPolygon.prototype.startCreating=function(){if(this.editing){return}for(var b=0,a=this.handles.length;b<a;b++){this.handles[b].setVisible(true)}for(var b=0,a=this.insertHandles.length;b<a;b++){this.insertHandles[b].setVisible(true)}this.editing=true};GSPolygon.prototype.stopEditing=function(){if(!this.editing){return}for(var b=0,a=this.handles.length;b<a;b++){this.handles[b].setVisible(false)}for(var b=0,a=this.insertHandles.length;b<a;b++){this.insertHandles[b].setVisible(false)}this.editing=false};GSPolygon.prototype.isEditing=function(){return this.editing};GSPolygon.prototype.startEditing=function(){if(this.editing){return}for(var b=0,a=this.handles.length;b<a;b++){this.handles[b].setVisible(true)}for(var b=0,a=this.insertHandles.length;b<a;b++){this.insertHandles[b].setVisible(true)}this.editing=true};GSPolygon.prototype.stopEditing=function(){if(!this.editing){return}for(var b=0,a=this.handles.length;b<a;b++){this.handles[b].setVisible(false)}for(var b=0,a=this.insertHandles.length;b<a;b++){this.insertHandles[b].setVisible(false)}this.editing=false};GSPolygon.prototype.showHandles=function(){this.startEditing()};GSPolygon.prototype.addHandles=function(d,c){for(var b=0,a=c.length;b<a;b++){c[b].addToLayer(d)}};GSPolygon.prototype.addPoint=function(a){var b=this.createHandle(a);this.addHandle(b)};GSPolygon.prototype.addPointAt=function(b,a){var c=this.createHandle(b);this.addHandleAt(c,a)};GSPolygon.prototype.replacePoint=function(c,f){var a=0;for(var d=0,b=this.handles.length;d<b;d++){if(handles[d].point.equals(f)){a=d;break}}var e=this.createHandle(c);this.addHandleAt(e,a)};GSPolygon.prototype.createHandle=function(a){var b=new GSHandle(this,a);b.addListener(this);return b};GSPolygon.prototype.createInsertHandle=function(a,c,b){var d=new GSHandle(this,a,{isInsertHandle:true,beforeHandle:c,afterHandle:b});d.addListener(this);return d};GSPolygon.prototype.addHandle=function(a){this.handles.push(a);this._addHandle(a)};GSPolygon.prototype.addHandleAt=function(b,a){this.handles.splice(a,0,b);this._addHandle(b)};GSPolygon.prototype.replaceHandle=function(c,b){var a=this.handles.indexOf(b);this.handles.splice(a,1,c);this._addHandle(c)};GSPolygon.prototype.removeHandle=function(c){for(var b=0,a=this.handles.length;b<a;b++){if(c.point.equals(this.handles[b].point)){this.handles.splice(b,1);c.remove();this.recreateInsertHandles();if(this.onmap){this.render()}return true}}return false};GSPolygon.prototype._addHandle=function(a){this.recreateInsertHandles();if(this.onmap){a.addToLayer(this.layer);this.render()}};GSPolygon.prototype.hideHandles=function(){this.stopEditing()};GSPolygon.prototype.removePoint=function(a){for(var c=0,b=this.handles.length;c<b;c++){if(a.equals(this.handles[c].point)){return this.removeHandle(this.handles[c])}}return false};GSPolygon.prototype.removePointAt=function(a){var b=this.handles.splice(a,1)[0];b.remove();this.recreateInsertHandles();if(this.onmap){this.render()}return true};GSPolygon.prototype.setPoints=function(a){this.removeHandles();this.createHandles(a);this.render()};GSPolygon.prototype.addToLayer=function(a){this.addHandles(a,this.handles);this.addHandles(a,this.insertHandles);GSPolygon.superClass.addToLayer.call(this,a)};GSPolygon.prototype.render=function(){if(this.isVisible()){GSPolygon.superClass.render.call(this);if(this.handles){var c=this.translateToMapPoints();if(_browser.svg){this.graphicsEl.setAttributeNS(null,"points",c);this.layer.map.container.scrollLeft=this.layer.map.container.scrollLeft}else{if(_browser.isIE6up){var b=c[0];var a=c[1];c.splice(0,2);var d="m "+b+","+a+" l "+c.join(",")+" x e";this.graphicsEl.style.display="none";this.graphicsEl.path=d;this.graphicsEl.style.display=""}}}}};GSPolygon.prototype.getIntermediatePoint=function(i,h){var d=Math.min(i.x,h.x);var c=Math.min(i.y,h.y);var b=Math.max(i.x,h.x);var a=Math.max(i.y,h.y);var f=d+((b-d)/2);var e=c+((a-c)/2);var g=new GSPoint(f,e);return g};GSPolygon.prototype.translateToMapPoints=function(){var d=[];for(var c=0,b=this.handles.length;c<b;c++){var a=this.handles[c].point;var e=this.map.translateToMapCoordinate(a);d.push(Math.round(e.x));d.push(Math.round(e.y))}return d};GSPolygon.prototype.closestPoint=function(g,f){var b=null;var j=this.getPoints();for(var e=(j.length-1),h=null;h=j[e];e--){var a=this.map.translateToMapCoordinate(h);var d=Math.abs(a.x-g.x);var c=Math.abs(a.y-g.y);if(d<f&&c<f){if(!b||Math.min(d,c)<b.delta){b={point:h,delta:Math.min(d,c)}}}}return b};GSPolygon.prototype.getBounds=function(){var d=[];for(var c=0,b=this.handles.length;c<b;c++){d.push(this.handles[c].point)}var a=GSUtil.getMinimum(GSUtil.getPropertyArray(d,"x"));var g=GSUtil.getMinimum(GSUtil.getPropertyArray(d,"y"));var f=GSUtil.getMaximum(GSUtil.getPropertyArray(d,"x"));var e=GSUtil.getMaximum(GSUtil.getPropertyArray(d,"y"));return new GSBounds(a,g,f,e)};GSPolygon.prototype.getInfoWindowPosition=function(){var d=this.getBounds();var b=d.maxX-d.minX;var c=d.maxY-d.minY;var a=new GSPoint(d.minX+(b/2),d.minY+(c/2));return a};GSPolygon.prototype.remove=function(){for(var b=0,a=this.handles.length;b<a;b++){this.handles[b].remove()}for(var b=0,a=this.insertHandles.length;b<a;b++){this.insertHandles[b].remove()}GSPolygon.superClass.remove.call(this)};GSPolygon.prototype.select=function(){GSPolygon.superClass.select.call(this);if(this.onmap&&this.options.clickToEdit&&!this.editing){this.startEditing()}};GSPolygon.prototype.deselect=function(){GSPolygon.superClass.deselect.call(this);if(this.onmap&&this.editing){this.stopEditing()}};GSPolygon.prototype.toJson=function(){var a={type:this.type,style:GSUtil.toCC(this.options.style),points:this.getPoints(),visible:this.visible};if(this.options.text){a.text=this.options.text;a.textPosition=this.options.textPosition;a.textStyle=GSUtil.toCC(this.options.textStyle)}return GSUtil.objToJson(a)};GSPolygon.prototype.toGML=function(){var e=[];var d=this.getPoints();for(var c=0,b=d.length;c<b;c++){var a=d[c];e.push(a.x+", "+a.y)}var f=[];f.push('<gml:Polygon xmlns:gml="http://www.opengis.net/gml" srsName="EPSG:27200">');f.push("<gml:outerBoundaryIs>");f.push("<gml:LinearRing>");f.push("<gml:coordinates>"+e.join(" ")+"</gml:coordinates>");f.push("</gml:LinearRing>");f.push("</gml:outerBoundaryIs>");f.push("</gml:Polygon>");return f.join("")};GSPolygon.prototype.toWKT=function(){var e=[];var d=this.getPoints();for(var c=0,b=d.length;c<b;c++){var a=d[c];e.push(a.x+" "+a.y)}return"POLYGON(("+e.join(",")+"))"};GSPolygon.prototype.handleDrag=function(a){this.render();if(!a.isInsertHandle()){this.updateInsertHandles()}};GSPolygon.prototype.handleDragEnd=function(b){if(b.isInsertHandle()){var c=this.createHandle(b.point);c.setVisible(true);var a=this.insertHandles.indexOf(b);this.addHandleAt(c,a+1)}else{this.render();this.updateInsertHandles()}this.broadcastMessage("shapeGeometryChanged",this)};GSPolygon.prototype.handleMoved=function(a){this.render();this.updateInsertHandles()};GSPolygon.prototype.pointDeleted=function(a){this.removePoint(a);this.broadcastMessage("shapeGeometryChanged",this)};GSPolygon.prototype.showStyleInspector=function(){var a=GSStyleInspector.getInstance();a.show()};GSUtil.extend(GSPolygonDrawingHandler,GSDrawingHandler);GSPolygon.drawingHandler=GSPolygonDrawingHandler;function GSPolygonDrawingHandler(b,a){GSPolygonDrawingHandler.baseConstructor.call(this,b,a)}GSPolygonDrawingHandler.prototype.createDrawFeature=function(){this.drawFeature=new GSPolyline([],{style:this.options.drawStyle,isDrawFeature:true});this.layer.addFeature(this.drawFeature);this.map.customCursor="crosshair";this.map.setCursor("")};GSPolygonDrawingHandler.prototype.mapClicked=function(b,c,a){if(this.drawing){this.addPoint(this.snapPoint(c))}};GSPolygonDrawingHandler.prototype.addPoint=function(d){if(this.drawing){var a=this;this.updatingLine=false;this.drawFeature.addPoint(d);if(this.drawFeature.getPoints().length==1){this.drawFeature.addPoint(d);var b=new GSIcon();b.imageSrc=GSVectorGraphicsConstants.resourceURL+"close.png";b.imageSize=new GSDimension(15,15);b.iconOffset=new GSPoint(-8,-8);var c={coordinate:d,icon:b};this.closeFeature=new GSPointFeature(c);this.closeFeature.setTip("Click here to close the polygon",{showDelay:0,hideDelay:0});this.closeFeature.addEventHandler("click",GSUtil.bindAsEventListener(function(f){this.stopDrawing();GSUtil.cancelEvent(f)},this));this.layer.addFeature(this.closeFeature)}if(!this.mouseMoveListener){this.mouseMoveListener=GSEventManager.addEventListener(document,"mousemove",GSUtil.bindAsEventListener(this.updateLine,this))}}};GSPolygonDrawingHandler.prototype.updateLine=function(c){GSUtil.cancelEvent(c);var a=this.map.getMouseCoordinate(c);this.map.panPointIntoView(a,25);if(!this.updatingLine){this.updatingLine=true}else{var b=this.drawFeature.getPoints();this.drawFeature.removePointAt(b.length-1);this.drawFeature.addPoint(a)}};GSPolygonDrawingHandler.prototype.removeDrawFeature=function(){if(this.drawing){GSEventManager.removeEventListener(this.mouseMoveListener);delete this.mouseMoveListener;this.drawFeature.removePointAt(this.drawFeature.getPoints().length-1);var a=this.drawFeature.getPoints();this.layer.removeFeature(this.drawFeature);this.drawFeature=null;this.layer.removeFeature(this.closeFeature);this.closeFeature=null;this.map.customCursor=null;this.map.setCursor();return a}else{throw new Error("GSPolygonDrawingHandler.closePolygon called while not drawing.")}};GSPolygonDrawingHandler.prototype.createViewFeature=function(b){var a=new GSPolygon(b,this.options.featureOptions);this.layer.addFeature(a);return a};GSUtil.extend(GSCircle,GSVectorGraphics);function GSCircle(b,a,c){this.options={};GSUtil.merge(c,this.options);GSCircle.baseConstructor.call(this,this.options);this.type="GSCircle";this.graphicsEl=undefined;if(_browser.svg){this.graphicsEl=document.createElementNS(_globals.svgns,"circle")}else{if(_browser.isIE6up){this.graphicsEl=document.createElement(_globals.vmlnsPrefix+":oval")}}this.setStyle(this.options.style);this.center=b;this.radius=a}GSCircle.prototype.setCenter=function(a){this.center=a;this.render()};GSCircle.prototype.setRadius=function(a){this.radius=a;this.render()};GSCircle.prototype.render=function(){if(this.isVisible()){GSCircle.superClass.render.call(this);var a=this.map.translateToMapCoordinate(this.center);var b=this.radius/this.map.mpx;if(_browser.svg){this.graphicsEl.setAttributeNS(null,"cx",a.x);this.graphicsEl.setAttributeNS(null,"cy",a.y);this.graphicsEl.setAttributeNS(null,"r",b)}else{if(_browser.isIE6up){this.graphicsEl.style.left=a.x-b;this.graphicsEl.style.top=a.y-b;this.graphicsEl.style.width=b*2;this.graphicsEl.style.height=b*2}}}};GSCircle.prototype.getBounds=function(){var a=this.center.x-this.radius;var d=this.center.y-this.radius;var c=this.center.x+this.radius;var b=this.center.y+this.radius;return new GSBounds(a,d,c,b)};GSCircle.prototype.getInfoWindowPosition=function(){return this.center};GSCircle.prototype.toJson=function(){var a={type:this.type,style:GSUtil.toCC(this.options.style),center:this.center,radius:this.radius,visible:this.visible};if(this.options.text){a.text=this.options.text;a.textPosition=this.options.textPosition;a.textStyle=GSUtil.toCC(this.options.textStyle)}return GSUtil.objToJson(a)};GSCircle.prototype.toGML=function(){throw new Error("GML output not supported for this shape type")};GSCircle.prototype.toWKT=function(){throw new Error("WKT output not supported for this shape type")};GSUtil.extend(GSHandle,GSMapFeature);function GSHandle(d,a,b){this.options={isInsertHandle:false,visible:false,draggable:true,style:{width:8,height:8,fill:"white",opacity:0.9,stroke:"black","stroke-width":"1px",cursor:"pointer",fontSize:"1px"},dragStyle:{stroke:"aqua",fill:"white",opacity:0.9,cursor:"crosshair"},insertStyle:{stroke:"black",fill:"white",opacity:0.5,cursor:"pointer"},snapStyle:{fill:"aqua","fill-opacity":0.9,stroke:"aqua","stroke-opacity":1}};GSUtil.merge(b,this.options);GSHandle.baseConstructor.call(this,this.options);this.type="GSHandle";this.graphicsEl=GSUtil.createElement("div");this.graphicsEl.style.position="absolute";this.setStyle(this.options.style);this.parent=d;this.point=a;this.beforeHandle=this.options.beforeHandle;this.afterHandle=this.options.afterHandle;if(this.options.isInsertHandle){this._setStyle(this.options.insertStyle);this.createDragBoundary();this.disableContextMenu()}else{this.setTip(GSHandle.TOOL_TIP_TEXT,{showDelay:0,hideDelay:0,offset:new GSPoint(20,-10)});var e=GSContextMenuManager.getContextMenu();this.setContextMenu(e);var c=new GSMenuItem("Delete point");c.addEventListener("click",this.pointDeletedHandler,this);this.addContextMenuItemAt(c,0);if(e.getItems().length){this.addContextMenuItemAt(new GSMenuItem("",{isSeparator:true}),1)}}this.setVisible(this.options.visible);if(this.options.draggable){GSEventManager.bind(this.graphicsEl,"mousedown",this,this.dragStart)}this.dragging=false;this.dragStartPoint=null;this.mapPanBuffer=25}GSHandle.TOOL_TIP_TEXT="Drag to move point";GSHandle.prototype.createDragBoundary=function(){if(_browser.svg){this.dragBoundary=document.createElementNS(_globals.svgns,"polyline");this.dragBoundary.style.display="none";this.dragBoundary.setAttributeNS(null,"stroke",this.parent.options.style.stroke);this.dragBoundary.setAttributeNS(null,"stroke-width","2px");this.dragBoundary.setAttributeNS(null,"stroke-dasharray","2px,4px");this.dragBoundary.setAttributeNS(null,"fill","none");GSUtil.makeUnselectable(this.dragBoundary)}else{if(_browser.isIE6up){this.dragBoundary=document.createElement(_globals.vmlnsPrefix+":shape");this.dragBoundary.style.display="none";this.dragBoundary.setAttribute("unselectable","on");var b=document.createElement(_globals.vmlnsPrefix+":stroke");b.setAttribute("on","true");b.setAttribute("color",this.parent.options.style.stroke);b.setAttribute("weight","3px");b.setAttribute("dashstyle","dot");this.dragBoundary.appendChild(b);var a=document.createElement(_globals.vmlnsPrefix+":fill");a.setAttribute("on","false");this.dragBoundary.appendChild(a)}}};GSHandle.prototype.dragStart=function(a){var b=a.which?a.which==3:(a.button?a.button==2:false);if(b){return}this.dragStartPoint=this.map.getMouseCoordinate(a);this._setStyle(this.options.dragStyle);if(this.options.isInsertHandle){this.dragBoundary.style.display=""}this.mousemoveListener=GSEventManager.addEventListener(document,"mousemove",this.onDrag,this);this.mouseupListener=GSEventManager.addEventListener(document,"mouseup",this.stopDrag,this);this.dragging=true;this.broadcastMessage("handleDragStart",this);GSUtil.cancelEvent(a)};GSHandle.prototype.onDrag=function(f){this.point=this.map.getMouseCoordinate(f);this.closest=undefined;if(this.parent.shouldSnapHandles()){var h=this.map.getSnappables();for(var c=0,b=h.length;c<b;c++){var d=h[c];if(d!==this.parent&&d.isVisible()){var g=this.map.translateToMapCoordinate(this.point);var a=d.closestPoint(g,15);if(a){if(!this.closest||a.delta<this.closest.delta){this.closest=a}}}}}if(this.closest){this._setStyle(this.options.snapStyle)}else{this._setStyle(this.options.dragStyle)}if(!this.options.isInsertHandle){this.tip.setText(this.point.x+", "+this.point.y)}this.render();this.broadcastMessage("handleDrag",this,[f]);GSUtil.cancelEvent(f)};GSHandle.prototype.stopDrag=function(a){GSUtil.cancelEvent(a);GSEventManager.release(this.mousemoveListener);delete this.mousemoveListener;GSEventManager.release(this.mouseupListener);delete this.mouseupListener;if(this.options.isInsertHandle){this._setStyle(this.options.insertStyle);this.dragBoundary.style.display="none"}else{this._setStyle(this.options.style);this.tip.setText(GSHandle.TOOL_TIP_TEXT)}if(!this.dragStartPoint.equals(this.map.getMouseCoordinate(a))){if(this.closest){this.point=this.closest.point;this.closest=undefined;this.render()}}this.broadcastMessage("handleDragEnd",this,[a]);this.dragging=false};GSHandle.prototype.addToLayer=function(a){a.map.handleContainer.appendChild(this.graphicsEl);if(this.options.isInsertHandle){if(!a.vectorContainer){a.vectorContainer=a.createVectorContainer()}if(_browser.isIE6up){this.dragBoundary.style.width=a.map.pxWidth;this.dragBoundary.style.height=a.map.pxHeight;this.dragBoundary.coordsize=a.map.pxWidth+" "+a.map.pxHeight}a.vectorContainer.appendChild(this.dragBoundary)}GSHandle.superClass.addToLayer.call(this,a)};GSHandle.prototype.isInsertHandle=function(){return this.options.isInsertHandle};GSHandle.prototype.render=function(){if(this.isVisible()){var g=this.map.translateToMapCoordinate(this.point);var a=g.x-this.options.style.width/2;var f=g.y-this.options.style.height/2;this.graphicsEl.style.left=a+"px";this.graphicsEl.style.top=f+"px";this.graphicsEl.style.width=this.options.style.width+"px";this.graphicsEl.style.height=this.options.style.height+"px";this.graphicsEl.style.zIndex=100;if(this.options.isInsertHandle&&this.dragging){var d=this.map.translateToMapCoordinate(this.beforeHandle.point);var b=this.map.translateToMapCoordinate(this.afterHandle.point);if(_browser.svg){var c=[d.x,d.y,g.x,g.y,b.x,b.y];this.dragBoundary.setAttributeNS(null,"points",c)}else{if(_browser.isIE6up){var e="m "+Math.round(d.x)+","+Math.round(d.y)+" l "+Math.round(g.x)+", "+Math.round(g.y)+", "+Math.round(b.x)+", "+Math.round(b.y)+" e";this.dragBoundary.style.display="none";this.dragBoundary.path=e;this.dragBoundary.style.display=""}}}}};GSHandle.prototype.setStyle=function(a){for(var c in a){var b=a[c];switch(c){case"stroke":this.setStroke(b);break;case"stroke-width":this.setStrokeWidth(b);break;case"fill":this.setFill(b);break;case"opacity":this.setOpacity(b);break;default:this.graphicsEl.style[c]=b;break}}};GSHandle.prototype._setStyle=function(a){for(var c in a){var b=a[c];switch(c){case"stroke":this._setStroke(b);break;case"stroke-width":this._setStrokeWidth(b);break;case"fill":this._setFill(b);break;case"opacity":this._setOpacity(b);break;default:this.graphicsEl.style[c]=b;break}}};GSHandle.prototype.setStroke=function(a){this.options.style.stroke=a;return this._setStroke(a)};GSHandle.prototype.setStrokeWidth=function(a){this.options.style["stroke-width"]=a;return this._setStrokeWidth(a)};GSHandle.prototype.setFill=function(a){this.options.style.fill=a;return this._setFill(a)};GSHandle.prototype.setOpacity=function(a){this.options.style.opacity=a;return this._setOpacity(a)};GSHandle.prototype._setStroke=function(a){if(a==="none"){this.graphicsEl.style.borderStyle="none"}else{this.graphicsEl.style.borderStyle="solid";this.graphicsEl.style.borderColor=a}};GSHandle.prototype._setStrokeWidth=function(a){this.graphicsEl.style.borderWidth=a};GSHandle.prototype._setStrokeOpacity=function(a){};GSHandle.prototype._setFill=function(a){if(a==="none"){this.graphicsEl.style.backgroundColor="transparent"}else{this.graphicsEl.style.backgroundColor=a}};GSHandle.prototype._setFillOpacity=function(a){};GSHandle.prototype._setOpacity=function(a){GSUtil.setOpacity(this.graphicsEl,a*100)};GSHandle.prototype.remove=function(){this.map.handleContainer.removeChild(this.graphicsEl);if(this.options.isInsertHandle){this.layer.vectorContainer.removeChild(this.dragBoundary)}GSHandle.superClass.remove.call(this)};GSHandle.prototype.setVisible=function(a){this.options.visible=a;if(this.graphicsEl){this.graphicsEl.style.visibility=(a===true?"visible":"hidden")}if(this.onmap&&this.options.visible){this.render()}};GSHandle.prototype.pointDeletedHandler=function(a){this.contextMenu.hide();this.broadcastMessage("pointDeleted",this.point);GSUtil.cancelEvent(a)};GSHandle.prototype.toString=function(){return"GSHandle: x=["+this.point.x+"], y=["+this.point.y+"]"};GSHandle.prototype.clickHandler=function(a){GSUtil.cancelEvent(a);return};function GSDrawingHandler(b,a){this.layer=b;this.map=b.map;this.eventListeners={};this.options={drawStyle:{fill:"white","fill-opacity":0.4,stroke:"black","stroke-width":"1px","stroke-opacity":1},onShapeCreated:function(){},onDrawingCancelled:function(){}};GSUtil.merge(a,this.options);this.drawing=false;this.map.addListener(this)}GSDrawingHandler.prototype.startDrawing=function(){if(!this.drawing){this.drawing=true;this.createDrawFeature();if(!this.eventListeners.keydownListener){this.eventListeners.keydownListener=GSEventManager.addEventListener(document,"keydown",this.keyHandler,this)}}};GSDrawingHandler.prototype.stopDrawing=function(){if(this.drawing){var a=this.removeDrawFeature();this.drawing=false;this.viewFeature=this.createViewFeature(a);if(this.viewFeature!==null){this.options.onShapeCreated(this.viewFeature)}GSEventManager.removeEventListener(this.eventListeners.keydownListener);this.eventListeners.keydownListener=null}};GSDrawingHandler.prototype.createDrawFeature=function(){};GSDrawingHandler.prototype.removeDrawFeature=function(){};GSDrawingHandler.prototype.createViewFeature=function(){};GSDrawingHandler.prototype.snapPoint=function(b){var d=this.map.translateToMapCoordinate(b);var f=this.map.getSnappables();var e=null;for(var c=0;c<f.length;c++){if(f[c].isVisible()){var a=f[c].closestPoint(d,15);if(a){if(!e||a.delta<e.delta){e=a}}}}if(e){return e.point}return b};GSDrawingHandler.prototype.keyHandler=function(a){if(a.keyCode==GSKeyEvents.KEY_ESC){this.cancelDrawing()}};GSDrawingHandler.prototype.cancelDrawing=function(){if(this.drawing){this.removeDrawFeature();this.drawing=false;if(this.options.onDrawingCancelled){this.options.onDrawingCancelled()}}};function GSMultiLevelPolyline(b,a){if(!a){a={}}this.type="GSMultiLevelPolyline";this.levelPoints=b;this.levelPolylines=[];this.style=a.style?a.style:{};this.layer=null;this.map=null;this.currentVisiblePolyline=null;this.createLevelPolylines()}GSMultiLevelPolyline.getLevelPoints=function(f,h){var e=[];var d,c,b,a;var g=4;for(d=0,a=g;d<a;d++){e[d]=[]}for(d=0,a=f.length;d<a;d++){for(c=0,b=h[d];c<=b;c++){e[c].push(f[d])}}return e};GSMultiLevelPolyline.prototype.createLevelPolylines=function(){if(this.levelPoints.length){this.removePolylines();for(var b=0,a=this.levelPoints.length;b<a;b++){this.levelPolylines[b]=new GSPolyline(this.levelPoints[b],{style:this.style});this.levelPolylines[b].setVisible(false)}}};GSMultiLevelPolyline.prototype.addPolylinesToLayer=function(a){this.layer=a;this.map=this.layer.map;this.map.addListener(this);this.updateVisiblePolyline()};GSMultiLevelPolyline.prototype.updateVisiblePolyline=function(){if(this.map!==null){var a=Math.floor((15-this.map.getZoomLevel())/3);if(a<0){a=0}else{if(a>3){a=3}}if(a!=this.currentVisiblePolyline){if(this.currentVisiblePolyline!==null){if(this.levelPolylines[this.currentVisiblePolyline].graphicsEl){this.levelPolylines[this.currentVisiblePolyline].setVisible(false)}else{this.removePolylines();return}}this.currentVisiblePolyline=a;if(!this.levelPolylines[this.currentVisiblePolyline]){console.log("No polyline for level "+this.currentVisiblePolyline)}if(this.levelPolylines[this.currentVisiblePolyline].graphicsEl){if(!this.levelPolylines[this.currentVisiblePolyline].layer){this.layer.addFeature(this.levelPolylines[this.currentVisiblePolyline])}else{this.levelPolylines[this.currentVisiblePolyline].setVisible(true)}}else{this.removePolylines();return}}}};GSMultiLevelPolyline.prototype.mapBoundsChanged=function(c,a,b){this.updateVisiblePolyline()};GSMultiLevelPolyline.prototype.mapZoomed=function(c,b,a){this.updateVisiblePolyline()};GSMultiLevelPolyline.prototype.removePolylines=function(){if(this.levelPolylines.length){for(var b=0,a=this.levelPolylines.length;b<a;b++){if(this.levelPolylines[b].graphicsEl){this.layer.removeFeature(this.levelPolylines[b])}}}this.levelPolylines=[];if(this.map){this.map.removeListener(this);this.map=null;this.layer=null}};GSMultiLevelPolyline.prototype.projectPoint=function(a){if(this.levelPolylines[this.currentVisiblePolyline]){return this.levelPolylines[this.currentVisiblePolyline].projectPoint(a)}return null};GSMultiLevelPolyline.prototype.addEventHandler=function(c,d){for(var b=0,a=this.levelPolylines.length;b<a;b++){this.levelPolylines[b].addEventHandler(c,d)}};GSMultiLevelPolyline.prototype.clone=function(){var a=new GSMultiLevelPolyline(this.levelPoints,{style:GSUtil.clone(this.style)});return a};function GSLineClipping(a){this.bounds=a}GSLineClipping.prototype.clipLine=function(c){var b=[];for(var d=0,a=c.length;d<a-1;d++){var f=c[d];var e=c[d+1];var g=this.clip(f,e);if(g){if(b.length){if((g[0].x==f.x&&g[0].y==f.y)&&(g[1].x==e.x&&g[1].y==e.y)){b[b.length-1].push(g[1]);continue}}b.push([g[0],g[1]])}}return b};GSLineClipping.prototype.clip=function(m,l){var o,n,c,b,a;var g=0;var f=1;o=l.x-m.x;n=l.y-m.y;var k=[-1*o,o,-1*n,n];var j=[m.x-this.bounds.minX,this.bounds.maxX-m.x,m.y-this.bounds.minY,this.bounds.maxY-m.y];var d=true;for(var e=0;e<4;e++){c=k[e];b=j[e];if(c==0&&b<0){d=false;break}a=b/c;if(c<0){g=Math.max(g,a)}if(c>0){f=Math.min(f,a)}if(g>f){d=false;break}}if(d){var h=[m,l,false];if(f<1){h[1]=new GSPoint(parseInt(m.x+f*o),parseInt(m.y+f*n))}if(g>0){h[0]=new GSPoint(parseInt(m.x+g*o),parseInt(m.y+g*n))}return h}return false};GSUtil.extend(GSStyleInspector,GSPanel);function GSStyleInspector(){this.options={width:300,height:210,y:100,backgroundColor:"rgba(0,0,0,0.80)",borderRadius:6,boxShadow:true,draggable:true,zIndex:10000,visible:false,eventsDisablePropagation:["click","dblclick"],className:"GSStyleInspector"};this.options.x=(screen.width-this.options.width)/2;this.controls={};this.state={};if(this.options.feature){this.setFeature(this.options.feature)}this.featureEdited=false;this.initialized=false;GSStyleInspector.baseConstructor.call(this,document.body,this.options)}GSStyleInspector.instance=null;GSStyleInspector.getInstance=function(){if(!GSStyleInspector.instance){GSStyleInspector.instance=new GSStyleInspector()}return GSStyleInspector.instance};GSStyleInspector.prototype.initialize=function(){GSStyleInspector.superClass.initialize.call(this);var a=GSUtil.createElement("img",{src:_globals.resourceURL+"inspector/close.png",title:"Close",styles:{position:"absolute",width:"14px",height:"14px",top:"4px",left:"6px"},events:{click:GSUtil.bind(this.hide,this)},parent:this.element});this.body=GSUtil.createElement("div",{styles:{position:"absolute",top:"18px",width:"100%"},parent:this.element});this.createPropertyEditor(this.body,"stroke-width","range","Stroke Width",{value:this.getFeatureStrokeWidth(),min:0,max:20,onChange:GSUtil.bind(function(b){if(this.feature){this.featureEdited=true;this.feature.setStrokeWidth(b)}},this)});this.createPropertyEditor(this.body,"stroke","color","Stroke Color",{value:this.getFeatureStroke(),onChange:GSUtil.bind(function(b){if(this.feature){this.featureEdited=true;this.feature.setStroke(b)}},this)});this.createPropertyEditor(this.body,"stroke-opacity","range","Stroke Opacity",{value:this.getFeatureStrokeOpacity(),min:0,max:100,onChange:GSUtil.bind(function(b){if(this.feature){this.featureEdited=true;this.feature.setStrokeOpacity(b/100)}},this),last:true});this.createPropertyEditor(this.body,"fill","color","Fill Color",{value:this.getFeatureFill(),onChange:GSUtil.bind(function(b){if(this.feature){this.featureEdited=true;this.feature.setFill(b)}},this)});this.createPropertyEditor(this.body,"fill-opacity","range","Fill Opacity",{value:this.getFeatureFillOpacity(),min:0,max:100,onChange:GSUtil.bind(function(b){if(this.feature){this.featureEdited=true;this.feature.setFillOpacity(b/100)}},this)});this.buttonBar=GSUtil.createElement("div",{styles:{height:"18px",padding:"8px 10px 8px 15px",marginTop:"8px",overflow:"hidden",position:"relative"},"class":"GSStyleInspector-buttonbar",parent:this.body});this.resetButton=new GSButton("Reset",this.buttonBar,{x:15,styles:{cursor:"default"}});this.resetButton.addEventListener("mousedown",GSUtil.bind(this.restoreFeatureState,this));this.createMaskAnimations();this.initialized=true};GSStyleInspector.prototype.createMaskAnimations=function(){this.maskAnimation=new GSAnimator(new GSPoint(100,0),new GSPoint(40,0),16,150,GSUtil.bind(function(b,a){GSUtil.setOpacity(this.body,a.x);if(_browser.isIE8x){for(var c in this.controls){GSUtil.setOpacity(this.controls[c].getElement(),a.x)}GSUtil.setOpacity(this.resetButton.getElement(),a.x)}},this));this.unmaskAnimation=new GSAnimator(new GSPoint(40,0),new GSPoint(100,0),16,150,GSUtil.bind(function(b,a){GSUtil.setOpacity(this.body,a.x);if(_browser.isIE8x){for(var c in this.controls){GSUtil.setOpacity(this.controls[c].getElement(),a.x)}GSUtil.setOpacity(this.resetButton.getElement(),a.x)}},this))};GSStyleInspector.prototype.getFeature=function(){return this.feature};GSStyleInspector.prototype.setFeature=function(a){if(a==this.feature){return}this.unsetFeature();this.feature=this.options.feature=a;this.feature.addListener(this);this.saveFeatureState();if(this.initialized){this.updateEditors();this.unmask()}};GSStyleInspector.prototype.unsetFeature=function(){if(this.feature){this.feature.removeListener(this);this.clearFeatureState();this.feature=null}};GSStyleInspector.prototype.stopInspecting=function(){if(this.feature){this.unsetFeature();this.updateEditors()}this.mask()};GSStyleInspector.prototype.saveFeatureState=function(){this.state.featureStyle=GSUtil.clone(this.feature.getStyle())};GSStyleInspector.prototype.clearFeatureState=function(){try{delete this.state.featureStyle}catch(a){}};GSStyleInspector.prototype.restoreFeatureState=function(){if(arguments.length){GSUtil.cancelEvent(arguments[0])}if(this.feature&&this.featureEdited){var a=this.state.featureStyle;this.feature.setStrokeWidth(a["stroke-width"]);this.feature.setStroke(a.stroke);this.feature.setStrokeOpacity(a["stroke-opacity"]);this.feature.setFill(a.fill);this.feature.setFillOpacity(a["fill-opacity"]);this.updateEditors()}};GSStyleInspector.prototype.createPropertyEditor=function(f,g,e,c,b){b||{};var d=GSUtil.createElement("div",{styles:{padding:"8px 10px 8px 15px",overflow:"hidden",zoom:1},parent:f});if(b.last){d.style.borderBottom="1px solid #4c4c4c"}var a=GSUtil.createElement("label",{styles:{clear:"left",color:"#dedede",display:"block",cssFloat:"left",styleFloat:"left",fontFamily:"Helvetica, Arial, Sans-serif",fontSize:"12px",textShadow:"1px 1px #222",margin:"0 15px 0 0",textAlign:"right",width:"90px"},html:c,unselectable:true,parent:d});switch(e){case"range":this.controls[g]=new GSSlider(d,{value:b.value,min:b.min,max:b.max,onChange:b.onChange,styles:{cssFloat:"left",styleFloat:"left"}});break;case"color":this.controls[g]=new GSSwatch(d,GSUtil.merge({pickerParent:this.element,onChange:b.onChange},b));break}};GSStyleInspector.prototype.updateEditors=function(){this.controls["stroke-width"].setValue(this.getFeatureStrokeWidth(),true);this.controls.stroke.setColor(this.getFeatureStroke());this.controls["stroke-opacity"].setValue(this.getFeatureStrokeOpacity(),true);this.controls.fill.setColor(this.getFeatureFill());this.controls["fill-opacity"].setValue(this.getFeatureFillOpacity(),true)};GSStyleInspector.prototype.mask=function(){if(this.maskEl){return}var a=this.body.offsetWidth;var b=this.body.offsetHeight;this.maskEl=GSUtil.createElement("div",{styles:{position:"absolute",top:0,left:0,width:a+"px",height:b+"px",zIndex:1000},"class":"GSStyleInspector-mask",parent:this.body});this.maskAnimation.animate()};GSStyleInspector.prototype.unmask=function(){if(this.maskEl){this.body.removeChild(this.maskEl);this.maskEl=null;this.unmaskAnimation.animate()}};GSStyleInspector.prototype.show=function(a){if(a){this.setPosition(a)}this.setVisible(true)};GSStyleInspector.prototype.hide=function(){this.setVisible(false)};GSStyleInspector.prototype.getFeatureStrokeWidth=function(){return this.feature?this.feature.getStrokeWidth():0};GSStyleInspector.prototype.getFeatureStroke=function(){return this.feature?this.feature.getStroke():"#000000"};GSStyleInspector.prototype.getFeatureStrokeOpacity=function(){return this.feature?this.feature.getStrokeOpacity()*100:0};GSStyleInspector.prototype.getFeatureFill=function(){return this.feature?this.feature.getFill():"#ffffff"};GSStyleInspector.prototype.getFeatureFillOpacity=function(){return this.feature?this.feature.getFillOpacity()*100:0};GSStyleInspector.prototype.listenForSelectionEvents=function(a){a.addListener(this)};GSStyleInspector.prototype.selectionChanged=function(b){if(b.length==1){var a=b[0];if(a instanceof GSVectorGraphics&&a!=this.feature){this.setFeature(a)}}else{this.stopInspecting()}};GSStyleInspector.prototype.featureRemoved=function(a){this.stopInspecting()};function GSSwatch(b,a){this.parent=b;this.options=a||{};this.initialize()}GSSwatch.prototype.initialize=function(){this.element=GSUtil.createElement("div",{styles:{backgroundColor:this.options.value,border:"1px solid #dfdfdf",fontSize:0,display:"block",cssFloat:"left",styleFloat:"left",position:"relative",width:"10px",height:"10px"},events:{click:GSUtil.bind(this.toggleColorPicker,this)},parent:this.parent});var a=this.options.pickerParent||document.body;var b=GSUtil.getElementPosition(this.element,a);this.picker=new GSColorPicker(a,{x:b.x,y:b.y+13,color:this.options.value,visible:false,onChange:GSUtil.bind(this.pickerChangeHandler,this)})};GSSwatch.prototype.getElement=function(){return this.element};GSSwatch.prototype.pickerChangeHandler=function(a){this.element.style.backgroundColor=a;if(this.options.onChange){this.options.onChange(a)}};GSSwatch.prototype.setColor=function(a){this.element.style.backgroundColor=a;this.picker.setColor(a);if(this.options.onChange){this.options.onChange(a)}};GSSwatch.prototype.toggleColorPicker=function(a){GSUtil.cancelEvent(a);this.picker.setVisible(!this.picker.visible)};if(window.GSModule&&GSModule.moduleLoaded){GSModule.moduleLoaded("svg")};