Commit d37cb7dccda592a9593bd3cb334409aff30316be
1 parent
20aed09b
Exists in
master
and in
7 other branches
Adicionado o js gerdadordelinks.js
Showing
1 changed file
with
452 additions
and
0 deletions
Show diff stats
... | ... | @@ -0,0 +1,452 @@ |
1 | +/* | |
2 | +Title: i3geo/classesjs/geradordelinks.js | |
3 | + | |
4 | +Classe javascript da aplicação de geração de links. | |
5 | + | |
6 | +Lê o conjunto de javascripts para o funcionamento da interface geradordelinks.htm | |
7 | + | |
8 | +File: i3geo/classesjs/geradordelinks.js | |
9 | + | |
10 | +Esse programa possuí as seguintes dependências: | |
11 | + | |
12 | +i3geo/pacotes/cpaint/cpaint2.inc.compressed.js | |
13 | + | |
14 | +i3geo/pacotes/openlayers/OpenLayers.js | |
15 | + | |
16 | +i3geo/classesjs/compactados/funcoes_compacto.js | |
17 | + | |
18 | +As dependências são carregadas pelo próprio geradordelinks.js, não sendo necessário incluir no HTML. | |
19 | + | |
20 | +About: Licença | |
21 | + | |
22 | +I3Geo Interface Integrada de Ferramentas de Geoprocessamento para Internet | |
23 | + | |
24 | +Direitos Autorais Reservados (c) 2006 Ministério do Meio Ambiente Brasil | |
25 | +Desenvolvedor: Edmar Moretti edmar.moretti@mma.gov.br | |
26 | + | |
27 | +Este programa é software livre; você pode redistribuí-lo | |
28 | +e/ou modificá-lo sob os termos da Licença Pública Geral | |
29 | +GNU conforme publicada pela Free Software Foundation; | |
30 | +tanto a versão 2 da Licença. | |
31 | +Este programa é distribuído na expectativa de que seja útil, | |
32 | +porém, SEM NENHUMA GARANTIA; nem mesmo a garantia implícita | |
33 | +de COMERCIABILIDADE OU ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. | |
34 | +Consulte a Licença Pública Geral do GNU para mais detalhes. | |
35 | +Você deve ter recebido uma cópia da Licença Pública Geral do | |
36 | +GNU junto com este programa; se não, escreva para a | |
37 | +Free Software Foundation, Inc., no endereço | |
38 | +59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. | |
39 | + | |
40 | +Veja: | |
41 | + | |
42 | +<i3geo/geradordelinks.htm> | |
43 | + | |
44 | +<i3geo/classesjs/funcoes.js> | |
45 | +*/ | |
46 | +// | |
47 | +//carrega as dependências | |
48 | +// | |
49 | +var scriptLocation = ""; | |
50 | +var scripts = document.getElementsByTagName('script'); | |
51 | +for (var i = 0; i < scripts.length; i++) { | |
52 | + var src = scripts[i].getAttribute('src'); | |
53 | + if (src) { | |
54 | + var index = src.lastIndexOf("geradordelinks.js"); | |
55 | + // is it found, at the end of the URL? | |
56 | + if ((index > -1) && (index + "geradordelinks.js".length == src.length)) { | |
57 | + scriptLocation = src.slice(0, -"geradordelinks.js".length); | |
58 | + break; | |
59 | + } | |
60 | + } | |
61 | +} | |
62 | +//scripts | |
63 | +var allScriptTags = ""; | |
64 | +var jsfiles = new Array() | |
65 | +if(typeof(testafuncoes) == 'undefined') | |
66 | +{jsfiles[1] = "compactados/funcoes_compacto.js"} | |
67 | +if(typeof(cpaint) == 'undefined') | |
68 | +{jsfiles[2] = "../pacotes/cpaint/cpaint2.inc.compressed.js"} | |
69 | +if(typeof(OpenLayers) == 'undefined') | |
70 | +{jsfiles[3] = "../pacotes/openlayers/OpenLayers.js"} | |
71 | +for (var i = 0; i < jsfiles.length; i++) | |
72 | +{ | |
73 | + var currentScriptTag = "<script src='" + scriptLocation + jsfiles[i] + "'></script>"; | |
74 | + allScriptTags += currentScriptTag; | |
75 | +} | |
76 | +document.write(allScriptTags); | |
77 | +// | |
78 | +// | |
79 | +// | |
80 | +//navm = false | |
81 | +//navn = false | |
82 | +//var app = navigator.appName.substring(0,1); | |
83 | +//if (app=='N') navn=true; else navm=true; | |
84 | + | |
85 | + | |
86 | +/* | |
87 | +Classe: i3geo_gl_configura | |
88 | + | |
89 | +Cria o objeto javascript com os parâmetros de configuração da api e com as funções de manipulação. | |
90 | + | |
91 | +Example: | |
92 | + | |
93 | +var i3geo_gl_configura = new i3geo_gl_configura("http://localhost/i3geo","estadosl","temasa","link") | |
94 | + | |
95 | +Parameters: | |
96 | + | |
97 | +loc_i3geo - endereço web onde está instalado o i3geo. | |
98 | + | |
99 | +nomeseltema - identificador do tema inicial que será incluido no link, normalmente estadosl | |
100 | + | |
101 | +temasa - Id do elemento HTML onde a lista de temas adicionados, ou seja, os que forem escolhidos pelo usuário, será incluída. | |
102 | + | |
103 | +link - Id do elemento HTML do tipo <a> onde será mostrado o link criado para o mapa. | |
104 | + | |
105 | +grupo - Id do elemento HTML que receberá o combo com os grupos | |
106 | + | |
107 | +subgrupo - Id do elemento HTML que receberá o combo com os subgrupos | |
108 | + | |
109 | +tema - Id do elemento HTML que receberá o combo com a lista de temas | |
110 | + | |
111 | +buscageo - Id do elemento HTML onde será incluída a opção de busca de coordenadas geográficas | |
112 | +*/ | |
113 | +function i3geo_gl_configura(loc_i3geo,nomeseltema,temasa,link,grupo,subgrupo,tema,buscageo) | |
114 | +{ | |
115 | + /* | |
116 | + Variable: temasa | |
117 | + | |
118 | + Id do elemento HTML onde a lista de temas adicionados, ou seja, os que forem escolhidos pelo usuário, será incluída. | |
119 | + */ | |
120 | + this.temasa = temasa; | |
121 | + /* | |
122 | + Variable: link | |
123 | + | |
124 | + Id do elemento HTML do tipo <a> onde será mostrado o link criado para o mapa. | |
125 | + */ | |
126 | + this.link = link; | |
127 | + /* | |
128 | + Variable: nomeseltema | |
129 | + | |
130 | + Guarda o valor do parâmetro seltema | |
131 | + */ | |
132 | + this.nomeseltema = nomeseltema; | |
133 | + /* | |
134 | + Variable: loc_i3geo | |
135 | + | |
136 | + Guarda o valor do parâmetro loc_i3geo | |
137 | + */ | |
138 | + this.loc_i3geo = loc_i3geo; | |
139 | + /* | |
140 | + Variable: grupo | |
141 | + | |
142 | + Guarda o valor do parâmetro grupo | |
143 | + */ | |
144 | + this.grupo = grupo; | |
145 | + /* | |
146 | + Variable: subgrupo | |
147 | + | |
148 | + Guarda o valor do parâmetro subgrupo | |
149 | + */ | |
150 | + this.subgrupo = subgrupo; | |
151 | + /* | |
152 | + Variable: tema | |
153 | + | |
154 | + Guarda o valor do parâmetro tema | |
155 | + */ | |
156 | + this.tema = tema; | |
157 | + /* | |
158 | + Variable: buscageo | |
159 | + | |
160 | + Guarda o valor do parâmetro buscageo | |
161 | + */ | |
162 | + this.buscageo = buscageo; | |
163 | + /* | |
164 | + Function: seltema | |
165 | + | |
166 | + Adiciona na lista de temas escolhidos pelo usuário um novo tema. | |
167 | + | |
168 | + Ativada quando um grupo ou subgrupo é escolhido. | |
169 | + | |
170 | + Parameters: | |
171 | + | |
172 | + idtema = identificador do tema conforme definido em menutemas/menutemas.xml | |
173 | + */ | |
174 | + this.seltema = function(idtema) | |
175 | + { | |
176 | + var novodiv = document.createElement("div"); | |
177 | + novodiv.style.textAlign="left" | |
178 | + novodiv.id = idtema | |
179 | + $i($i3geo_gl.temasa).appendChild(novodiv); | |
180 | + var novoel = document.createElement("img"); | |
181 | + novoel.title = "excluir" | |
182 | + //novoel.onclick = excluir | |
183 | + eval("novoel.onclick = $i3geo_gl.excluir") | |
184 | + novoel.src = "imagens/x.png" | |
185 | + novodiv.appendChild(novoel); | |
186 | + var novoel = document.createElement("img"); | |
187 | + novoel.title = "subir" | |
188 | + novoel.src = "imagens/sobe.gif" | |
189 | + //novoel.onclick = subir | |
190 | + eval("novoel.onclick = $i3geo_gl.subir") | |
191 | + novodiv.appendChild(novoel); | |
192 | + var novoel = document.createElement("img"); | |
193 | + novoel.title = "descer" | |
194 | + novoel.src = "imagens/desce.gif" | |
195 | + //novoel.onclick = descer | |
196 | + eval("novoel.onclick = $i3geo_gl.descer") | |
197 | + novodiv.appendChild(novoel); | |
198 | + var novoel = document.createElement("input"); | |
199 | + eval("novoel.onclick = function(){$i3geo_gl.crialink()}") | |
200 | + novoel.title = "visível/não visível" | |
201 | + novoel.type = "checkbox" | |
202 | + novoel.style.cursor="pointer" | |
203 | + novoel.style.top="3px" | |
204 | + novoel.style.position="relative" | |
205 | + novoel.style.border="0px" | |
206 | + novoel.value=idtema | |
207 | + novodiv.appendChild(novoel); | |
208 | + var novoel = document.createElement("span"); | |
209 | + novoel.innerHTML = idtema | |
210 | + novodiv.appendChild(novoel); | |
211 | + novodiv.appendChild(document.createElement("br")); | |
212 | + this.crialink() | |
213 | + } | |
214 | + /* | |
215 | + Function: crialink | |
216 | + | |
217 | + Pega os parâmetros especificados pelo usuário e monta o link para mostrar na tela. | |
218 | + */ | |
219 | + this.crialink = function() | |
220 | + { | |
221 | + var ins = $i3geo_gl.loc_i3geo+"/ms_criamapa.php?"; | |
222 | + var iguias = $i($i3geo_gl.temasa).getElementsByTagName("input"); | |
223 | + var tsl = new Array(); //temas ligados | |
224 | + var tsd = new Array(); //temas | |
225 | + for (i=0;i<iguias.length; i++) | |
226 | + { | |
227 | + if (iguias[i].type == "checkbox") | |
228 | + { | |
229 | + tsd.push(iguias[i].value); | |
230 | + if (iguias[i].checked == true) | |
231 | + {tsl.push(iguias[i].value);} | |
232 | + } | |
233 | + } | |
234 | + if(tsd.length > 0) | |
235 | + {ins += "&temasa="+tsd.join(" ")} | |
236 | + if(tsl.length > 0) | |
237 | + {ins += "&layers="+tsl.join(" ")} | |
238 | + if($i("pontos").value != "") | |
239 | + { | |
240 | + ins += "&pontos="+$i("pontos").value | |
241 | + ins += "&nometemapontos="+$i("nometemapontos").value | |
242 | + } | |
243 | + if($i("perfil").value != "") | |
244 | + { | |
245 | + ins += "&perfil="+$i("perfil").value | |
246 | + } | |
247 | + if($i("interface").value != "") | |
248 | + { | |
249 | + ins += "&interface="+$i("interface").value | |
250 | + } | |
251 | + if($i($i3geo_gl.buscageo)) | |
252 | + { | |
253 | + if($i("xmin").value != "") | |
254 | + { | |
255 | + ins += "&mapext="+$i("xmin").value+" " | |
256 | + ins += $i("ymin").value+" " | |
257 | + ins += $i("xmax").value+" " | |
258 | + ins += $i("ymax").value | |
259 | + } | |
260 | + } | |
261 | + $i($i3geo_gl.link).href = ins | |
262 | + $i($i3geo_gl.link).innerHTML = ins | |
263 | + } | |
264 | + /* | |
265 | + Function: combosubgrupos | |
266 | + | |
267 | + Chama a função do i3geo que monta um combo com a lista de subgrupos de um grupo do menu do i3geo | |
268 | + | |
269 | + Parameters: | |
270 | + | |
271 | + idGrupo - id do grupo que será pesquisado | |
272 | + */ | |
273 | + this.combosubgrupos = function(idGrupo) | |
274 | + { | |
275 | + i3geo_comboSubGruposMenu("$i3geo_gl.combotemas",$i3geo_gl.subgrupo,"",idGrupo,"250","1") | |
276 | + } | |
277 | + /* | |
278 | + Function: combotemas | |
279 | + | |
280 | + Monta um combo com a lista de temas vinculados diretamente a um grupo. | |
281 | + | |
282 | + Chamado pela função combosubgrupos. | |
283 | + | |
284 | + Parameters: | |
285 | + | |
286 | + idGrupo - id que identifica o grupo escolhido. | |
287 | + | |
288 | + idSubGrupo - id do sibgrupo | |
289 | + */ | |
290 | + this.combotemas = function (idGrupo,idSubGrupo) | |
291 | + { | |
292 | + i3geo_comboTemasMenu("$i3geo_gl.preseltema",$i3geo_gl.tema,"",idGrupo,idSubGrupo,"250","10") | |
293 | + } | |
294 | + /* | |
295 | + Function: preseltema | |
296 | + | |
297 | + Compatibiliza a chamada da função i3geo_combotemasMenu com a função this.seltema em termos de número de parâmetros | |
298 | + */ | |
299 | + this.preseltema = function(idgrupo,idsubgrupo,idtema) | |
300 | + { | |
301 | + $i3geo_gl.seltema(idtema) | |
302 | + } | |
303 | + /* | |
304 | + Function: descer | |
305 | + | |
306 | + Desce um tema na lista de temas selecionados. | |
307 | + | |
308 | + Parameters: | |
309 | + | |
310 | + e - elemento do DOM do objeto clicado. | |
311 | + */ | |
312 | + this.descer = function(e) | |
313 | + { | |
314 | + var pai = i3geo_pegaElementoPai(e) | |
315 | + divpai = pai.parentNode | |
316 | + if(pai.nextSibling) | |
317 | + divpai.insertBefore(pai,pai.nextSibling.nextSibling) | |
318 | + $i3geo_gl.crialink(); | |
319 | + } | |
320 | + /* | |
321 | + Function: subir | |
322 | + | |
323 | + Sobe um tema na lista de temas selecionados | |
324 | + | |
325 | + Parameters: | |
326 | + | |
327 | + e - elemento do DOM. | |
328 | + */ | |
329 | + this.subir = function(e) | |
330 | + { | |
331 | + var pai = i3geo_pegaElementoPai(e) | |
332 | + divpai = pai.parentNode | |
333 | + divpai.insertBefore(pai,pai.previousSibling) | |
334 | + $i3geo_gl.crialink() | |
335 | + } | |
336 | + /* | |
337 | + Function: excluir | |
338 | + | |
339 | + Exclui um tema da lista de temas selecionados | |
340 | + | |
341 | + Parameters: | |
342 | + | |
343 | + e - elemento do DOM. | |
344 | + */ | |
345 | + this.excluir = function(e) | |
346 | + { | |
347 | + var pai = i3geo_pegaElementoPai(e) | |
348 | + pai.parentNode.removeChild(pai) | |
349 | + $i3geo_gl.crialink() | |
350 | + } | |
351 | + /* | |
352 | + Function: buscageo_init | |
353 | + | |
354 | + Inicializa o OpenLayers para permitir ao usuário escolher a abrangência espacial do link. | |
355 | + */ | |
356 | + this.buscageo_init = function() | |
357 | + { | |
358 | + var ins = "<div style=margin:10px;text-align:left; >" | |
359 | + ins += "<p><b>Utilize o mapa abaixo para definir as coordenadas geográficas do seu mapa, ou digite os valores desejados (opcional):</b></p>" | |
360 | + ins += "<div id=mapa1 style='width:250px;height:250px;border:1px solid blue;display:none'></div>" | |
361 | + ins += "<div style=position:absolute;top:40px;left:270px;text-align:left; >" | |
362 | + ins += "Coordenadas geográficas em décimos de grau:<br><br>" | |
363 | + ins += "Longitude mínima:<br>" | |
364 | + ins += "<div style=padding:5px;width:80px; id=paiXmin >" | |
365 | + ins += "<input onchange='$i3geo_gl.crialink()' type=text size=10 value='' id=xmin />" | |
366 | + ins += "</div><br>" | |
367 | + ins += "Longitude máxima:<br>" | |
368 | + ins += "<div style=padding:5px;width:80px; id=paiXmax >" | |
369 | + ins += "<input onchange='$i3geo_gl.crialink()' type=text size=10 value='' id=xmax />" | |
370 | + ins += "</div><br>" | |
371 | + ins += "Latitude mínima:<br>" | |
372 | + ins += "<div style=padding:5px;width:80px; id=paiYmin >" | |
373 | + ins += "<input onchange='$i3geo_gl.crialink()' type=text size=10 value='' id=ymin />" | |
374 | + ins += "</div><br>" | |
375 | + ins += "Latitude máxima:<br>" | |
376 | + ins += "<div style=padding:5px;width:80px; id=paiYmax >" | |
377 | + ins += "<input onchange='$i3geo_gl.crialink()' type=text size=10 value='' id=ymax />" | |
378 | + ins += "</div><br>" | |
379 | + ins += "<input class=executar size='20' type='button' value='capturar ' onclick='$i3geo_gl.OL.capturageo()' />" | |
380 | + ins += "</div></div>" | |
381 | + document.getElementById(this.buscageo).innerHTML = ins | |
382 | + $i("mapa1").style.display = "block"; | |
383 | + $i3geo_gl.OL = new OpenLayers.Map('mapa1',{controls:[],numZoomLevels: 13}); | |
384 | + // | |
385 | + //layers | |
386 | + // | |
387 | + var ol_wms = new OpenLayers.Layer.WMS( "OpenLayers WMS", "http://labs.metacarta.com/wms/vmap0",{layers: 'basic'},{isBaseLayer: true} ); | |
388 | + ol_wms.setVisibility(true); | |
389 | + $i3geo_gl.OL.addLayer(ol_wms); | |
390 | + var jpl_wms = new OpenLayers.Layer.WMS( "NASA Global Mosaic","http://wms.jpl.nasa.gov/wms.cgi", {layers: "global_mosaic"},{isBaseLayer: false}); | |
391 | + jpl_wms.setVisibility(false); | |
392 | + $i3geo_gl.OL.addLayer(jpl_wms); | |
393 | + var base = new OpenLayers.Layer.WMS( "Cartografia", "http://mapas.mma.gov.br/cgi-bin/mapserv?map=/opt/www/html/webservices/baseraster.map&",{layers:'baseraster',transparent:'true',format:'image/png'},{isBaseLayer:false}); | |
394 | + base.setVisibility(false); | |
395 | + $i3geo_gl.OL.addLayer(base); | |
396 | + // | |
397 | + //zoom e controle de layers | |
398 | + // | |
399 | + var ls = new OpenLayers.Control.LayerSwitcher() | |
400 | + $i3geo_gl.OL.addControl(ls); | |
401 | + $i(ls.id).style.zIndex=2000; | |
402 | + $i3geo_gl.OL.setCenter(new OpenLayers.LonLat(-55,-14), 2); | |
403 | + var panel = new OpenLayers.Control.NavToolbar(); | |
404 | + $i3geo_gl.OL.addControl(panel); | |
405 | + panel.div.style.left="-4px"; | |
406 | + panel.div.style.top="-298px"; | |
407 | + var zb = new OpenLayers.Control.PanZoomBar(); | |
408 | + $i3geo_gl.OL.addControl(zb); | |
409 | + $i("OpenLayers_Control_PanZoom_pandown").style.display="none" | |
410 | + $i("OpenLayers_Control_PanZoom_panup").style.display="none" | |
411 | + $i("OpenLayers_Control_PanZoom_panleft").style.display="none" | |
412 | + $i("OpenLayers_Control_PanZoom_panright").style.display="none" | |
413 | + zb.div.style.left="-8px" | |
414 | + $i3geo_gl.OL.capturageo = function() | |
415 | + { | |
416 | + var b = $i3geo_gl.OL.getExtent(); | |
417 | + $i("xmin").value = b.left | |
418 | + $i("xmax").value = b.right | |
419 | + $i("ymin").value = b.bottom | |
420 | + $i("ymax").value = b.top | |
421 | + $i3geo_gl.crialink() | |
422 | + } | |
423 | + $inputText("paiXmin","","xmin","","","") | |
424 | + $inputText("paiXmax","","xmax","","","") | |
425 | + $inputText("paiYmin","","ymin","","","") | |
426 | + $inputText("paiYmax","","ymax","","","") | |
427 | + } | |
428 | +} | |
429 | +/* | |
430 | +Inicia a interface do gerador de links. | |
431 | + | |
432 | +Parameters: | |
433 | + | |
434 | +objeto_i3geo_gl_configura - objeto com os parâmentros de configuração criado pela função i3geo_gl_configura | |
435 | +*/ | |
436 | +function i3geo_gl_inicia(objeto_i3geo_gl_configura) | |
437 | +{ | |
438 | + /* | |
439 | + Variable: $i3geo_gl | |
440 | + | |
441 | + Contém o objeto | |
442 | + */ | |
443 | + $i3geo_gl = objeto_i3geo_gl_configura; | |
444 | + if(document.getElementById($i3geo_gl.buscageo)) | |
445 | + $i3geo_gl.buscageo_init() | |
446 | + $i3geo_gl.seltema($i3geo_gl.nomeseltema) | |
447 | + i3geo_comboGruposMenu("$i3geo_gl.combosubgrupos",$i3geo_gl.grupo,"","250","1") | |
448 | + | |
449 | + $inputText("paiPontos","","pontos","","","") | |
450 | + $inputText("paiNometemapontos","","nometemapontos","","","") | |
451 | + $inputText("paiPerfil","","perfil","","","") | |
452 | +} | |
0 | 453 | \ No newline at end of file | ... | ... |