Commit b2aa5fc9036305a3611fc074dec084d43495410e
1 parent
ae57caca
Exists in
master
and in
7 other branches
Inclusão do parâmetro KML no mashup Openlayers
Showing
3 changed files
with
60 additions
and
4 deletions
Show diff stats
mashups/index.html
| @@ -27,8 +27,10 @@ conter um grande número de funcionalidades.</p> | @@ -27,8 +27,10 @@ conter um grande número de funcionalidades.</p> | ||
| 27 | <p>Para ver todos os parâmetros: <a href='openlayers.php'>i3geo/mashups/openlayers.php</a></p> | 27 | <p>Para ver todos os parâmetros: <a href='openlayers.php'>i3geo/mashups/openlayers.php</a></p> |
| 28 | <p>Exemplo: todas as opções e um tema adicionado <a href='openlayers.php?temas=biomashp&largura=600'>openlayers.php?temas=biomashp&largura=600</a></p> | 28 | <p>Exemplo: todas as opções e um tema adicionado <a href='openlayers.php?temas=biomashp&largura=600'>openlayers.php?temas=biomashp&largura=600</a></p> |
| 29 | <p>Exemplo: Botões principais e barra de zoom maior <a href='openlayers.php?temas=biomashp&largura=600&botoes=pan,zoombox,zoomtot,distancia,area,identifica&numzoomlevels=10'>openlayers.php?temas=biomashp&largura=600&botoes=pan,zoombox,zoomtot,distancia,area,identifica&numzoomlevels=10</a> | 29 | <p>Exemplo: Botões principais e barra de zoom maior <a href='openlayers.php?temas=biomashp&largura=600&botoes=pan,zoombox,zoomtot,distancia,area,identifica&numzoomlevels=10'>openlayers.php?temas=biomashp&largura=600&botoes=pan,zoombox,zoomtot,distancia,area,identifica&numzoomlevels=10</a> |
| 30 | -<p>Exemplo: Inclusão de pontos <a href='openlayers.php?temas=biomashp&largura=600&pontos=-54 -12 -56 -15'>openlayers.php?temas=biomashp&largura=600&pontos=-54 -12 -56 -15 | ||
| 31 | -<p>Exemplo: Camada adicional como fundo <a href='openlayers.php?temas=biomashp&largura=600&fundo=biomashp'>openlayers.php?temas=biomashp&largura=600&fundo=biomashp | 30 | +<p>Exemplo: Inclusão de pontos <a href='openlayers.php?temas=biomashp&largura=600&pontos=-54 -12 -56 -15'>openlayers.php?temas=biomashp&largura=600&pontos=-54 -12 -56 -15</a> |
| 31 | +<p>Exemplo: Camada adicional como fundo <a href='openlayers.php?temas=biomashp&largura=600&fundo=biomashp'>openlayers.php?temas=biomashp&largura=600&fundo=biomashp</a> | ||
| 32 | +<p>Exemplo: KML <a href='openlayers.php?temas=biomashp&largura=700&kml=http://localhost/i3geo/aplicmap/dados/sundials.kml'>openlayers.php?temas=biomashp&largura=700&kml=http://localhost/i3geo/aplicmap/dados/sundials.kml</a> | ||
| 33 | + | ||
| 32 | 34 | ||
| 33 | </body> | 35 | </body> |
| 34 | <script> | 36 | <script> |
mashups/openlayers.js.php
| @@ -50,7 +50,7 @@ i3GEO.editorOL = { | @@ -50,7 +50,7 @@ i3GEO.editorOL = { | ||
| 50 | {layers: "estadosl",FORMAT:'image/png'} | 50 | {layers: "estadosl",FORMAT:'image/png'} |
| 51 | ), | 51 | ), |
| 52 | fundo: "ol_mma,ol_wms,jpl_wms,osm_wms,top_wms,est_wms", | 52 | fundo: "ol_mma,ol_wms,jpl_wms,osm_wms,top_wms,est_wms", |
| 53 | - | 53 | + kml: [], |
| 54 | layersIniciais: [], | 54 | layersIniciais: [], |
| 55 | botoes: { | 55 | botoes: { |
| 56 | 'pan':true, | 56 | 'pan':true, |
| @@ -170,6 +170,7 @@ i3GEO.editorOL = { | @@ -170,6 +170,7 @@ i3GEO.editorOL = { | ||
| 170 | if(i3GEO.editorOL.layergrafico !== ""){ | 170 | if(i3GEO.editorOL.layergrafico !== ""){ |
| 171 | i3GEO.editorOL.mapa.addLayers([i3GEO.editorOL.layergrafico]); | 171 | i3GEO.editorOL.mapa.addLayers([i3GEO.editorOL.layergrafico]); |
| 172 | } | 172 | } |
| 173 | + i3GEO.editorOL.adicionaKml(); | ||
| 173 | i3GEO.editorOL.adicionaMarcas(); | 174 | i3GEO.editorOL.adicionaMarcas(); |
| 174 | if(i3GEO.editorOL.maxext !== "") | 175 | if(i3GEO.editorOL.maxext !== "") |
| 175 | {i3GEO.editorOL.mapa.zoomToMaxExtent();} | 176 | {i3GEO.editorOL.mapa.zoomToMaxExtent();} |
| @@ -980,6 +981,51 @@ i3GEO.editorOL = { | @@ -980,6 +981,51 @@ i3GEO.editorOL = { | ||
| 980 | layer.addFeatures(features); | 981 | layer.addFeatures(features); |
| 981 | i3GEO.editorOL.mapa.addLayer(layer); | 982 | i3GEO.editorOL.mapa.addLayer(layer); |
| 982 | }, | 983 | }, |
| 984 | + adicionaKml: function(){ | ||
| 985 | + var temp,n,i,id,url; | ||
| 986 | + n = i3GEO.editorOL.kml.length; | ||
| 987 | + for(i=0;i<n;i++){ | ||
| 988 | + id = "kml"+i; | ||
| 989 | + url = i3GEO.editorOL.kml[i]; | ||
| 990 | + eval(id+" = new OpenLayers.Layer.Vector('"+id+"', {displayOutsideMaxExtent:true,displayInLayerSwitcher:false,visibility:true, strategies: [new OpenLayers.Strategy.Fixed()],protocol: new OpenLayers.Protocol.HTTP({url: '"+url+"',format: new OpenLayers.Format.KML({extractStyles: true,extractAttributes: true,maxDepth: 5})})})"); | ||
| 991 | + eval("i3GEO.editorOL.mapa.addLayer("+id+");"); | ||
| 992 | + eval("temp = "+id+".div;"); | ||
| 993 | + temp.onclick = function(e){ | ||
| 994 | + var targ,id,temp,features,n,i,j,g,html=""; | ||
| 995 | + if (!e){e = window.event;} | ||
| 996 | + if (e.target) | ||
| 997 | + {targ = e.target;} | ||
| 998 | + else | ||
| 999 | + if (e.srcElement) | ||
| 1000 | + {targ = e.srcElement;} | ||
| 1001 | + | ||
| 1002 | + temp = targ.id.split("_"); | ||
| 1003 | + if(temp[0] === "OpenLayers.Geometry.Point"){ | ||
| 1004 | + id = targ.id; | ||
| 1005 | + temp = i3GEO.editorOL.mapa.getLayer(this.id); | ||
| 1006 | + features = temp.features; | ||
| 1007 | + n = features.length; | ||
| 1008 | + for(i=0;i<n;i++){ | ||
| 1009 | + if(features[i].geometry.id === id){ | ||
| 1010 | + for (j in features[i].attributes) { | ||
| 1011 | + html += j+": "+features[i].attributes[j]; | ||
| 1012 | + } | ||
| 1013 | + g = features[i].geometry; | ||
| 1014 | + i3GEO.editorOL.mapa.addPopup(new OpenLayers.Popup.FramedCloud( | ||
| 1015 | + "kml", | ||
| 1016 | + new OpenLayers.LonLat(g.x,g.y), | ||
| 1017 | + null, | ||
| 1018 | + html, | ||
| 1019 | + null, | ||
| 1020 | + true | ||
| 1021 | + )); | ||
| 1022 | + | ||
| 1023 | + } | ||
| 1024 | + } | ||
| 1025 | + } | ||
| 1026 | + }; | ||
| 1027 | + } | ||
| 1028 | + }, | ||
| 983 | //obtido de openlayers.org | 1029 | //obtido de openlayers.org |
| 984 | propriedades: function(){ | 1030 | propriedades: function(){ |
| 985 | if(!document.getElementById("panelpropriedadesEditor")){ | 1031 | if(!document.getElementById("panelpropriedadesEditor")){ |
mashups/openlayers.php
| @@ -140,7 +140,8 @@ function ajuda(){ | @@ -140,7 +140,8 @@ function ajuda(){ | ||
| 140 | <pre><b> | 140 | <pre><b> |
| 141 | Mashup OpenLayers | 141 | Mashup OpenLayers |
| 142 | Parâmetros: | 142 | Parâmetros: |
| 143 | - servidor - endereco do servidor OGC utilizado. Por default é ../ogc.php o que força o uso do i3geo local | 143 | + kml - lista de endereços (url) de um arquivos kml que serão adicionados ao mapa. Separado por ',' |
| 144 | + servidor - por default é ../ogc.php o que força o uso do i3geo local. Esse é o programa que será utilizado em conjunto com a lista definida no parâmetro 'temas' | ||
| 144 | temas - lista com os temas (mapfiles) do i3Geo que serão incluídos no mapa | 145 | temas - lista com os temas (mapfiles) do i3Geo que serão incluídos no mapa |
| 145 | numzoomlevels - número de níveis de zoom, default=6 | 146 | numzoomlevels - número de níveis de zoom, default=6 |
| 146 | maxextent - extensão geográfica do mapa (xmin,ymin,xmax,ymax) | 147 | maxextent - extensão geográfica do mapa (xmin,ymin,xmax,ymax) |
| @@ -252,6 +253,13 @@ i3GEO.editorOL.pontos = [<?php | @@ -252,6 +253,13 @@ i3GEO.editorOL.pontos = [<?php | ||
| 252 | echo $pontos; | 253 | echo $pontos; |
| 253 | } | 254 | } |
| 254 | ?>]; | 255 | ?>]; |
| 256 | +i3GEO.editorOL.kml = [<?php | ||
| 257 | + if(isset($kml)){ | ||
| 258 | + $kml = str_replace(" ",",",$kml); | ||
| 259 | + $kml = explode(",",$kml); | ||
| 260 | + echo "'".implode("','",$kml)."'"; | ||
| 261 | + } | ||
| 262 | +?>]; | ||
| 255 | i3GEO.editorOL.marca = "<?php | 263 | i3GEO.editorOL.marca = "<?php |
| 256 | if(isset($marca)){echo $marca;} | 264 | if(isset($marca)){echo $marca;} |
| 257 | else | 265 | else |