Commit 489ce01ea1ad6ae7c3aade3a3730e4bc6758640c
1 parent
9848fbfb
Exists in
master
and in
7 other branches
Inclusão de parâmetro no mahup do OpenLayers para permitir a inclusão de pontos
Showing
4 changed files
with
64 additions
and
1 deletions
Show diff stats
mashups/index.html
| ... | ... | @@ -27,6 +27,7 @@ conter um grande número de funcionalidades.</p> |
| 27 | 27 | <p>Para ver todos os parâmetros: <a href='openlayers.php'>i3geo/mashups/openlayers.php</a></p> |
| 28 | 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 | 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 | |
| 30 | 31 | </body> |
| 31 | 32 | <script> |
| 32 | 33 | /* | ... | ... |
mashups/openlayers.js.php
| ... | ... | @@ -33,6 +33,17 @@ i3GEOOL = { |
| 33 | 33 | {echo "''";} |
| 34 | 34 | ?>], |
| 35 | 35 | botoes: <?php echo $botoes; ?>, |
| 36 | + pontos: [<?php | |
| 37 | + if(isset($pontos)){ | |
| 38 | + $pontos = str_replace(" ",",",$pontos); | |
| 39 | + echo $pontos; | |
| 40 | + } | |
| 41 | + ?>], | |
| 42 | + marca: "<?php | |
| 43 | + if(isset($marca)){echo $marca;} | |
| 44 | + else | |
| 45 | + {echo "../pacotes/openlayers/img/marker-gold.png";} | |
| 46 | + ?>", | |
| 36 | 47 | mapa: new OpenLayers.Map('i3geoMapa', { |
| 37 | 48 | controls: [ |
| 38 | 49 | <?php echo implode(",",$objControles); ?> |
| ... | ... | @@ -66,12 +77,13 @@ i3GEOOL = { |
| 66 | 77 | if(i3GEOOL.layergrafico != ""){ |
| 67 | 78 | i3GEOOL.mapa.addLayers([i3GEOOL.layergrafico]); |
| 68 | 79 | } |
| 69 | - | |
| 80 | + i3GEOOL.adicionaMarcas(); | |
| 70 | 81 | i3GEOOL.mapa.zoomToMaxExtent(); |
| 71 | 82 | i3GEOOL.coordenadas(); |
| 72 | 83 | i3GEOOL.criaJanelaBusca(); |
| 73 | 84 | i3GEOOL.criaJanelaAtivaTema(); |
| 74 | 85 | i3GEOOL.criaBotoes(i3GEOOL.botoes); |
| 86 | + | |
| 75 | 87 | }, |
| 76 | 88 | layersLigados: function(){ |
| 77 | 89 | var layers = i3GEOOL.mapa.layers; |
| ... | ... | @@ -581,5 +593,49 @@ i3GEOOL = { |
| 581 | 593 | panel.addControls(controles); |
| 582 | 594 | i3GEOOL.mapa.addControl(panel); |
| 583 | 595 | } |
| 596 | + }, | |
| 597 | + adicionaMarcas: function(){ | |
| 598 | + if(i3GEOOL.pontos.length == 0) | |
| 599 | + {return;} | |
| 600 | + var SHADOW_Z_INDEX = 10, | |
| 601 | + MARKER_Z_INDEX = 11, | |
| 602 | + DIAMETER = 200, | |
| 603 | + layer = new OpenLayers.Layer.Vector( | |
| 604 | + "pontos", | |
| 605 | + { | |
| 606 | + styleMap: new OpenLayers.StyleMap({ | |
| 607 | + externalGraphic: i3GEOOL.marca, | |
| 608 | + backgroundGraphic: "../pacotes/openlayers/img/marker_shadow.png", | |
| 609 | + backgroundXOffset: 0, | |
| 610 | + backgroundYOffset: -7, | |
| 611 | + graphicZIndex: MARKER_Z_INDEX, | |
| 612 | + backgroundGraphicZIndex: SHADOW_Z_INDEX, | |
| 613 | + pointRadius: 10 | |
| 614 | + }), | |
| 615 | + isBaseLayer: false, | |
| 616 | + rendererOptions: {yOrdering: true}, | |
| 617 | + displayInLayerSwitcher:true, | |
| 618 | + visibility:true | |
| 619 | + } | |
| 620 | + ), | |
| 621 | + index, | |
| 622 | + x = [], | |
| 623 | + y = [], | |
| 624 | + pixel, | |
| 625 | + lonlat, | |
| 626 | + features = []; | |
| 627 | + for (index = 0; index < i3GEOOL.pontos.length; index = index + 2){ | |
| 628 | + x.push(i3GEOOL.pontos[index]); | |
| 629 | + y.push(i3GEOOL.pontos[index+1]); | |
| 630 | + }; | |
| 631 | + for (index = 0; index < x.length; index++) { | |
| 632 | + features.push( | |
| 633 | + new OpenLayers.Feature.Vector( | |
| 634 | + new OpenLayers.Geometry.Point(x[index], y[index]) | |
| 635 | + ) | |
| 636 | + ); | |
| 637 | + } | |
| 638 | + layer.addFeatures(features); | |
| 639 | + i3GEOOL.mapa.addLayer(layer); | |
| 584 | 640 | } |
| 585 | 641 | }; | ... | ... |
mashups/openlayers.php
| ... | ... | @@ -18,6 +18,10 @@ servidor - endereco do servidor OGC utilizado. Por default é "../ogc.php" o que |
| 18 | 18 | largura - lagura do mapa em pixels |
| 19 | 19 | |
| 20 | 20 | altura - altura do mapa em pixels |
| 21 | + | |
| 22 | +pontos - lista de coordenadas x e y que serão incluídas como marcas no mapa | |
| 23 | + | |
| 24 | +marca - nome do arquivo que contém a imagem que será utilizada para mostrar as coordenadas | |
| 21 | 25 | */ |
| 22 | 26 | include_once("../classesphp/pega_variaveis.php"); |
| 23 | 27 | include_once("../classesphp/carrega_ext.php"); |
| ... | ... | @@ -172,6 +176,8 @@ Parâmetros: |
| 172 | 176 | maxextent - extensão geográfica do mapa (xmin,ymin,xmax,ymax) |
| 173 | 177 | largura - lagura do mapa em pixels |
| 174 | 178 | altura - altura do mapa em pixels |
| 179 | + pontos - lista de coordenadas x e y que serão incluídas como marcas no mapa | |
| 180 | + marca - nome do arquivo que contém a imagem que será utilizada para mostrar as coordenadas | |
| 175 | 181 | |
| 176 | 182 | controles - lista com os nomes dos controles que serão adicionados ao mapa. Se não for definido, todos os controles serão adicionados |
| 177 | 183 | navigation | ... | ... |
374 Bytes