Commit 8a2751f17e6e3060845a8c066c63623600eab602
1 parent
354c4a69
Exists in
master
and in
7 other branches
Conclusão do mashup OpenLayers
Showing
6 changed files
with
520 additions
and
355 deletions
Show diff stats
classesjs/classe_arvoredetemas.js
mashups/openlayers.css
... | ... | @@ -82,6 +82,12 @@ background-position:-377px 0; |
82 | 82 | .olControlEditingToolbar .capturaItemActive { |
83 | 83 | background-position:-377px -28px; |
84 | 84 | } |
85 | +.olControlEditingToolbar .procuraItemInactive { | |
86 | +background-position:-406px 0; | |
87 | +} | |
88 | +.olControlEditingToolbar .procuraItemActive { | |
89 | +background-position:-406px -28px; | |
90 | +} | |
85 | 91 | |
86 | 92 | |
87 | 93 | ... | ... |
... | ... | @@ -0,0 +1,499 @@ |
1 | +<?php error_reporting(0);if(extension_loaded('zlib')){ob_start('ob_gzhandler');} header("Content-type: text/javascript"); ?>$i = function(id){return document.getElementById(id);}; | |
2 | +navn = false; | |
3 | +//seta as variáveis navn e navm | |
4 | +var navn = false; | |
5 | +var navm = false; | |
6 | +var app = navigator.appName.substring(0,1); | |
7 | +if (app==='N'){navn=true;}else{navm=true;} | |
8 | + | |
9 | +OpenLayers.ImgPath = "../pacotes/openlayers/img/" | |
10 | +OpenLayers.Lang.setCode("pt-BR"); | |
11 | +i3GEOOL = { | |
12 | + ol_mma: new OpenLayers.Layer.WMS( | |
13 | + "Base cartográfica", | |
14 | + "http://mapas.mma.gov.br/cgi-bin/mapserv?map=/opt/www/html/webservices/baseraster.map&", | |
15 | + {layers:'baseraster',SRS:'EPSG:4291'} | |
16 | + ), | |
17 | + ol_wms: new OpenLayers.Layer.WMS.Untiled( | |
18 | + "OpenLayers WMS", | |
19 | + "http://labs.metacarta.com/wms/vmap0", | |
20 | + {layers: 'basic'} | |
21 | + ), | |
22 | + jpl_wms: new OpenLayers.Layer.WMS( | |
23 | + "NASA Global Mosaic", | |
24 | + "http://t1.hypercube.telascience.org/cgi-bin/landsat7", | |
25 | + {layers: "landsat7"} | |
26 | + ), | |
27 | + layergrafico: new OpenLayers.Layer.Vector("Edição"), | |
28 | + layersIniciais: <?php echo implode(",",$objOpenLayers); ?>, | |
29 | + botoes: <?php echo $botoes; ?>, | |
30 | + mapa: new OpenLayers.Map('i3geoMapa', { | |
31 | + controls: [ | |
32 | + <?php echo implode(",",$objControles); ?> | |
33 | + ], | |
34 | + numZoomLevels: <?php echo $numzoomlevels;?>, | |
35 | + maxExtent: new OpenLayers.Bounds(<?php echo $maxextent;?>) | |
36 | + }), | |
37 | + inicia: function(){ | |
38 | + i3GEOOL.jpl_wms.setVisibility(false); | |
39 | + i3GEOOL.ol_wms.setVisibility(false); | |
40 | + i3GEOOL.mapa.addLayers([ | |
41 | + i3GEOOL.ol_mma, | |
42 | + i3GEOOL.ol_wms, | |
43 | + i3GEOOL.jpl_wms, | |
44 | + i3GEOOL.layersIniciais, | |
45 | + i3GEOOL.layergrafico | |
46 | + ]); | |
47 | + i3GEOOL.mapa.zoomToMaxExtent(); | |
48 | + i3GEOOL.coordenadas(); | |
49 | + i3GEOOL.criaJanelaBusca(); | |
50 | + i3GEOOL.criaJanelaAtivaTema(); | |
51 | + i3GEOOL.criaBotoes(i3GEOOL.botoes); | |
52 | + }, | |
53 | + layersLigados: function(){ | |
54 | + var layers = i3GEOOL.mapa.layers; | |
55 | + var nlayers = layers.length; | |
56 | + var ins = new Array(); | |
57 | + for(i=0;i<nlayers;i++){ | |
58 | + if(layers[i].isBaseLayer == false){ | |
59 | + ins.push(layers[i]); | |
60 | + } | |
61 | + } | |
62 | + return ins; | |
63 | + }, | |
64 | + coordenadas: function(){ | |
65 | + // | |
66 | + //substitui o controle que mostra as coordenadas | |
67 | + // | |
68 | + var idcoord = i3GEOOL.mapa.getControlsBy("separator"," "); | |
69 | + if(idcoord[0]){ | |
70 | + i3GEOOL.mapa.events.register("mousemove", i3GEOOL.mapa, function(e){ | |
71 | + var p,lonlat,d,dc; | |
72 | + if (navm) | |
73 | + {p = new OpenLayers.Pixel(e.x,e.y);} | |
74 | + else | |
75 | + {p = e.xy;} | |
76 | + //altera o indicador de localizacao | |
77 | + lonlat = i3GEOOL.mapa.getLonLatFromPixel(p); | |
78 | + d = i3GEO.calculo.dd2dms(lonlat.lon,lonlat.lat); | |
79 | + try{ | |
80 | + $i(idcoord[0].id).innerHTML = "Long: "+d[0]+"<br>Lat: "+d[1]; | |
81 | + } | |
82 | + catch(e){ | |
83 | + if(typeof(console) !== 'undefined'){console.error(e);} | |
84 | + } | |
85 | + }); | |
86 | + } | |
87 | + }, | |
88 | + criaJanelaBusca: function(){ | |
89 | + var layers = i3GEOOL.layersLigados(); | |
90 | + var nlayers = layers.length; | |
91 | + var combo = "<select id=i3GEOOLlistaTemasBusca ><option value=''>----</option>"; | |
92 | + for(i=0;i<nlayers;i++){ | |
93 | + combo += "<option value='"+i+"' >"+layers[i].name+"</option>"; | |
94 | + } | |
95 | + combo += "</select>"; | |
96 | + var ins = "<div class=paragrafo >Tema:<br>"+combo; | |
97 | + ins += "<br>Item:<br><span id=i3GEOOLcomboitens ></span>"; | |
98 | + ins += "<br>Procurar por:<br><input type=text size=20 id=i3GEOOLpalavraBusca >"; | |
99 | + ins += "<br><br><input type=button value='Procurar' id='i3GEOOLbotaoBusca' ></div>"; | |
100 | + ins += "<br>Resultado:<br><span id=i3GEOOLcomboresultado ></span>"; | |
101 | + YAHOO.namespace("procura.container"); | |
102 | + YAHOO.procura.container.panel = new YAHOO.widget.Panel("panelprocura", {zIndex:2000, iframe:false, width:"250px", visible:false, draggable:true, close:true } ); | |
103 | + YAHOO.procura.container.panel.setHeader("Encontre no mapa"); | |
104 | + YAHOO.procura.container.panel.setBody(ins); | |
105 | + YAHOO.procura.container.panel.setFooter(""); | |
106 | + YAHOO.procura.container.panel.render(document.body); | |
107 | + YAHOO.procura.container.panel.center(); | |
108 | + document.getElementById("i3GEOOLbotaoBusca").onclick = function(){ | |
109 | + var layer = i3GEOOL.layerAtivo(); | |
110 | + var item = document.getElementById("i3GEOOLbuscaItem").value; | |
111 | + var palavra = document.getElementById("i3GEOOLpalavraBusca").value; | |
112 | + if(item == "" || palavra == "") | |
113 | + {alert("Escolha o item e o texto de busca");return;} | |
114 | + i3GEOOL.busca(layer,item,palavra,"i3GEOOLcomboresultado"); | |
115 | + }; | |
116 | + document.getElementById("i3GEOOLlistaTemasBusca").onchange = function(){ | |
117 | + i3GEOOL.ativaTema(this.value); | |
118 | + document.getElementById("i3GEOOLcomboitens").innerHTML = "..."; | |
119 | + i3GEOOL.listaItens(i3GEOOL.layerAtivo(),"i3GEOOLcomboitens","i3GEOOLbuscaItem"); | |
120 | + }; | |
121 | + }, | |
122 | + criaJanelaAtivaTema: function(){ | |
123 | + var layers = i3GEOOL.layersLigados(); | |
124 | + var nlayers = layers.length; | |
125 | + var combo = "<select id=i3GEOOLlistaTemasAtivos >"; | |
126 | + for(i=0;i<nlayers;i++){ | |
127 | + combo += "<option value='"+i+"' >"+layers[i].name+"</option>"; | |
128 | + } | |
129 | + combo += "</select>"; | |
130 | + YAHOO.namespace("temaativo.container"); | |
131 | + YAHOO.temaativo.container.panel = new YAHOO.widget.Panel("paneltemaativo", {zIndex:2000, iframe:false, width:"250px", visible:false, draggable:true, close:true } ); | |
132 | + YAHOO.temaativo.container.panel.setHeader("Tema ativo"); | |
133 | + YAHOO.temaativo.container.panel.setBody(combo); | |
134 | + YAHOO.temaativo.container.panel.setFooter(""); | |
135 | + YAHOO.temaativo.container.panel.render(document.body); | |
136 | + YAHOO.temaativo.container.panel.center(); | |
137 | + document.getElementById("i3GEOOLlistaTemasAtivos").onchange = function(){ | |
138 | + if(botaoIdentifica){ | |
139 | + botaoIdentifica.layers = [i3GEOOL.layersLigados()[this.value]]; | |
140 | + } | |
141 | + }; | |
142 | + }, | |
143 | + ativaTema: function(id){ | |
144 | + document.getElementById("i3GEOOLlistaTemasAtivos").value = id; | |
145 | + }, | |
146 | + layerAtivo: function(){ | |
147 | + var id = document.getElementById("i3GEOOLlistaTemasAtivos").value; | |
148 | + return i3GEOOL.layersLigados()[id]; | |
149 | + }, | |
150 | + listaItens: function(layer,idonde,idobj){ | |
151 | + if(!layer){return;} | |
152 | + if(!layer.params){return;} | |
153 | + var u = layer.url+"&request=describefeaturetype&service=wfs&version=1.0.0"; | |
154 | + u += "&typename="+layer.params.LAYERS; | |
155 | + document.body.style.cursor="wait"; | |
156 | + document.getElementById("i3geoMapa").style.cursor = "wait"; | |
157 | + OpenLayers.Request.issue({ | |
158 | + method: "GET", | |
159 | + url: u, | |
160 | + callback: function(retorno){ | |
161 | + document.body.style.cursor="default"; | |
162 | + document.getElementById("i3geoMapa").style.cursor = "default"; | |
163 | + var fromgml = new OpenLayers.Format.WFSDescribeFeatureType({ | |
164 | + geometryName: "msGeometry" | |
165 | + }); | |
166 | + var gml = fromgml.read(retorno.responseText); | |
167 | + var prop = gml.featureTypes[0].properties; | |
168 | + var nprop = prop.length; | |
169 | + var itens = new Array(); | |
170 | + var combo = "<select id="+idobj+" ><option value=''>----</option>"; | |
171 | + for(i = 0;i < nprop; i++){ | |
172 | + combo += "<option value="+prop[i].name+" >"+prop[i].name+"</option>"; | |
173 | + } | |
174 | + combo += "</select>"; | |
175 | + document.getElementById(idonde).innerHTML = combo; | |
176 | + | |
177 | + }, | |
178 | + failure: function(){ | |
179 | + document.body.style.cursor="default"; | |
180 | + document.getElementById("i3geoMapa").style.cursor = "default"; | |
181 | + alert("Erro"); | |
182 | + } | |
183 | + }) | |
184 | + }, | |
185 | + busca: function(layer,item,palavra,onde){ | |
186 | + document.body.style.cursor="wait"; | |
187 | + document.getElementById("i3geoMapa").style.cursor = "wait"; | |
188 | + var u = layer.url+"&request=getfeature&service=wfs&version=1.0.0"; | |
189 | + u += "&OUTPUTFORMAT=gml2&typename="+layer.params.LAYERS; | |
190 | + u += "&filter=<Filter><PropertyIsLike wildcard=* singleChar=. escape=! ><PropertyName>"+item+"</PropertyName><Literal>*"+palavra+"*</Literal></PropertyIsLike></Filter>"; | |
191 | + document.body.style.cursor="wait"; | |
192 | + document.getElementById("i3geoMapa").style.cursor = "wait"; | |
193 | + document.getElementById(onde).innerHTML = "..."; | |
194 | + OpenLayers.Request.issue({ | |
195 | + method: "GET", | |
196 | + url: u, | |
197 | + callback: function(retorno){ | |
198 | + document.body.style.cursor="default"; | |
199 | + document.getElementById("i3geoMapa").style.cursor = "default"; | |
200 | + var fromgml = new OpenLayers.Format.GML({ | |
201 | + geometryName: "msGeometry" | |
202 | + }); | |
203 | + var gml = fromgml.read(retorno.responseText); | |
204 | + var ngml = gml.length; | |
205 | + var ins = "<select onchange='i3GEOOL.zoomPara(this.value)'>"; | |
206 | + ins += "<option value=''>---</option>"; | |
207 | + for(i=0;i<ngml;i++){ | |
208 | + eval("var valor = gml[i].data."+item); | |
209 | + var bounds = gml[i].geometry.getBounds(); | |
210 | + var bounds = bounds.toBBOX(); | |
211 | + ins += "<option value='"+bounds+"'>"+valor+"</option>"; | |
212 | + } | |
213 | + ins += "</select>"; | |
214 | + document.getElementById(onde).innerHTML = ins; | |
215 | + }, | |
216 | + failure: function(){ | |
217 | + document.body.style.cursor="default"; | |
218 | + document.getElementById("i3geoMapa").style.cursor = "default"; | |
219 | + alert("Erro"); | |
220 | + } | |
221 | + }) | |
222 | + }, | |
223 | + zoomPara: function(bbox){ | |
224 | + var b = new OpenLayers.Bounds.fromString(bbox); | |
225 | + i3GEOOL.mapa.zoomToExtent(b); | |
226 | + }, | |
227 | + mostraLegenda: function(){ | |
228 | + var layers = i3GEOOL.layersLigados(); | |
229 | + var nlayers = layers.length; | |
230 | + var ins = ""; | |
231 | + for(i=0;i<nlayers;i++){ | |
232 | + var url = layers[i].getFullRequestString({"request":"getlegendgraphic"}); | |
233 | + url = url.replace("LAYERS","LAYER"); | |
234 | + ins += "<img src='"+url+"' /><br>"; | |
235 | + } | |
236 | + var w = window.open() | |
237 | + w.document.write(ins) | |
238 | + w.document.close(); | |
239 | + }, | |
240 | + captura: function(lonlat){ | |
241 | + var layers = [i3GEOOL.layerAtivo()]; | |
242 | + var u = layers[0].url+"&request=getfeature&service=wfs&version=1.0.0"; | |
243 | + u += "&OUTPUTFORMAT=gml2&typename="+layers[0].params.LAYERS; | |
244 | + u += "&filter=<Filter><Intersect><PropertyName>Geometry</PropertyName><gml:Point><gml:coordinates>"+lonlat+"</gml:coordinates></gml:Point></Intersect></Filter>"; | |
245 | + document.body.style.cursor="wait"; | |
246 | + document.getElementById("i3geoMapa").style.cursor = "wait"; | |
247 | + OpenLayers.Request.issue({ | |
248 | + method: "GET", | |
249 | + url: u, | |
250 | + callback: function(retorno){ | |
251 | + document.body.style.cursor="default"; | |
252 | + document.getElementById("i3geoMapa").style.cursor = "default"; | |
253 | + var fromgml = new OpenLayers.Format.GML({ | |
254 | + geometryName: "msGeometry" | |
255 | + }); | |
256 | + var gml = fromgml.read(retorno.responseText); | |
257 | + i3GEOOL.layergrafico.addFeatures(gml); | |
258 | + }, | |
259 | + failure: function(){ | |
260 | + document.body.style.cursor="default"; | |
261 | + document.getElementById("i3geoMapa").style.cursor = "default"; | |
262 | + alert("Erro"); | |
263 | + } | |
264 | + }) | |
265 | + }, | |
266 | + criaBotoes: function(botoes){ | |
267 | + var sketchSymbolizers = { | |
268 | + "Point": { | |
269 | + pointRadius: 4, | |
270 | + graphicName: "square", | |
271 | + fillColor: "white", | |
272 | + fillOpacity: 1, | |
273 | + strokeWidth: 1, | |
274 | + strokeOpacity: 1, | |
275 | + strokeColor: "#333333" | |
276 | + }, | |
277 | + "Line": { | |
278 | + strokeWidth: 3, | |
279 | + strokeOpacity: 1, | |
280 | + strokeColor: "#666666", | |
281 | + strokeDashstyle: "dash" | |
282 | + }, | |
283 | + "Polygon": { | |
284 | + strokeWidth: 2, | |
285 | + strokeOpacity: 1, | |
286 | + strokeColor: "#666666", | |
287 | + fillColor: "white", | |
288 | + fillOpacity: 0.3 | |
289 | + } | |
290 | + }; | |
291 | + var style = new OpenLayers.Style(); | |
292 | + style.addRules([ | |
293 | + new OpenLayers.Rule({symbolizer: sketchSymbolizers}) | |
294 | + ]); | |
295 | + var styleMap = new OpenLayers.StyleMap({"default": style}); | |
296 | + | |
297 | + var adiciona = false; | |
298 | + var controles = new Array(); | |
299 | + var panel = new OpenLayers.Control.Panel({ | |
300 | + displayClass: "olControlEditingToolbar noprint" | |
301 | + }); | |
302 | + if(botoes.procura==true){ | |
303 | + var button = new OpenLayers.Control.Button({ | |
304 | + displayClass: "procura", | |
305 | + trigger: function(){YAHOO.procura.container.panel.show();}, | |
306 | + title: "Procurar" | |
307 | + }); | |
308 | + controles.push(button); | |
309 | + var adiciona = true; | |
310 | + } | |
311 | + if(botoes.pan==true){ | |
312 | + controles.push(new OpenLayers.Control.Navigation({title: "Deslocar",displayClass:"pan"})); | |
313 | + var adiciona = true; | |
314 | + } | |
315 | + if(botoes.zoombox==true){ | |
316 | + controles.push(new OpenLayers.Control.ZoomBox({displayClass: "zoombox",title: "Zoom"})); | |
317 | + var adiciona = true; | |
318 | + } | |
319 | + if(botoes.zoomtot==true){ | |
320 | + var button = new OpenLayers.Control.Button({ | |
321 | + displayClass: "zoomtot", | |
322 | + trigger: function(){i3GEOOL.mapa.zoomToMaxExtent();}, | |
323 | + title: "Ajusta extensão" | |
324 | + }); | |
325 | + controles.push(button); | |
326 | + var adiciona = true; | |
327 | + } | |
328 | + if(botoes.legenda==true){ | |
329 | + var button = new OpenLayers.Control.Button({ | |
330 | + displayClass: "legenda", | |
331 | + trigger: function(){i3GEOOL.mostraLegenda();}, | |
332 | + title: "Legenda" | |
333 | + }); | |
334 | + controles.push(button); | |
335 | + var adiciona = true; | |
336 | + } | |
337 | + if(botoes.distancia==true){ | |
338 | + var button = new OpenLayers.Control.Measure( | |
339 | + OpenLayers.Handler.Path, | |
340 | + { | |
341 | + handlerOptions: {layerOptions: {styleMap: styleMap}}, | |
342 | + persist: true, | |
343 | + displayClass: "distancia", | |
344 | + title: "Distância" | |
345 | + } | |
346 | + ); | |
347 | + button.events.on({ | |
348 | + "measure": function(event){ | |
349 | + var units = event.units; | |
350 | + var measure = event.measure; | |
351 | + alert("Distância: " + measure.toFixed(3) + " " + units); | |
352 | + }, | |
353 | + }); | |
354 | + controles.push(button); | |
355 | + var adiciona = true; | |
356 | + } | |
357 | + if(botoes.area==true){ | |
358 | + var button = new OpenLayers.Control.Measure( | |
359 | + OpenLayers.Handler.Polygon, | |
360 | + { | |
361 | + handlerOptions: {layerOptions: {styleMap: styleMap}}, | |
362 | + persist: true, | |
363 | + displayClass: "area", | |
364 | + title: "Área" | |
365 | + } | |
366 | + ); | |
367 | + button.events.on({ | |
368 | + "measure": function(event){ | |
369 | + var units = event.units; | |
370 | + var measure = event.measure; | |
371 | + alert("Área: " + measure.toFixed(3) + " " + units + " quadrados"); | |
372 | + }, | |
373 | + }); | |
374 | + controles.push(button); | |
375 | + var adiciona = true; | |
376 | + } | |
377 | + if(botoes.identifica==true){ | |
378 | + botaoIdentifica = new OpenLayers.Control.WMSGetFeatureInfo({ | |
379 | + maxFeatures:1, | |
380 | + infoFormat:'text/plain', //'application/vnd.ogc.gml', | |
381 | + layers: [i3GEOOL.layerAtivo()], | |
382 | + queryVisible: true, | |
383 | + title: "Identificar", | |
384 | + displayClass: "identifica", | |
385 | + eventListeners: { | |
386 | + getfeatureinfo: function(event) { | |
387 | + var lonlat = i3GEOOL.mapa.getLonLatFromPixel(event.xy); | |
388 | + var lonlattexto = "<hr><pre><span style=color:blue;cursor:pointer onclick='i3GEOOL.captura(\""+lonlat.lon+","+lonlat.lat+"\")'>captura</span></pre>"; | |
389 | + i3GEOOL.mapa.addPopup(new OpenLayers.Popup.FramedCloud( | |
390 | + "chicken", | |
391 | + i3GEOOL.mapa.getLonLatFromPixel(event.xy), | |
392 | + null, | |
393 | + lonlattexto+"<pre>"+event.text+"</pre>", | |
394 | + null, | |
395 | + true | |
396 | + )); | |
397 | + }, | |
398 | + activate: function(){ | |
399 | + YAHOO.temaativo.container.panel.show(); | |
400 | + } | |
401 | + } | |
402 | + }); | |
403 | + //button.events.register("getfeatureinfo", this, showInfo); | |
404 | + controles.push(botaoIdentifica); | |
405 | + var adiciona = true; | |
406 | + } | |
407 | + if(botoes.linha==true){ | |
408 | + button = new OpenLayers.Control.DrawFeature( | |
409 | + i3GEOOL.layergrafico, | |
410 | + OpenLayers.Handler.Path, | |
411 | + { | |
412 | + displayClass: "linha", | |
413 | + title: "digitalizar linha" | |
414 | + } | |
415 | + ); | |
416 | + controles.push(button); | |
417 | + var adiciona = true; | |
418 | + } | |
419 | + if(botoes.ponto==true){ | |
420 | + button = new OpenLayers.Control.DrawFeature( | |
421 | + i3GEOOL.layergrafico, | |
422 | + OpenLayers.Handler.Point, | |
423 | + { | |
424 | + displayClass: "ponto", | |
425 | + title: "digitalizar ponto" | |
426 | + } | |
427 | + ); | |
428 | + controles.push(button); | |
429 | + var adiciona = true; | |
430 | + } | |
431 | + if(botoes.poligono==true){ | |
432 | + button = new OpenLayers.Control.DrawFeature( | |
433 | + i3GEOOL.layergrafico, | |
434 | + OpenLayers.Handler.Polygon, | |
435 | + { | |
436 | + displayClass: "poligono", | |
437 | + title: "digitalizar polígono" | |
438 | + } | |
439 | + ); | |
440 | + controles.push(button); | |
441 | + var adiciona = true; | |
442 | + } | |
443 | + if(botoes.edita==true){ | |
444 | + button = new OpenLayers.Control.ModifyFeature( | |
445 | + i3GEOOL.layergrafico, | |
446 | + { | |
447 | + displayClass: "edita", | |
448 | + title: "edita elemento" | |
449 | + } | |
450 | + ); | |
451 | + controles.push(button); | |
452 | + var adiciona = true; | |
453 | + } | |
454 | + //botao de seleção | |
455 | + if(botoes.apaga==true){ | |
456 | + button = new OpenLayers.Control.SelectFeature( | |
457 | + i3GEOOL.layergrafico, | |
458 | + { | |
459 | + displayClass: "selecao", | |
460 | + title: "seleciona elemento", | |
461 | + clickout: true, | |
462 | + toggle: true, | |
463 | + multiple: false, | |
464 | + hover: false, | |
465 | + toggleKey: "ctrlKey", // ctrl key removes from selection | |
466 | + multipleKey: "shiftKey", // shift key adds to selection | |
467 | + box: false | |
468 | + } | |
469 | + ); | |
470 | + controles.push(button); | |
471 | + var adiciona = true; | |
472 | + } | |
473 | + if(botoes.apaga==true){ | |
474 | + var button = new OpenLayers.Control.Button({ | |
475 | + displayClass: "apaga", | |
476 | + trigger: function(){ | |
477 | + if(i3GEOOL.layergrafico.selectedFeatures.length > 0){ | |
478 | + var x = window.confirm("Exclui os elementos selecionados?"); | |
479 | + if(x) | |
480 | + {i3GEOOL.layergrafico.removeFeatures(i3GEOOL.layergrafico.selectedFeatures);} | |
481 | + } | |
482 | + else | |
483 | + {alert("Selecione pelo menos um elemento");} | |
484 | + }, | |
485 | + title: "Apaga selecionados" | |
486 | + }); | |
487 | + controles.push(button); | |
488 | + var adiciona = true; | |
489 | + } | |
490 | + // | |
491 | + //adiciona o painel ao mapa se alguma op��o foi inserida | |
492 | + // | |
493 | + if(adiciona == true){ | |
494 | + panel.addControls(controles); | |
495 | + i3GEOOL.mapa.addControl(panel); | |
496 | + } | |
497 | + } | |
498 | +}; | |
499 | +<?php if(extension_loaded('zlib')){ob_end_flush();}?> | |
0 | 500 | \ No newline at end of file | ... | ... |
mashups/openlayers.php
... | ... | @@ -90,7 +90,7 @@ if(!isset($botoes)){ |
90 | 90 | $objBotoes[] = "'poligono':true"; |
91 | 91 | $objBotoes[] = "'edita':true"; |
92 | 92 | $objBotoes[] = "'apaga':true"; |
93 | - $objBotoes[] = "'captura':false"; | |
93 | + $objBotoes[] = "'procura':true"; | |
94 | 94 | } |
95 | 95 | else{ |
96 | 96 | $botoes = str_replace(" ",",",$botoes); |
... | ... | @@ -120,8 +120,8 @@ else{ |
120 | 120 | {$objBotoes[] = "'edita':true";} |
121 | 121 | if(in_array("apaga",$botoes)) |
122 | 122 | {$objBotoes[] = "'apaga':true";} |
123 | - if(in_array("captura",$botoes)) | |
124 | - {$objBotoes[] = "'captura':false";} | |
123 | + if(in_array("procura",$botoes)) | |
124 | + {$objBotoes[] = "'procura':false";} | |
125 | 125 | } |
126 | 126 | $botoes = "{".implode(",",$objBotoes)."}"; |
127 | 127 | // |
... | ... | @@ -187,6 +187,7 @@ Parâmetros: |
187 | 187 | edita |
188 | 188 | apaga |
189 | 189 | captura |
190 | + procura | |
190 | 191 | |
191 | 192 | Para ver a lista de códigos de temas, que podem ser utilizados no parâmetro 'temas', acesse: |
192 | 193 | <a href='../ogc.php?lista=temas' >lista de temas</a>. Os códigos são mostrados em vermelho. |
... | ... | @@ -202,363 +203,22 @@ Parâmetros: |
202 | 203 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> |
203 | 204 | <html> |
204 | 205 | <head> |
206 | +<link rel="stylesheet" type="text/css" href="../pacotes/yui270/build/fonts/fonts-min.css" /> | |
207 | +<link rel="stylesheet" type="text/css" href="../pacotes/yui270/build/container/assets/skins/sam/container.css" /> | |
208 | +<script type="text/javascript" src="../pacotes/yui270/build/yahoo-dom-event/yahoo-dom-event.js"></script> | |
209 | +<script type="text/javascript" src="../pacotes/yui270/build/dragdrop/dragdrop-min.js"></script> | |
210 | +<script type="text/javascript" src="../pacotes/yui270/build/container/container-min.js"></script> | |
205 | 211 | <script type="text/javascript" src="../classesjs/compactados/classe_calculo_compacto.js"></script> |
206 | 212 | <script type="text/javascript" src="../pacotes/openlayers/OpenLayers.js.php"></script> |
207 | 213 | <link rel="stylesheet" href="theme/default/style.css" type="text/css" /> |
208 | 214 | <link rel="stylesheet" href="openlayers.css" type="text/css" /> |
209 | - | |
210 | 215 | </head> |
211 | -<body> | |
216 | +<body class=" yui-skin-sam"> | |
212 | 217 | <div id=i3geoMapa style="width:<?php echo $largura;?>px;height:<?php echo $altura;?>px;"></div> |
218 | +<div id=i3geoSelTemaAtivo style="height:15em;z-index:3000" class=" yui-skin-sam"></div> | |
213 | 219 | <script type="text/javascript"> |
214 | -navn = false; | |
215 | -//seta as variáveis navn e navm | |
216 | -var navn = false; | |
217 | -var navm = false; | |
218 | -var app = navigator.appName.substring(0,1); | |
219 | -if (app==='N'){navn=true;}else{navm=true;} | |
220 | - | |
221 | -OpenLayers.ImgPath = "../pacotes/openlayers/img/" | |
222 | -OpenLayers.Lang.setCode("pt-BR"); | |
223 | -function i3GeoMapaInicia(){ | |
224 | - i3geoOL = new OpenLayers.Map('i3geoMapa', { | |
225 | - controls: [ | |
226 | - <?php echo implode(",",$objControles); ?> | |
227 | - ], | |
228 | - numZoomLevels: <?php echo $numzoomlevels;?>, | |
229 | - maxExtent: new OpenLayers.Bounds(<?php echo $maxextent;?>) | |
230 | - }); | |
231 | - var ol_wms = new OpenLayers.Layer.WMS.Untiled( "OpenLayers WMS","http://labs.metacarta.com/wms/vmap0",{layers: 'basic'} ); | |
232 | - var jpl_wms = new OpenLayers.Layer.WMS( "NASA Global Mosaic","http://t1.hypercube.telascience.org/cgi-bin/landsat7",{layers: "landsat7"}); | |
233 | - jpl_wms.setVisibility(false); | |
234 | - layergrafico = new OpenLayers.Layer.Vector("Edição"); | |
235 | - i3geoOL.addLayers([ol_wms, jpl_wms, <?php echo implode(",",$objOpenLayers); ?>,layergrafico]); | |
236 | - i3geoOL.zoomToMaxExtent(); | |
237 | - // | |
238 | - //substitui o controle que mostra as coordenadas | |
239 | - // | |
240 | - var idcoord = i3geoOL.getControlsBy("separator"," "); | |
241 | - //alert(idcoord[0].id) | |
242 | - if(idcoord[0]){ | |
243 | - i3geoOL.events.register("mousemove", i3geoOL, function(e){ | |
244 | - var p,lonlat,d,dc; | |
245 | - if (navm) | |
246 | - {p = new OpenLayers.Pixel(e.x,e.y);} | |
247 | - else | |
248 | - {p = e.xy;} | |
249 | - //altera o indicador de localizacao | |
250 | - lonlat = i3geoOL.getLonLatFromPixel(p); | |
251 | - d = i3GEO.calculo.dd2dms(lonlat.lon,lonlat.lat); | |
252 | - try{ | |
253 | - $i(idcoord[0].id).innerHTML = "Long: "+d[0]+"<br>Lat: "+d[1]; | |
254 | - } | |
255 | - catch(e){ | |
256 | - if(typeof(console) !== 'undefined'){console.error(e);} | |
257 | - } | |
258 | - }); | |
259 | - } | |
260 | - var botoes = <?php echo $botoes; ?>; | |
261 | - i3GEOOLcriaBotoes(botoes); | |
262 | -}; | |
263 | -function i3GEOOLcriaBotoes(botoes){ | |
264 | - var sketchSymbolizers = { | |
265 | - "Point": { | |
266 | - pointRadius: 4, | |
267 | - graphicName: "square", | |
268 | - fillColor: "white", | |
269 | - fillOpacity: 1, | |
270 | - strokeWidth: 1, | |
271 | - strokeOpacity: 1, | |
272 | - strokeColor: "#333333" | |
273 | - }, | |
274 | - "Line": { | |
275 | - strokeWidth: 3, | |
276 | - strokeOpacity: 1, | |
277 | - strokeColor: "#666666", | |
278 | - strokeDashstyle: "dash" | |
279 | - }, | |
280 | - "Polygon": { | |
281 | - strokeWidth: 2, | |
282 | - strokeOpacity: 1, | |
283 | - strokeColor: "#666666", | |
284 | - fillColor: "white", | |
285 | - fillOpacity: 0.3 | |
286 | - } | |
287 | - }; | |
288 | - var style = new OpenLayers.Style(); | |
289 | - style.addRules([ | |
290 | - new OpenLayers.Rule({symbolizer: sketchSymbolizers}) | |
291 | - ]); | |
292 | - var styleMap = new OpenLayers.StyleMap({"default": style}); | |
293 | - | |
294 | - var adiciona = false; | |
295 | - var controles = new Array(); | |
296 | - var panel = new OpenLayers.Control.Panel({ | |
297 | - displayClass: "olControlEditingToolbar noprint" | |
298 | - }); | |
299 | - if(botoes.pan==true){ | |
300 | - controles.push(new OpenLayers.Control.Navigation({title: "Deslocar",displayClass:"pan"})); | |
301 | - var adiciona = true; | |
302 | - } | |
303 | - if(botoes.zoombox==true){ | |
304 | - controles.push(new OpenLayers.Control.ZoomBox({displayClass: "zoombox",title: "Zoom"})); | |
305 | - var adiciona = true; | |
306 | - } | |
307 | - if(botoes.zoomtot==true){ | |
308 | - var button = new OpenLayers.Control.Button({ | |
309 | - displayClass: "zoomtot", | |
310 | - trigger: function(){i3geoOL.zoomToMaxExtent();}, | |
311 | - title: "Ajusta extensão" | |
312 | - }); | |
313 | - controles.push(button); | |
314 | - var adiciona = true; | |
315 | - } | |
316 | - if(botoes.legenda==true){ | |
317 | - var button = new OpenLayers.Control.Button({ | |
318 | - displayClass: "legenda", | |
319 | - trigger: function(){i3GEOOLmostraLegenda();}, | |
320 | - title: "Legenda" | |
321 | - }); | |
322 | - controles.push(button); | |
323 | - var adiciona = true; | |
324 | - } | |
325 | - if(botoes.distancia==true){ | |
326 | - var button = new OpenLayers.Control.Measure( | |
327 | - OpenLayers.Handler.Path, | |
328 | - { | |
329 | - handlerOptions: {layerOptions: {styleMap: styleMap}}, | |
330 | - persist: true, | |
331 | - displayClass: "distancia", | |
332 | - title: "Distância" | |
333 | - } | |
334 | - ); | |
335 | - button.events.on({ | |
336 | - "measure": function(event){ | |
337 | - var units = event.units; | |
338 | - var measure = event.measure; | |
339 | - alert("Distância: " + measure.toFixed(3) + " " + units); | |
340 | - }, | |
341 | - }); | |
342 | - controles.push(button); | |
343 | - var adiciona = true; | |
344 | - } | |
345 | - if(botoes.area==true){ | |
346 | - var button = new OpenLayers.Control.Measure( | |
347 | - OpenLayers.Handler.Polygon, | |
348 | - { | |
349 | - handlerOptions: {layerOptions: {styleMap: styleMap}}, | |
350 | - persist: true, | |
351 | - displayClass: "area", | |
352 | - title: "Área" | |
353 | - } | |
354 | - ); | |
355 | - button.events.on({ | |
356 | - "measure": function(event){ | |
357 | - var units = event.units; | |
358 | - var measure = event.measure; | |
359 | - alert("Área: " + measure.toFixed(3) + " " + units + " quadrados"); | |
360 | - }, | |
361 | - }); | |
362 | - controles.push(button); | |
363 | - var adiciona = true; | |
364 | - } | |
365 | - if(botoes.identifica==true){ | |
366 | - button = new OpenLayers.Control.WMSGetFeatureInfo({ | |
367 | - maxFeatures:1, | |
368 | - infoFormat:'text/plain', //'application/vnd.ogc.gml', | |
369 | - layers: i3GEOOLpegaLayers(), | |
370 | - queryVisible: true, | |
371 | - title: "Identificar", | |
372 | - displayClass: "identifica", | |
373 | - eventListeners: { | |
374 | - getfeatureinfo: function(event) { | |
375 | - var lonlat = i3geoOL.getLonLatFromPixel(event.xy); | |
376 | - var lonlattexto = "<hr><pre><span style=color:blue;cursor:pointer onclick='i3GEOOLcaptura(\""+lonlat.lon+","+lonlat.lat+"\")'>captura</span></pre>"; | |
377 | - i3geoOL.addPopup(new OpenLayers.Popup.FramedCloud( | |
378 | - "chicken", | |
379 | - i3geoOL.getLonLatFromPixel(event.xy), | |
380 | - null, | |
381 | - lonlattexto+"<pre>"+event.text+"</pre>", | |
382 | - null, | |
383 | - true | |
384 | - )); | |
385 | - } | |
386 | - } | |
387 | - }); | |
388 | - //button.events.register("getfeatureinfo", this, showInfo); | |
389 | - controles.push(button); | |
390 | - var adiciona = true; | |
391 | - } | |
392 | - if(botoes.linha==true){ | |
393 | - button = new OpenLayers.Control.DrawFeature( | |
394 | - layergrafico, | |
395 | - OpenLayers.Handler.Path, | |
396 | - { | |
397 | - displayClass: "linha", | |
398 | - title: "digitalizar linha" | |
399 | - } | |
400 | - ); | |
401 | - controles.push(button); | |
402 | - var adiciona = true; | |
403 | - } | |
404 | - if(botoes.ponto==true){ | |
405 | - button = new OpenLayers.Control.DrawFeature( | |
406 | - layergrafico, | |
407 | - OpenLayers.Handler.Point, | |
408 | - { | |
409 | - displayClass: "ponto", | |
410 | - title: "digitalizar ponto" | |
411 | - } | |
412 | - ); | |
413 | - controles.push(button); | |
414 | - var adiciona = true; | |
415 | - } | |
416 | - if(botoes.poligono==true){ | |
417 | - button = new OpenLayers.Control.DrawFeature( | |
418 | - layergrafico, | |
419 | - OpenLayers.Handler.Polygon, | |
420 | - { | |
421 | - displayClass: "poligono", | |
422 | - title: "digitalizar polígono" | |
423 | - } | |
424 | - ); | |
425 | - controles.push(button); | |
426 | - var adiciona = true; | |
427 | - } | |
428 | - if(botoes.edita==true){ | |
429 | - button = new OpenLayers.Control.ModifyFeature( | |
430 | - layergrafico, | |
431 | - { | |
432 | - displayClass: "edita", | |
433 | - title: "edita elemento" | |
434 | - } | |
435 | - ); | |
436 | - controles.push(button); | |
437 | - var adiciona = true; | |
438 | - } | |
439 | - //botao de seleção | |
440 | - if(botoes.apaga==true){ | |
441 | - button = new OpenLayers.Control.SelectFeature( | |
442 | - layergrafico, | |
443 | - { | |
444 | - displayClass: "selecao", | |
445 | - title: "seleciona elemento", | |
446 | - clickout: true, | |
447 | - toggle: true, | |
448 | - multiple: false, | |
449 | - hover: false, | |
450 | - toggleKey: "ctrlKey", // ctrl key removes from selection | |
451 | - multipleKey: "shiftKey", // shift key adds to selection | |
452 | - box: false | |
453 | - } | |
454 | - ); | |
455 | - controles.push(button); | |
456 | - var adiciona = true; | |
457 | - } | |
458 | - if(botoes.apaga==true){ | |
459 | - var button = new OpenLayers.Control.Button({ | |
460 | - displayClass: "apaga", | |
461 | - trigger: function(){ | |
462 | - if(layergrafico.selectedFeatures.length > 0){ | |
463 | - var x = window.confirm("Exclui os elementos selecionados?"); | |
464 | - if(x) | |
465 | - {layergrafico.removeFeatures(layergrafico.selectedFeatures);} | |
466 | - } | |
467 | - else | |
468 | - {alert("Selecione pelo menos um elemento");} | |
469 | - }, | |
470 | - title: "Apaga selecionados" | |
471 | - }); | |
472 | - controles.push(button); | |
473 | - var adiciona = true; | |
474 | - } | |
475 | - if(botoes.captura==true){ | |
476 | - botaoCapturaOL = new OpenLayers.Control.GetFeature({ | |
477 | - protocol: "", | |
478 | - displayClass: "captura", | |
479 | - title: "Captura geometria", | |
480 | - eventListeners: { | |
481 | - featureselected: function(e) { | |
482 | - layergrafico.addFeatures([e.feature]); | |
483 | - } | |
484 | - } | |
485 | - }); | |
486 | - botaoCapturaOL.events.register( | |
487 | - "activate", | |
488 | - this, | |
489 | - function(e){ | |
490 | - var layers = i3GEOOLpegaLayers(); | |
491 | - var u = layers[0].url+"&request=getfeature&service=wfs"; | |
492 | - u += "&typename="+layers[0].params.LAYERS; | |
493 | - u += "&filter=<Filter><Intersect><PropertyName>Geometry</PropertyName><gml:Point><gml:coordinates>-54,-12</gml:coordinates></gml:Point></Intersect></Filter>"; | |
494 | - botaoCapturaOL.protocol = OpenLayers.Protocol.WFS({ | |
495 | - url:u | |
496 | - }); | |
497 | - } | |
498 | - ); | |
499 | - controles.push(botaoCapturaOL); | |
500 | - var adiciona = true; | |
501 | - } | |
502 | - // | |
503 | - //adiciona o painel ao mapa se alguma op��o foi inserida | |
504 | - // | |
505 | - if(adiciona == true){ | |
506 | - panel.addControls(controles); | |
507 | - i3geoOL.addControl(panel); | |
508 | - } | |
509 | -} | |
510 | -function i3GEOOLmostraLegenda(){ | |
511 | - var layers = pegaLayers() | |
512 | - var nlayers = layers.length; | |
513 | - var ins = ""; | |
514 | - for(i=0;i<nlayers;i++){ | |
515 | - var url = layers[i].getFullRequestString({"request":"getlegendgraphic"}); | |
516 | - url = url.replace("LAYERS","LAYER"); | |
517 | - ins += "<img src='"+url+"' /><br>"; | |
518 | - } | |
519 | - var w = window.open() | |
520 | - w.document.write(ins) | |
521 | - w.document.close(); | |
522 | - | |
523 | -} | |
524 | -function i3GEOOLpegaLayers(){ | |
525 | - var layers = i3geoOL.layers; | |
526 | - var nlayers = layers.length; | |
527 | - var ins = new Array(); | |
528 | - for(i=0;i<nlayers;i++){ | |
529 | - if(layers[i].visibility && (layers[i].isBaseLayer == false)){ | |
530 | - ins.push(layers[i]); | |
531 | - } | |
532 | - } | |
533 | - return ins; | |
534 | -} | |
535 | -function i3GEOOLcaptura(lonlat){ | |
536 | - var layers = i3GEOOLpegaLayers(); | |
537 | - var u = layers[0].url+"&request=getfeature&service=wfs&version=1.0.0"; | |
538 | - u += "&OUTPUTFORMAT=gml2&typename="+layers[0].params.LAYERS; | |
539 | - u += "&filter=<Filter><Intersect><PropertyName>Geometry</PropertyName><gml:Point><gml:coordinates>"+lonlat+"</gml:coordinates></gml:Point></Intersect></Filter>"; | |
540 | - document.body.style.cursor="wait"; | |
541 | - document.getElementById("i3geoMapa").style.cursor = "wait"; | |
542 | - OpenLayers.Request.issue({ | |
543 | - method: "GET", | |
544 | - url: u, | |
545 | - callback: function(retorno){ | |
546 | - document.body.style.cursor="default"; | |
547 | - document.getElementById("i3geoMapa").style.cursor = "default"; | |
548 | - var fromgml = new OpenLayers.Format.GML({ | |
549 | - geometryName: "msGeometry" | |
550 | - }); | |
551 | - var gml = fromgml.read(retorno.responseText); | |
552 | - layergrafico.addFeatures(gml); | |
553 | - }, | |
554 | - failure: function(){ | |
555 | - document.body.style.cursor="default"; | |
556 | - document.getElementById("i3geoMapa").style.cursor = "default"; | |
557 | - alert("Erro"); | |
558 | - } | |
559 | - }) | |
560 | -} | |
561 | -i3GeoMapaInicia(); | |
220 | +<?php include("openlayers.js.php"); ?> | |
221 | +i3GEOOL.inicia() | |
562 | 222 | </script> |
563 | 223 | </body> |
564 | -</html> | |
224 | +</html> | |
565 | 225 | \ No newline at end of file | ... | ... |
mashups/openlayers.png
menutemas/admin.db
No preview for this file type