barradebotoes.js
6.35 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
/**
* Title: Barra de botões
*
*/
if (typeof (i3GEO) === 'undefined') {
var i3GEO = {};
}
i3GEO.barraDeBotoes =
{
/**
* Function: execBotao
*
* Com base no código de um botão (iddiv), obtém a função armazenada em
* i3GEO.barraDeBotoes.LISTABOTOES e executa.
*
* Parametros:
*
* {string} - identificador do botão, conforme definido no elemento iddiv de i3GEO.barraDeBotoes.LISTABOTOES
*
* {numeric} - (opcional) posição em pixels da tela onde foi feito o clique do mouse
*
* {numeric} - (opcional) posição em pixels da tela onde foi feito o clique do mouse
*/
execBotao : function(id, x, y, posX, posY) {
var botao = i3GEO.barraDeBotoes.defBotao(id);
if (botao === false) {
return;
}
try {
if (botao.funcaoonclick) {
botao.funcaoonclick.call();
}
} catch (e) {
if (typeof (console) !== 'undefined')
console.error("Erro no botao " + id + " " + e);
}
},
/**
* Function: defBotao
*
* Obtém as definições de um botão conforme o seu código (iddiv)
*
* Retorno:
*
* {objeto} - ver i3GEO.barraDeBotoes.LISTABOTOES
*/
defBotao : function(iddiv) {
var l = i3GEO.configura.funcoesBotoes.botoes, b = l.length - 1;
if (b >= 0) {
do {
// temp = l[b].iddiv;
if (l[b].iddiv === iddiv) {
return l[b];
}
} while (b--);
}
return false;
},
/**
* Section: i3GEO.barraDeBotoes.editor
*
* Editor vetorial
*/
editor : {
/**
* Function: inicia
*
* Abre as opções do editor conforme a interface em uso
*/
inicia : function() {
i3GEO.eventos.cliquePerm.desativa();
i3GEO.barraDeBotoes.editor[i3GEO.Interface.ATUAL].inicia("janelaEditorVetorial");
},
// carrega as opcoes de edicao se a interface for do googlemaps
googlemaps : {
inicia : function(idjanela) {
var temp =
function() {
var cabecalho, minimiza, fecha, janela = YAHOO.i3GEO.janela.manager.find("i3GEOjanelaEditor");
if (janela) {
janela.destroy();
}
cabecalho = function() {
};
minimiza = function() {
i3GEO.janela.minimiza("i3GEOjanelaEditor");
};
janela =
i3GEO.janela.cria(
"350px",
"100px",
"",
"",
"",
"<div class='i3GeoTituloJanela'>Editor</div>",
"i3GEOjanelaEditor",
false,
"hd",
cabecalho,
minimiza);
$i("i3GEOjanelaEditor_corpo").style.backgroundColor = "white";
i3GEO.editorGM.inicia("i3GEOjanelaEditor_corpo");
fecha = function() {
var temp = window.confirm($trad("x94"));
if (i3GEO.eventos) {
i3GEO.eventos.cliquePerm.ativa();
}
if (temp === true) {
i3GEO.desenho.googlemaps.destroyFeatures(i3GEO.desenho.googlemaps.shapes);
}
};
$( janela[0].close ).click(fecha);
};
// @TODO incluir o js compactado ao inves do original
if (!i3GEO.editorGM) {
i3GEO.util.scriptTag(
i3GEO.configura.locaplic + "/ferramentas/editorgm/editorgm_compacto.js",
temp,
"editorgm.js",
true);
} else {
temp.call();
}
}
},
openlayers : {
inicia : function(idjanela) {
//TODO mudar carga do JS do editor para o compactado
if (!i3GEO.editorOL) {
//a barra de botoes utiliza codigo do Opelayers2
i3GEO.util.scriptTag(
i3GEO.configura.locaplic + "/ferramentas/editorol/editorol.js",
"i3GEO.barraDeBotoes.editor.openlayers.ativaPainel('" + idjanela + "')",
"editorol.js",
true);
} else {
if (!i3GEO.desenho.layergrafico) {
i3GEO.desenho.openlayers.criaLayerGrafico();
i3GEO.editorOL.mapa.addLayers([
i3GEO.desenho.layergrafico
]);
}
if (!i3GEO.editorOL.backup) {
i3GEO.editorOL.backup = new ol.layer.Vector({
source : new ol.source.Vector({
features : new ol.Collection(),
useSpatialIndex : false,
name : "Backup"
}),
visible: false
});
i3GEO.editorOL.backup.setMap(i3geoOL);
i3GEO.editorOL.backup.getFeatures = function(){
return i3GEO.editorOL.backup.getSource().getFeatures();
};
}
i3GEO.editorOL.criaBotoes(i3GEO.editorOL.botoes);
}
},
criaJanela : function() {
if ($i("i3GEOjanelaEditor")) {
return "i3GEOjanelaEditor";
}
var janela, divid, titulo, cabecalho, minimiza;
cabecalho = function() {
};
minimiza = function() {
i3GEO.janela.minimiza("i3GEOjanelaEditor");
};
// cria a janela flutuante
titulo = "<div class='i3GeoTituloJanela'>"+$trad("u29")+"</div>";
janela = i3GEO.janela.cria("300px", "200px", "", "", "", titulo, "i3GEOjanelaEditor", false, "hd", cabecalho, minimiza);
divid = janela[2].id;
$i("i3GEOjanelaEditor_corpo").style.backgroundColor = "white";
$i("i3GEOjanelaEditor_corpo").style.textAlign = "left";
return divid;
},
ativaPainel : function(idjanela) {
i3GEO.editorOL.fundo = "";// i3GEO.editorOL é criado pelo script carregado
i3GEO.editorOL.mapa = i3geoOL;
i3GEO.editorOL.maxext = "";
i3GEO.editorOL.controles = [];
i3GEO.editorOL.botoes = {
'zoomin' : true,
'zoomout' : true,
'pan' : true,
'zoombox' : true,
'zoomtot' : true,
'legenda' : true,
'distancia' : true,
'area' : true,
'identifica' : true,
'linha' : true,
'ponto' : true,
'poligono' : true,
'texto' : true,
'corta' : true,
'edita' : true,
'listag' : true,
'selecao' : true,
'selecaotudo' : true,
'apaga' : true,
'procura' : false,
'propriedades' : true,
'salva' : true,
'ajuda' : true,
'fecha' : true,
'tools' : true,
'undo' : true,
'frente' : true
};
if (!i3GEO.desenho.layergrafico) {
i3GEO.desenho.openlayers.criaLayerGrafico();
}
if (idjanela) {
i3GEO.editorOL.criaBotoes(i3GEO.editorOL.botoes);
}
}
}
}
};