[Spanish] Re: Problema con popup en capa MapServer

florencia.bujan florita026 at gmail.com
Fri Apr 8 07:35:09 EDT 2011


Buenos días,

Te cuento lo que yo hice para que me funcione.
Es una capa de polígonos llamada "Departamentos" que al hacer click sobre un
polígono se muestran datos de la base de datos de dicha tabla.
Te paso el código de cada parte. El contenido del popup lo debes hacer en un
archivo aparte html que en mi caso se encuentra en la carpeta "popups" en el
archivo "departamentos.html".

*ARCHIVO .MAP*
# Capa de Departamentos
LAYER
CONNECTIONTYPE postgis
NAME "Departamentos"
 STATUS on
LABELITEM "nombre"
LABELMAXSCALE 2000000
PROCESSING "LABEL_NO_CLIP=ON"
PROCESSING "CLOSE_CONNECTION=DEFER"
 CONNECTION "user=xx password=xx dbname=xx host=xx"
DATA "the_geom FROM departamentos as departamentos USING UNIQUE GID USING
SRID=-1"
DUMP True
TYPE POLYGON
      METADATA
        "wms_title"     "Departamentos"
        "wms_srs"             "EPSG:4326"
        "wms_name"             "Departamentos"
        "wms_server_version"   "1.1.1"
        "wms_format"           "image/png"
        "wms_include_items" "all"
    END
    TEMPLATE "popups/departamentos.html"
 CLASS
STYLE
COLOR 0 99 0
OUTLINECOLOR 0 0 0
END
END
END

*ARCHIVO Departamentos.html (popup): En este archivo ponés entre paréntesis
rectos los nombres de las columnas de tu tabla en la base de datos*
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "
http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
<table border=1 cellspacing=0 cellpadding=2 align=center width=80%>
<tr>
<td>
<font size=1><b>Nombre: </b></font>
</td>
<td>
<font size=1>[nombre]</font>
</td>
</tr>
<tr>
<td>
<font size=1><b>Cabecera: </b></font>
</td>
<td>
<font size=1>[cabecera]</font>
</td>
</tr>
</table>
</body>
</html>

*Archivo OpenLayers:*
var layerRegional = new OpenLayers.Layer.WMS('Departamentos',
'http://localhost/cgi-bin/mapserv.exe?map=../htdocs/GISManager/mapa.map",
                {layers:'Departamentos',  format: 'image/png',
transparent:true, gutter: 15},
                {opacity:0.6, displayInLayerSwitcher: false }
        );
map.addLayer(layerRegional);
info = new OpenLayers.Control.WMSGetFeatureInfo({
            url: '
http://localhost/cgi-bin/mapserv.exe?map=../htdocs/GISManager/mapa.map",
            title: 'Click',
            layers: [layerRegional],
            queryVisible: true,
            eventListeners: {
                getfeatureinfo: function(event) {
                    map.addPopup(new OpenLayers.Popup.FramedCloud(
                        "chicken",
                        map.getLonLatFromPixel(event.xy),
                        null,
                        event.text,
                        null,
                        true
                    ));
                }
            }
        });
map.addControl(info);
info.activate();


Eso sería todo.
Cualquier consulta que tengas no dudes en preguntarme.

Saludos!
Florencia

El 7 de abril de 2011 16:53, webmapping [via OSGeo.org] <
ml-node+6251341-1926894468-295788 at n2.nabble.com> escribió:

> Hola
>
> Estoy realizando tus mismos pasos con el popup de openlayers, para mi
> visor, pero al momento de dar click en un punto me arroja es el contenido
> del archivo proxy.cgi, quisiera saber si algo anda mal, o serán problemas de
> configuración, cualquier ayuda, opinión se los agradeceré....
>
> De antemano muchas gracias
>
> ------------------------------
>  If you reply to this email, your message will be added to the discussion
> below:
>
> http://osgeo-org.1803224.n2.nabble.com/Problema-con-popup-en-capa-MapServer-tp5655608p6251341.html
>  To unsubscribe from Problema con popup en capa MapServer, click here<http://osgeo-org.1803224.n2.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=5655608&code=Zmxvcml0YTAyNkBnbWFpbC5jb218NTY1NTYwOHwtMTA5MjA5NTEwMA==>.
>
>


--
View this message in context: http://osgeo-org.1803224.n2.nabble.com/Problema-con-popup-en-capa-MapServer-tp5655608p6253342.html
Sent from the OSGeo Spanish Local Chapter mailing list archive at Nabble.com.


More information about the Spanish mailing list