Commit bb6547fce58a605a2a5c4a82ffd2a2556e50b81d
1 parent
8704a795
Exists in
master
and in
7 other branches
adicao da classe js que manipula marcadores
Showing
2 changed files
with
191 additions
and
0 deletions
Show diff stats
| ... | ... | @@ -0,0 +1,190 @@ |
| 1 | +/* | |
| 2 | +Title: Marcador | |
| 3 | + | |
| 4 | +i3GEO.marcador | |
| 5 | + | |
| 6 | +Gerencia os marcadores espaciais que o usuario pode definir e compartilhar | |
| 7 | + | |
| 8 | +Os marcadores sao mantidos como cookies | |
| 9 | + | |
| 10 | + | |
| 11 | +Arquivo: | |
| 12 | + | |
| 13 | +i3geo/classesjs/classe_marcador.js | |
| 14 | + | |
| 15 | +Licença: | |
| 16 | + | |
| 17 | +GPL2 | |
| 18 | + | |
| 19 | +i3Geo Interface Integrada de Ferramentas de Geoprocessamento para Internet | |
| 20 | + | |
| 21 | +Direitos Autorais Reservados (c) 2006 Ministério do Meio Ambiente Brasil | |
| 22 | +Desenvolvedor: Edmar Moretti edmar.moretti@gmail.com | |
| 23 | + | |
| 24 | +Este programa é software livre; você pode redistribuí-lo | |
| 25 | +e/ou modificá-lo sob os termos da Licença Pública Geral | |
| 26 | +GNU conforme publicada pela Free Software Foundation; | |
| 27 | + | |
| 28 | +Este programa é distribuído na expectativa de que seja útil, | |
| 29 | +porém, SEM NENHUMA GARANTIA; nem mesmo a garantia implícita | |
| 30 | +de COMERCIABILIDADE OU ADEQUACÃO A UMA FINALIDADE ESPECÍFICA. | |
| 31 | +Consulte a Licença Pública Geral do GNU para mais detalhes. | |
| 32 | +Você deve ter recebido uma cópia da Licença Pública Geral do | |
| 33 | +GNU junto com este programa; se não, escreva para a | |
| 34 | +Free Software Foundation, Inc., no endereço | |
| 35 | +59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. | |
| 36 | +*/ | |
| 37 | +if(typeof(i3GEO) === 'undefined'){ | |
| 38 | + var i3GEO = {}; | |
| 39 | +} | |
| 40 | +i3GEO.marcador = { | |
| 41 | + /** | |
| 42 | + * Pergunta ao usuario o nome do marcador e armazena | |
| 43 | + * O Cookie utilizado chama-se marcadoresDoI3Geo | |
| 44 | + */ | |
| 45 | + prompt: function(){ | |
| 46 | + i3GEO.janela.prompt( | |
| 47 | + $trad("x77"), | |
| 48 | + i3GEO.marcador.armazena, | |
| 49 | + "" | |
| 50 | + ); | |
| 51 | + }, | |
| 52 | + /** | |
| 53 | + * Armazena um novo marcador no cookie | |
| 54 | + * Os cookies sao separados por : | |
| 55 | + * O valor contem o nome seguido por = e o valor da extensao geografica | |
| 56 | + */ | |
| 57 | + armazena: function(){ | |
| 58 | + var cookies = i3GEO.util.pegaCookie("marcadoresDoI3Geo"), | |
| 59 | + ext = i3GEO.parametros.mapexten, | |
| 60 | + nome = "Marcador", | |
| 61 | + valor; | |
| 62 | + if($i("i3GEOjanelaprompt")){ | |
| 63 | + nome = $i("i3GEOjanelaprompt").value; | |
| 64 | + } | |
| 65 | + valor = nome+"|"+ext; | |
| 66 | + if(cookies){ | |
| 67 | + cookies += ":"; | |
| 68 | + } | |
| 69 | + else{ | |
| 70 | + cookies = ""; | |
| 71 | + } | |
| 72 | + valor = cookies + valor; | |
| 73 | + i3GEO.util.insereCookie("marcadoresDoI3Geo",valor,365); | |
| 74 | + i3GEO.marcador.redesenha(); | |
| 75 | + }, | |
| 76 | + redesenha: function(){ | |
| 77 | + var m = i3GEOoMenuBar.getMenu("i3GeoMenuMarcador"); | |
| 78 | + m.clearContent(); | |
| 79 | + m.addItems(i3GEO.marcador.itensMenu()); | |
| 80 | + m.render(); | |
| 81 | + }, | |
| 82 | + exporta: function(){ | |
| 83 | + var c = i3GEO.util.pegaCookie("marcadoresDoI3Geo"), | |
| 84 | + texto; | |
| 85 | + if(!c){ | |
| 86 | + c = ""; | |
| 87 | + } | |
| 88 | + texto = "<p class=paragrafo >"+$trad("x78")+"<br><br><input type=text value='"+ | |
| 89 | + c +"' size=37 />"; | |
| 90 | + i3GEO.janela.mensagemSimples(texto,$trad("x79")); | |
| 91 | + }, | |
| 92 | + exportaShp: function(){ | |
| 93 | + var c = i3GEO.util.pegaCookie("marcadoresDoI3Geo"), | |
| 94 | + temp = function(retorno){ | |
| 95 | + i3GEO.temaAtivo = retorno.data; | |
| 96 | + i3GEO.atualiza(); | |
| 97 | + }; | |
| 98 | + if(c){ | |
| 99 | + i3GEO.php.marcadores2shp(temp); | |
| 100 | + } | |
| 101 | + }, | |
| 102 | + importa: function(){ | |
| 103 | + var temp = function(){ | |
| 104 | + var cookies = i3GEO.util.pegaCookie("marcadoresDoI3Geo"), | |
| 105 | + novos = ""; | |
| 106 | + if($i("i3GEOjanelaprompt")){ | |
| 107 | + novos = $i("i3GEOjanelaprompt").value; | |
| 108 | + } | |
| 109 | + if(cookies){ | |
| 110 | + cookies += ":"; | |
| 111 | + } | |
| 112 | + else{ | |
| 113 | + cookies = ""; | |
| 114 | + } | |
| 115 | + novos = cookies + novos; | |
| 116 | + i3GEO.util.insereCookie("marcadoresDoI3Geo",novos,365); | |
| 117 | + i3GEO.marcador.redesenha(); | |
| 118 | + }; | |
| 119 | + i3GEO.janela.prompt( | |
| 120 | + $trad("x83"), | |
| 121 | + temp, | |
| 122 | + "" | |
| 123 | + ); | |
| 124 | + }, | |
| 125 | + remove: function(nomeMarcador){ | |
| 126 | + var cookie = i3GEO.util.pegaCookie("marcadoresDoI3Geo"), | |
| 127 | + valores = cookie.split(":"), | |
| 128 | + n = valores.length, | |
| 129 | + i,temp,novos = []; | |
| 130 | + for(i=0;i<n;i++){ | |
| 131 | + temp = valores[i].split("|"); | |
| 132 | + if(temp[0] && temp[0] !== nomeMarcador){ | |
| 133 | + novos.push(valores[i]); | |
| 134 | + } | |
| 135 | + } | |
| 136 | + i3GEO.util.insereCookie("marcadoresDoI3Geo",novos.join(":"),365); | |
| 137 | + i3GEO.marcador.redesenha(); | |
| 138 | + }, | |
| 139 | + recuperaZoom: function(nomeMarcador){ | |
| 140 | + var cookie = i3GEO.util.pegaCookie("marcadoresDoI3Geo"), | |
| 141 | + valores = cookie.split(":"), | |
| 142 | + n = valores.length, | |
| 143 | + i,temp; | |
| 144 | + for(i=0;i<n;i++){ | |
| 145 | + temp = valores[i].split("|"); | |
| 146 | + if(temp[0] && temp[0] === nomeMarcador){ | |
| 147 | + i3GEO.navega.zoomExt("","","",temp[1]); | |
| 148 | + return; | |
| 149 | + } | |
| 150 | + } | |
| 151 | + }, | |
| 152 | + /** | |
| 153 | + * Adiciona os itens no objeto menu suspenso no processo de nicializacao do i3geo | |
| 154 | + * | |
| 155 | + * @param objeto com os parametros ja existentes no menu | |
| 156 | + * @return objeto com os parametros complementados | |
| 157 | + */ | |
| 158 | + adicionaMenuSuspenso: function(obj){ | |
| 159 | + obj.menu.push({nome:$trad("x79"),id:"i3GeoMenuMarcador"}); | |
| 160 | + obj.submenus.i3GeoMenuMarcador = i3GEO.marcador.itensMenu(); | |
| 161 | + return obj; | |
| 162 | + }, | |
| 163 | + /** | |
| 164 | + * Itens para o menu suspenso | |
| 165 | + */ | |
| 166 | + itensMenu: function(){ | |
| 167 | + var itens = [], | |
| 168 | + cookie = i3GEO.util.pegaCookie("marcadoresDoI3Geo"), | |
| 169 | + valores,n,i,temp; | |
| 170 | + itens.push( | |
| 171 | + {id:"omenudataMarcadorSalva",text: $trad("x82"), url: "javascript:i3GEO.marcador.prompt()" }, | |
| 172 | + {id:"omenudataMarcadorExporta",text: $trad("x80"), url: "javascript:i3GEO.marcador.exporta()" }, | |
| 173 | + {id:"omenudataMarcadorImporta",text: $trad("x81"), url: "javascript:i3GEO.marcador.importa()" }, | |
| 174 | + {id:"omenudataMarcadorExportaShp",text: $trad("x84"), url: "javascript:i3GEO.marcador.exportaShp()" } | |
| 175 | + ); | |
| 176 | + if(cookie){ | |
| 177 | + valores = cookie.split(":"); | |
| 178 | + n = valores.length; | |
| 179 | + for(i=0;i<n;i++){ | |
| 180 | + temp = valores[i].split("|"); | |
| 181 | + if(temp.length === 2){ | |
| 182 | + itens.push( | |
| 183 | + {id:"omenudataMarcador"+i,text: "<img src='"+i3GEO.configura.locaplic+"/imagens/visual/default/branco.gif' class=x onclick='i3GEO.marcador.remove(\""+temp[0]+"\")' /> <span style=color:blue>"+temp[0]+"</span>", url: "javascript:i3GEO.marcador.recuperaZoom('"+temp[0]+"')" } | |
| 184 | + ); | |
| 185 | + } | |
| 186 | + } | |
| 187 | + } | |
| 188 | + return itens; | |
| 189 | + } | |
| 190 | +}; | |
| 0 | 191 | \ No newline at end of file | ... | ... |
| ... | ... | @@ -0,0 +1 @@ |
| 1 | +if(typeof(i3GEO)==='undefined'){var i3GEO={}}i3GEO.marcador={prompt:function(){i3GEO.janela.prompt($trad("x77"),i3GEO.marcador.armazena,"")},armazena:function(){var cookies=i3GEO.util.pegaCookie("marcadoresDoI3Geo"),ext=i3GEO.parametros.mapexten,nome="Marcador",valor;if($i("i3GEOjanelaprompt")){nome=$i("i3GEOjanelaprompt").value}valor=nome+"|"+ext;if(cookies){cookies+=":"}else{cookies=""}valor=cookies+valor;i3GEO.util.insereCookie("marcadoresDoI3Geo",valor,365);i3GEO.marcador.redesenha()},redesenha:function(){var m=i3GEOoMenuBar.getMenu("i3GeoMenuMarcador");m.clearContent();m.addItems(i3GEO.marcador.itensMenu());m.render()},exporta:function(){var c=i3GEO.util.pegaCookie("marcadoresDoI3Geo"),texto;if(!c){c=""}texto="<p class=paragrafo >"+$trad("x78")+"<br><br><input type=text value='"+c+"' size=37 />";i3GEO.janela.mensagemSimples(texto,$trad("x79"))},exportaShp:function(){var c=i3GEO.util.pegaCookie("marcadoresDoI3Geo"),temp=function(retorno){i3GEO.temaAtivo=retorno.data;i3GEO.atualiza()};if(c){i3GEO.php.marcadores2shp(temp)}},importa:function(){var temp=function(){var cookies=i3GEO.util.pegaCookie("marcadoresDoI3Geo"),novos;if($i("i3GEOjanelaprompt")){novos=$i("i3GEOjanelaprompt").value}if(cookies){cookies+=":"}else{cookies=""}novos=cookies+novos;i3GEO.util.insereCookie("marcadoresDoI3Geo",novos,365);i3GEO.marcador.redesenha()};i3GEO.janela.prompt($trad("x83"),temp,"")},remove:function(nomeMarcador){var cookie=i3GEO.util.pegaCookie("marcadoresDoI3Geo"),valores=cookie.split(":"),n=valores.length,i,temp,m,novos=[];for(i=0;i<n;i++){temp=valores[i].split("|");if(temp[0]&&temp[0]!==nomeMarcador){novos.push(valores[i])}}i3GEO.util.insereCookie("marcadoresDoI3Geo",novos.join(":"),365);i3GEO.marcador.redesenha()},recuperaZoom:function(nomeMarcador){var cookie=i3GEO.util.pegaCookie("marcadoresDoI3Geo"),valores=cookie.split(":"),n=valores.length,i,temp;for(i=0;i<n;i++){temp=valores[i].split("|");if(temp[0]&&temp[0]===nomeMarcador){i3GEO.navega.zoomExt("","","",temp[1]);return}}},adicionaMenuSuspenso:function(obj){obj.menu.push({nome:$trad("x79"),id:"i3GeoMenuMarcador"});obj.submenus.i3GeoMenuMarcador=i3GEO.marcador.itensMenu();return obj},itensMenu:function(){var itens=[],cookie=i3GEO.util.pegaCookie("marcadoresDoI3Geo"),valores,n,i,temp;itens.push({id:"omenudataMarcadorSalva",text:$trad("x82"),url:"javascript:i3GEO.marcador.prompt()"},{id:"omenudataMarcadorExporta",text:$trad("x80"),url:"javascript:i3GEO.marcador.exporta()"},{id:"omenudataMarcadorImporta",text:$trad("x81"),url:"javascript:i3GEO.marcador.importa()"},{id:"omenudataMarcadorExportaShp",text:$trad("x84"),url:"javascript:i3GEO.marcador.exportaShp()"});if(cookie){valores=cookie.split(":");n=valores.length;for(i=0;i<n;i++){temp=valores[i].split("|");if(temp.length===2){itens.push({id:"omenudataMarcador"+i,text:"<img src='"+i3GEO.configura.locaplic+"/imagens/visual/default/branco.gif' class=x onclick='i3GEO.marcador.remove(\""+temp[0]+"\")' /> <span style=color:blue>"+temp[0]+"</span>",url:"javascript:i3GEO.marcador.recuperaZoom('"+temp[0]+"')"})}}}return itens}}; | |
| 0 | 2 | \ No newline at end of file | ... | ... |