window.onload=function(){window.mapas&&ingraMapa()};function ingraMapa(){for(var a=0;a<mapas.length;a++){var b=mapas[a];b.div=document.getElementById("ingraMapa"+(a+1));if(!b.div)break;if(b.geo){for(var c=b.geo.entl,d=0;d<c.length;d++)c[d].punl=ingra.punl.axy(c[d].punl);for(var e=[],d=0;d<c.length;d++)e=e.concat(c[d].punl);b.medio=ingra.punl.medio(e)}if(a)for(v in c=mapas[a-1],c)null==b[v]&&(b[v]=c[v]);b.mapaEstatico?ingraMapaEstatico(b):ingraMapaDinamico(b)}}
function ingraMapaEstatico(a){var b=[];b.push("center="+a.medio.y+","+a.medio.x);b.push("zoom="+(a.zoom?a.zoom:"19"));b.push("size="+a.ancho+"x"+a.alto);b.push("maptype="+(a.type?a.type:"hybrid"));for(var c=0;c<a.geo.entl.length;c++){var d=a.geo.entl[c],e=d.punl,f=d.tip,g=ingra.punl.medio(e),h=ingra.punl.centroide(e),d=[];d.push("markers=color:"+(a.markersColor?a.markersColor:"red"));d.push("label:"+f);d.push(g.y+","+g.x);b.push(d.join("%7C"));"C"==f&&(f="P",e=ingra.punl.regular({pun:h,rad:9E-6,lad:8}));
if("L"==f){d=[];d.push("path=weight:"+(a.pathWeight?a.pathWeight:"5"));d.push("color:"+(a.pathColor?a.pathColor:"red"));for(f=0;f<e.length;f++)d.push(e[f].y+","+e[f].x);b.push(d.join("%7C"))}else if("P"==f){d=[];d.push("path=weight:"+(a.pathWeight?a.pathWeight:"0"));d.push("color:"+(a.pathColor?a.pathColor:"red"));d.push("fillcolor:"+(a.pathFillcolor?a.pathFillcolor:"0xff000088"));for(f=0;f<e.length;f++)d.push(e[f].y+","+e[f].x);d.push(e[0].y+","+e[0].x);b.push(d.join("%7C"))}}b.push("sensor=false");
b.push("Key=AIzaSyBBVP12RIUu6USWETB-fK7kJA2HdQObLoo");a.div.innerHTML="<img src='http://maps.googleapis.com/maps/api/staticmap?"+b.join("&")+"' alt:'' />"}
function ingraMapaDinamico(a){for(var b=new google.maps.Map(a.div,{center:ingra.pun.ag(a.medio),zoom:a.zoom?a.zoom:19,mapTypeId:a.type?a.type:"satellite",tilt:a.tilt?a.tilt:0}),c=0;c<a.geo.entl.length;c++){var d=a.geo.entl[c],e=d.punl;ingra.punl.medio(e);var f=ingra.punl.centroide(e),g=a.geo.cod+" · "+a.geo.res+"\nCentroide: "+ingra.pun.ac(f,5);new google.maps.Marker({map:b,title:g,position:ingra.pun.ag(f)});"C"==d.tip?new google.maps.Circle({map:b,center:ingra.pun.ag(f),radius:a.radius?a.radius:
2,strokeColor:a.strokeColor?a.strokeColor:"#ff0000",strokeOpacity:a.strokeOpacity?a.strokeOpacity:0.8,strokeWeight:a.strokeWeight?a.strokeWeight:3,fillColor:a.fillColor?a.fillColor:"#ff0000",fillOpacity:a.fillOpacity?a.fillOpacity:0.35}):"L"==d.tip?go=new google.maps.Polyline({map:b,path:ingra.punl.ag(e),strokeColor:a.strokeColor?a.strokeColor:"#ff0000",strokeOpacity:a.strokeOpacity?a.strokeOpacity:0.8,strokeWeight:a.strokeWeight?a.strokeWeight:4}):"P"==d.tip&&(go=new google.maps.Polygon({map:b,path:ingra.punl.ag(e),
strokeColor:a.strokeColor?a.strokeColor:"#ff0000",strokeOpacity:a.strokeOpacity?a.strokeOpacity:0.8,strokeWeight:a.strokeWeight?a.strokeWeight:3,fillColor:a.fillColor?a.fillColor:"#ff0000",fillOpacity:a.fillOpacity?a.fillOpacity:0.35}))}}
var ingra={red:function(a,b){if(0>b)return a;if(!b)return Math.round(a);var c=Math.pow(10,b);return Math.round(a*c)/c},ac:function(a,b){null==b&&(b=-1);0>1+b&&(a=ingra.red(a,-1-b));if(!a)return"";for(var c=a.toString().split("."),d=c[0],e=d.length-3,f=0<a?0:1;e>f;e-=3)d=d.substr(0,e)+"."+d.substr(e);if(b){c=1<c.length?c[1]:"";if(0<b)for(c.length>b&&(c=c.substr(0,b));c.length<b;)c+="0";c&&(d+=","+c)}return d},rad:function(a){return a*Math.PI/180},pun:{ag:function(a){return new google.maps.LatLng(a.y,
a.x)},ac:function(a,b,c){c||(c="; ");return a&&(a.x||a.y)?ingra.ac(a.x,b)+c+ingra.ac(a.y,b):""},distancia2:function(a,b){var c=b.x-a.x,d=b.y-a.y;return c*c+d*d},distancia:function(a,b){return Math.sqrt(this.distancia2(a,b))}},punl:{axy:function(a){for(var b=[],c=0;c<a.length;c++)b.push({x:a[c][0],y:a[c][1]});return b},ag:function(a){for(var b=[],c=0;c<a.length;c++)b.push(new google.maps.LatLng(a[c].y,a[c].x));return b},medio:function(a){if(0==a.length)return null;if(1==a.length)return a[0];for(var b=
a[0],c=b.x,d=b.y,e=b.x,f=b.y,g=1;g<a.length;g++)b=a[g],c>b.x&&(c=b.x),d>b.y&&(d=b.y),e<b.x&&(e=b.x),f<b.y&&(f=b.y);return{x:(c+e)/2,y:(d+f)/2}},centroide:function(a){if(3>a.length)return this.medio(a);for(var b=0,c=0,d=0,e=a[0],f=a[a.length-1],g=0;g<a.length;g++)var h=a[g],k=f,f={x:h.x-e.x,y:h.y-e.y},h=(k.y+f.y)/3,l=(f.x*k.y-k.x*f.y)/2,b=b+(k.x+f.x)/3*l,c=c+h*l,d=d+l;return d?{x:e.x+b/d,y:e.y+c/d}:this.medio()},area:function(a){if(!a||3>a.length)return 0;for(var b=0,c=0,d=a.length-1;c<a.length;d=
c++)var d=a[d],e=a[c],b=b+(e.x-d.x)*(e.y+d.y);return b/2},perimetro:function(a,b){if(!a||2>a.length)return 0;for(var c=0,d=0;d<a.length-1;d++)c+=ingra.pun.distancia(a[d],a[d+1]);b&&(c+=ingra.pun.distancia(a[a.length-1],a[0]));return c},sinl:[],cosl:[],regular:function(a){a.rad2||(a.rad2=a.rad);if(!a.lad)return[];var b=360/a.lad,c=this.sinl[b]?this.sinl[b]:this.sinl[b]=Math.sin(ingra.rad(b)),d=this.cosl[b]?this.cosl[b]:this.cosl[b]=Math.cos(ingra.rad(b)),c=-c,e=(b=a.ang)?this.sinl[b]?this.sinl[b]:
this.sinl[b]=Math.sin(ingra.rad(b)):1,b=b?this.cosl[b]?this.cosl[b]:this.cosl[b]=Math.cos(ingra.rad(b)):0;venb=-e;for(var f=[],g=0;g<a.lad;g++){f.push({x:a.pun.x+a.rad*b,y:a.pun.y+a.rad2*e});var h=d*b-c*e,e=b*c+e*d,b=h}return f}}};
