classe_maparef.js
11.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
/*
Title: Mapa de referência
File: i3geo/classesjs/classe_maparef.js
About: Licença
I3Geo Interface Integrada de Ferramentas de Geoprocessamento para Internet
Direitos Autorais Reservados (c) 2006 Ministério do Meio Ambiente Brasil
Desenvolvedor: Edmar Moretti edmar.moretti@mma.gov.br
Este programa é software livre; você pode redistribuí-lo
e/ou modificá-lo sob os termos da Licença Pública Geral
GNU conforme publicada pela Free Software Foundation;
tanto a versão 2 da Licença.
Este programa é distribuído na expectativa de que seja útil,
porém, SEM NENHUMA GARANTIA; nem mesmo a garantia implícita
de COMERCIABILIDADE OU ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA.
Consulte a Licença Pública Geral do GNU para mais detalhes.
Você deve ter recebido uma cópia da Licença Pública Geral do
GNU junto com este programa; se não, escreva para a
Free Software Foundation, Inc., no endereço
59 Temple Street, Suite 330, Boston, MA 02111-1307 USA.
*/
if(typeof(i3GEO) == 'undefined'){
i3GEO = new Array();
}
/*
Class: i3GEO.maparef
Cria e processa o mapa de referência
Exemplo:
i3Geo.maparef.inicia()
*/
i3GEO.maparef = {
/*
Variable: fatorZoomDinamico
Define o fator de zoom inicial do mapa de referência quando o modo dinâmico for ativado
*/
fatorZoomDinamico: -3,
/*
Property: SELETORTIPO
Inclui ou não o seletor de tipo de mapa de referência
Type:
{Boolean}
Default:
{true}
*/
SELETORTIPO:true,
/*
Property: PERMITEFECHAR
Mostra o botão para fechar a janela ou não.
Type:
{boolean}
*/
PERMITEFECHAR: true,
/*
Property: PERMITEDESLOCAR
Permite deslocar janela ou não.
Type:
{boolean}
*/
PERMITEDESLOCAR: true,
/*
Property: TRANSICAOSUAVE
Altera a transparência quando o mouse sobrepõe ao mapa de referência e quando sai
Essa opção como true não funciona bem no IE
Type:
{boolean}
Default:
{true}
*/
TRANSICAOSUAVE: false,
/*
Property: OPACIDADE
Valor da transparência mínima utilizada quando TRANSICAOSUAVE for igual a true.
Varia de 0 a 100
Type:
{numeric}
Default:
{65}
*/
OPACIDADE: 35,
/*
Property: TOP
Posição da janela em relação ao topo do mapa
{Numeric}
*/
TOP: 4,
/*
Property: RIGHT
Posição da janela em relação ao lado direito do mapa
{Numeric}
*/
RIGHT:0,
/*
Function: inicia
Inicializa o mapa de referência
*/
inicia: function(){
//YAHOO.log("initJanelaRef", "i3geo");
if (!$i("i3geo_winRef")){
var novoel = document.createElement("div");
novoel.id = "i3geo_winRef";
novoel.style.display="none";
novoel.style.borderColor="gray";
var ins = "";
if(i3GEO.maparef.PERMITEDESLOCAR){
ins += '<div class="hd" style="text-align:left;z-index:20;">';
ins += '<span id=maparefmaismenosZoom > ';
var temp = "javascript:if(i3GEO.maparef.fatorZoomDinamico == -1){i3GEO.maparef.fatorZoomDinamico = 1};i3GEO.maparef.fatorZoomDinamico = i3GEO.maparef.fatorZoomDinamico + 1 ;$i(\"refDinamico\").checked = true;i3GEO.maparef.atualiza();";
ins += "<img class=mais onclick='"+temp+"' src="+i3GEO.util.$im("branco.gif")+" />";
var temp = "javascript:if(i3GEO.maparef.fatorZoomDinamico == 1){i3GEO.maparef.fatorZoomDinamico = -1};i3GEO.maparef.fatorZoomDinamico = i3GEO.maparef.fatorZoomDinamico - 1 ;$i(\"refDinamico\").checked = true;i3GEO.maparef.atualiza();";
ins += "<img class=menos onclick='"+temp+"' src="+i3GEO.util.$im("branco.gif")+" /></span> ";
if(i3GEO.maparef.SELETORTIPO){
ins += "<select id='refDinamico' onchange='javascript:i3GEO.maparef.atualiza()'>";
ins += "<option value='fixo' select >fixo</option>";
ins += "<option value='mapa' >mapa</option>";
ins += "<option value='dinamico' >dinâmico</option>";
ins += "</select>";
}
ins += "</div>";
}
ins += '<div class="bd" style="text-align:left;padding:3px;border-bottom-width:1px;" id="mapaReferencia" onmouseover="this.onmousemove=function(exy){i3GEO.eventos.posicaoMouseMapa(exy)}" >';
ins += '<img style="cursor:pointer;" id=imagemReferencia src="" onclick="javascript:i3GEO.maparef.click()">';
//ins += '<div style="text-align:left;font-size:0px" id="refmensagem" ></div></div>';
novoel.innerHTML = ins;
document.body.appendChild(novoel);
if(i3GEO.maparef.TRANSICAOSUAVE){
var novoel = $i("imagemReferencia");
if (navm)
{novoel.style.filter='alpha(opacity='+i3GEO.maparef.OPACIDADE+')';}
else
{novoel.style.opacity= i3GEO.maparef.OPACIDADE / 100;}
novoel.onmouseover = function(){
if (navm)
{novoel.style.filter='alpha(opacity=100)';}
else
{novoel.style.opacity= 1;}
};
novoel.onmouseout = function(){
if (navm)
{novoel.style.filter='alpha(opacity='+i3GEO.maparef.OPACIDADE+')';}
else
{novoel.style.opacity= i3GEO.maparef.OPACIDADE / 100;}
}
}
}
if($i("i3geo_winRef").style.display != "block"){
$i("i3geo_winRef").style.display = "block";
YAHOO.namespace("janelaRef.xp");
var temp = "none";
if(i3GEO.maparef.PERMITEDESLOCAR)
var temp = "shadow";
YAHOO.janelaRef.xp.panel = new YAHOO.widget.Panel("i3geo_winRef", { height:"200px", width:"156px", fixedcenter: false, constraintoviewport: true, underlay:temp, close:i3GEO.maparef.PERMITEFECHAR, visible:true, draggable:i3GEO.maparef.PERMITEDESLOCAR, modal:false } );
YAHOO.janelaRef.xp.panel.render();
var r = $i("i3geo_winRef_c");
if(r){
r.style.clip = "rect(0px, 160px, 179px, 0px)";
r.style.position = "absolute";
}
var pos = i3GEO.util.pegaPosicaoObjeto($i(i3GEO.interface.IDCORPO));
var moveX = pos[0] + i3GEO.parametros.w + 153 - i3GEO.maparef.RIGHT - 300;
var moveY = pos[1] + i3GEO.maparef.TOP;
YAHOO.janelaRef.xp.panel.moveTo(moveX,moveY);
var escondeRef = function(){
YAHOO.util.Event.removeListener(YAHOO.janelaRef.xp.panel.close, "click");
YAHOO.janelaRef.xp.panel.destroy();
i3GEO.util.insereCookie("i3GEO.configura.mapaRefDisplay","none");
};
YAHOO.util.Event.addListener(YAHOO.janelaRef.xp.panel.close, "click", escondeRef);
i3GEO.util.insereCookie("i3GEO.configura.mapaRefDisplay","block");
if(typeof(atualizaLocalizarxy) == "function"){
if(i3GEO.gadgets.PARAMETROS.mostraCoordenadasGEO.idhtml)
YAHOO.util.Event.addListener($i("imagemReferencia"),"mousemove", atualizaLocalizarxy);
}
}
//YAHOO.log("Fim initJanelaRef", "i3geo");
if(i3GEO.eventos.NAVEGAMAPA.toString().search("i3GEO.maparef.atualiza()") < 0)
{i3GEO.eventos.NAVEGAMAPA.push("i3GEO.maparef.atualiza()");}
this.atualiza();
$i("i3geo_winRef_h").className = "hd2";
},
/*
Function: atualiza
Atualiza o mapa de referência.
Se o modo cgi estiver ativado, o mapa de referência é desenhado utilizando-se como src da imagem o programa cgi do Mapserver.
No modo dinâmico, a imagem é gerada de forma diferenciada. Nesse caso, o modo cgi é desabilitado.
O atualizaReferencia é sempre chamado após o mapa ser redesenhado.
Se houve alteração na extensão, é preciso refazer o mapa de referência se não, a imagem atual é armazenada no quado de animação
*/
atualiza: function(){
var dinamico = false;
if ($i("refDinamico"))
{var tiporef = $i("refDinamico").value;}
else
{var tiporef = "fixo";}
if ($i("mapaReferencia")){
var temp = $i("maparefmaismenosZoom");
if(tiporef == "dinamico"){
i3GEO.php.referenciadinamica(i3GEO.maparef.processaImagem,i3GEO.maparef.fatorZoomDinamico,tiporef);
if(temp){temp.style.display="inline";}
}
if(tiporef == "fixo"){
if(($i("imagemReferencia").src == "") || (i3GEO.parametros.cgi != "sim")){
i3GEO.php.referencia(i3GEO.maparef.processaImagem);
if(temp){temp.style.display="none";}
}
else{
var re = new RegExp("&mode=map", "g");
$i("imagemReferencia").src = $i(i3GEO.interface.IDMAPA).src.replace(re,'&mode=reference');
i3GEO.gadgets.quadros.grava("referencia",$i("imagemReferencia").src);
}
}
if(tiporef == "mapa"){
i3GEO.php.referenciadinamica(i3GEO.maparef.processaImagem,i3GEO.maparef.fatorZoomDinamico,tiporef);
if(temp){temp.style.display="inline";}
}
}
else{
if($i("imagemReferencia"))
i3GEO.gadgets.quadros.grava("referencia",$i("imagemReferencia").src);
i3GEO.eventos.NAVEGAMAPA.remove("i3GEO.maparef.atualiza()");
}
},
/*
Function: processaImagem
Substituí a imagem do mapa de referência pela última gerada.
Esta função processa os dados de uma chamada AJAX para atualizar o mapa de referência
Parameters:
retorno - string no formato "var refimagem='nome da imagem'".
*/
processaImagem: function(retorno){
i3GEO.janela.fechaAguarde("ajaxreferencia1");
if ((retorno.data != "erro") && (retorno.data != undefined)){
eval(retorno.data);
i3GEO.parametros.celularef = g_celularef;
i3GEO.parametros.extentref = extentref;
if ($i("imagemReferencia")){
var m = new Image();
m.src = refimagem;
$i("imagemReferencia").src=m.src;
}
i3GEO.gadgets.quadros.grava("referencia",refimagem);
var tiporef = "fixo";
if ($i("refDinamico"))
{var tiporef = $i("refDinamico").value;}
var box = $i("boxref");
if(tiporef != "fixo"){
if (box){box.style.display = "none"}
return;
}
//
//box movel sobre o mapa
//
if (!box){
var novoel = document.createElement("div");
novoel.id = "boxref";
novoel.style.zIndex=10;
novoel.style.position = 'absolute';
novoel.style.cursor = "move";
novoel.style.backgroundColor = "RGB(120,220,220)";
if (navm){novoel.style.filter='alpha(opacity=40)';}
else{novoel.style.opacity= .4;}
$i("mapaReferencia").appendChild(novoel);
var boxrefdd = new YAHOO.util.DD("boxref");
novoel.onmouseup = function(){
var rect = $i("boxref");
var telaminx = parseInt(rect.style.left);
var telamaxy = parseInt(rect.style.top);
var telamaxx = telaminx + parseInt(rect.style.width);
var telaminy = telamaxy + parseInt(rect.style.height);
var m = i3GEO.calculo.tela2dd(telaminx,telaminy,i3GEO.parametros.celularef,i3GEO.parametros.extentref);
var x = i3GEO.calculo.tela2dd(telamaxx,telamaxy,i3GEO.parametros.celularef,i3GEO.parametros.extentref);
var ext = m[0]+" "+m[1]+" "+x[0]+" "+x[1];
i3GEO.navega.zoomExt(i3GEO.configura.locaplic,i3GEO.configura.sid,"",ext);
}
var box = $i("boxref");
}
i3GEO.calculo.ext2rect("boxref",extentref,i3GEO.parametros.mapexten,g_celularef,$i("mapaReferencia"));
if(parseInt(box.style.width) > 120)
box.style.display = "none";
else{
box.style.display = "block";
box.style.top = parseInt(box.style.top)+2;
box.style.left = parseInt(box.style.left)+2;
}
}
},
/*
Function: click
Ocorre quando o usuário clica sobre o mapa de referência, alterando a extensão geográfica do mapa principal
*/
click: function(){
try{
i3GEO.janela.abreAguarde("i3GEO.atualiza",$trad("o1"));
i3GEO.php.pan(i3GEO.atualiza,i3GEO.parametros.mapscale,"ref",objposicaocursor.refx,objposicaocursor.refy);
}
catch(e)
{var e = "";i3GEO.janela.fechaAguarde("i3GEO.atualiza");}
}
};
//YAHOO.log("carregou classe maparef", "Classes i3geo");