desenho_compacto.js 7.01 KB
if(typeof(i3GEO)==='undefined'){var i3GEO={}}i3GEO.desenho={layergrafico:null,estilos:{"normal":{fillcolor:'#ffffff',linecolor:'#ffcc33',linewidth:'2',circcolor:'#ffffff',textcolor:'#787A78'},"palido":{fillcolor:'#B5A8A8',linecolor:'#BAA4AE',linewidth:'1',circcolor:'#E0D7DC',textcolor:'#787A78'},"vermelho":{fillcolor:'#E8ACAC',linecolor:'#F50707',linewidth:'1',circcolor:'#F09EA6',textcolor:'#787A78'},"verde":{fillcolor:'#3CCC2F',linecolor:'#0C6642',linewidth:'1',circcolor:'#C7D9D2',textcolor:'#787A78'}},estilosOld:{"normal":{fillcolor:'red',linecolor:'black',linewidth:'1',circcolor:'white',textcolor:'gray'},"palido":{fillcolor:'gray',linecolor:'gray',linewidth:'1',circcolor:'gray',textcolor:'gray'},"vermelho":{fillcolor:'gray',linecolor:'red',linewidth:'1',circcolor:'pink',textcolor:'brown'},"verde":{fillcolor:'gray',linecolor:'green',linewidth:'1',circcolor:'DarkGreen',textcolor:'GreenYellow'}},estiloPadrao:"normal",caixaEstilos:function(){var lista=i3GEO.util.listaChaves(i3GEO.desenho.estilos),n=lista.length,i,caixa,sel;caixa="<select class='form-control' onchange='i3GEO.desenho.definePadrao(this.value)'>";for(i=0;i<n;i+=1){sel="";if(lista[i]===i3GEO.desenho.estiloPadrao){sel="select"}caixa+="<option value='"+lista[i]+"'"+sel+">"+lista[i]+"</option>"}caixa+="</select>";return caixa},definePadrao:function(valor){i3GEO.desenho.estiloPadrao=valor},addBox:function(xmin,ymin,xmax,ymax,namespace,strokeColor,strokeWidth){return i3GEO.desenho[i3GEO.Interface.ATUAL].addBox(xmin,ymin,xmax,ymax,namespace,strokeColor,strokeWidth)},moveBox:function(box,xmin,ymin,xmax,ymax){return i3GEO.desenho[i3GEO.Interface.ATUAL].moveBox(box,xmin,ymin,xmax,ymax)},removeBox:function(namespace){i3GEO.desenho.removePins(namespace)},addPin:function(x,y,w,h,imagem,namespace,centro,funcaoclick){return i3GEO.desenho[i3GEO.Interface.ATUAL].addPin(x,y,w,h,imagem,namespace,centro)},removePins:function(namespace){i3GEO.desenho[i3GEO.Interface.ATUAL].removePins(namespace)},movePin:function(pin,x,y){i3GEO.desenho[i3GEO.Interface.ATUAL].movePin(pin,x,y)},criaLayerGrafico:function(){if(!i3GEO.desenho.layergrafico){i3GEO.desenho[i3GEO.Interface.ATUAL].criaLayerGrafico()}},openlayers:{inicia:function(){if(!i3GEO.desenho.layergrafico){i3GEO.desenho.openlayers.criaLayerGrafico()}},addBox:function(xmin,ymin,xmax,ymax,namespace,strokeColor,strokeWidth){var pol,f;if(!namespace){namespace="box"}if(!strokeColor){strokeColor="#FF0000"}if(!strokeWidth){strokeWidth=2}i3GEO.desenho.openlayers.inicia();xmin=xmin*1;ymin=ymin*1;xmax=xmax*1;ymax=ymax*1;pol=new ol.geom.Polygon([[[xmin,ymin],[xmin,ymax],[xmax,ymax],[xmax,ymin],[xmin,ymin]]]);pol=i3GEO.util.extGeo2OSM(pol);f=new ol.Feature({geometry:pol});f.setStyle(new ol.style.Style({stroke:new ol.style.Stroke({color:strokeColor,width:strokeWidth})}));f.setProperties({origem:namespace});i3GEO.desenho.layergrafico.getSource().addFeature(f);return f},moveBox:function(box,xmin,ymin,xmax,ymax){box.getGeometry().setCoordinates([[[xmin,ymin],[xmin,ymax],[xmax,ymax],[xmax,ymin],[xmin,ymin]]]);return box},addPin:function(x,y,w,h,imagem,namespace,centro,funcaoclick){if(!imagem||imagem===""){imagem=i3GEO.configura.locaplic+"/imagens/google/confluence.png"}if(!namespace){namespace="pin"}if(!w||w===""){w=27}if(!h||h===""){h=27}if(!funcaoclick){funcaoclick=function(){i3GEO.desenho.openlayers.removePins(namespace)}}if(!centro){centro=false}i3GEO.desenho.openlayers.inicia();var point,f,ox,oy;if(centro===true){ox=0.5;oy=0.5}else{ox=0.5;oy=1}point=i3GEO.util.extGeo2OSM(new ol.geom.Point([x,y]));f=new ol.Feature({geometry:point});f.setProperties({origem:namespace});f.setStyle(new ol.style.Style({image:new ol.style.Icon({src:imagem,size:[w,h],anchor:[ox,oy]})}));i3GEO.desenho.layergrafico.getSource().addFeature(f);return f},removePins:function(namespace){if(!namespace){namespace="pin"}if(i3GEO.desenho.layergrafico){var features,n,f,i,remover=[];features=i3GEO.desenho.layergrafico.getSource().getFeatures();n=features.length;for(i=0;i<n;i++){if(features[i].get("origem")==namespace){remover.push(features[i])}}n=remover.length;for(i=0;i<n;i++){i3GEO.desenho.layergrafico.getSource().removeFeature(remover[i])}}},movePin:function(pin,x,y){var point=i3GEO.util.extGeo2OSM(new ol.geom.Point([x,y]));pin.getGeometry().setCoordinates(point.getCoordinates())},criaLayerGrafico:function(){if(!i3GEO.desenho.layergrafico){i3GEO.desenho.layergrafico=new ol.layer.Vector({source:new ol.source.Vector({features:new ol.Collection(),useSpatialIndex:false}),style:new ol.style.Style({fill:new ol.style.Fill({color:'rgba(255, 255, 255, 0.2)'}),stroke:new ol.style.Stroke({color:'#ffcc33',width:4}),image:new ol.style.Circle({radius:7,fill:new ol.style.Fill({color:'#ffcc33'})})})});i3GEO.desenho.layergrafico.setProperties({"layerGr":true,"name":"i3GEOdesenho","title":$trad("layerDesenho"),"isBaseLayer":false},true);i3GEO.desenho.layergrafico.setMap(i3geoOL);i3GEO.desenho.layergrafico.getFeatures=function(){return i3GEO.desenho.layergrafico.getSource().getFeatures()};i3GEO.editor.criaLayerBackup()}}},googlemaps:{shapes:[],inicia:function(){},addBox:function(xmin,ymin,xmax,ymax,namespace,strokeColor,strokeWidth){var f;if(!namespace){namespace="box"}if(!strokeColor){strokeColor="#FF0000"}if(!strokeWidth){strokeWidth=2}i3GEO.desenho.googlemaps.inicia();f=new google.maps.Rectangle({origem:namespace,strokeColor:strokeColor,strokeWeight:strokeWidth,fillOpacity:0,map:i3GeoMap,bounds:new google.maps.LatLngBounds(new google.maps.LatLng(ymin,xmin),new google.maps.LatLng(ymax,xmax))});i3GEO.desenho.googlemaps.shapes.push(f);return f},moveBox:function(box,xmin,ymin,xmax,ymax){box.setBounds(new google.maps.LatLngBounds(new google.maps.LatLng(ymin,xmin),new google.maps.LatLng(ymax,xmax)));return box},addPin:function(x,y,w,h,imagem,namespace,centro,funcaoclick){if(!imagem||imagem===""){imagem=i3GEO.configura.locaplic+"/imagens/google/confluence.png"}if(!namespace){namespace="pin"}if(!w||w===""){w=27}if(!h||h===""){h=27}if(!funcaoclick){funcaoclick=function(){i3GEO.desenho.googlemaps.removePins(namespace)}}if(!centro){centro=false}i3GEO.desenho.googlemaps.inicia();var point,f,icon;if(centro===false){icon={url:imagem,size:new google.maps.Size(w,h)}}else{icon={url:imagem,size:new google.maps.Size(w,h),origin:new google.maps.Point(0,0),anchor:new google.maps.Point(w/2,h/2)}}point=new google.maps.LatLng(y,x);f=new google.maps.Marker({position:point,map:i3GeoMap,origem:namespace,icon:icon});i3GEO.desenho.googlemaps.shapes.push(f);return f},removePins:function(namespace){if(!namespace){namespace="pin"}var f=i3GEO.desenho.googlemaps.getFeaturesByAttribute("origem",namespace);if(f&&f.length>0){i3GEO.desenho.googlemaps.destroyFeatures(f)}},movePin:function(pin,x,y){var point=new google.maps.LatLng(y,x);pin.setPosition(point)},getFeaturesByAttribute:function(atributo,valor){var i,s=[],n=i3GEO.desenho.googlemaps.shapes.length;for(i=0;i<n;i++){if(i3GEO.desenho.googlemaps.shapes[i]&&i3GEO.desenho.googlemaps.shapes[i]!=""){if(i3GEO.desenho.googlemaps.shapes[i][atributo]==valor){s.push(i3GEO.desenho.googlemaps.shapes[i])}}}return s},destroyFeatures:function(f){if(f){var i,n=f.length;for(i=0;i<n;i++){f[i].setMap(null);f[i]=""}}}}};