[OpenLayers-Users] get feature popup

truongxuan quang truongxuanquang at yahoo.com
Fri Mar 18 13:23:30 EDT 2011


Hello list


 I am trying to do similar 
to http://www.openlayers.org/dev/examples/getfeatureinfo-popup.html example, but 
I could not done yet because feature did not view probably. I am using Openlayer 
and Geoext running  in mapfish enviroment (but without any mapfish commends and 
library only run as env of mapfish).
I put my example on http://131.175.143.99/form.html and when I click on the map, 
responses an errors as

!/usr/bin/env python   """This is a blind proxy that we use to get around 
browser restrictions that prevent the Javascript from loading pages not on the 
same server as the Javascript.  This has several problems: it's less efficient, 
it might break some sites, and it's a security risk because people can use this 
proxy to browse the web and possibly do bad stuff with it.  It only loads pages 
via http and https, but it can load any content type. It supports GET and POST 
requests."""  import urllib2 import cgi import sys, os  # Designed to prevent 
Open Proxy type stuff.  allowedHosts = ['131.175.143.99', 'localhost:8081']  
method = os.environ["REQUEST_METHOD"]  if method == "POST":     qs = 
os.environ["QUERY_STRING"]     d = cgi.parse_qs(qs)     if d.has_key("url"):         
url = d["url"][0]     else:         url = "http://131.175.143.99" else:     fs = 
cgi.FieldStorage()     url = fs.getvalue('url', "http://131.175.143.99")  try:     
host = url.split("/")[2]     if allowedHosts and not host in allowedHosts:         
print "Status: 502 Bad Gateway"         print "Content-Type: text/plain"         
print         print "This proxy does not allow you to access that location 
(%s)." % (host,)         print         print os.environ        elif 
url.startswith("http://") or url.startswith("https://"):              if method 
== "POST":             length = int(os.environ["CONTENT_LENGTH"])             
headers = {"Content-Type": os.environ["CONTENT_TYPE"]}             body = 
sys.stdin.read(length)             r = urllib2.Request(url, body, headers)             
y = urllib2.urlopen(r)         else:             y = urllib2.urlopen(url)                  
# print content type header         i = y.info()         if 
i.has_key("Content-Type"):             print "Content-Type: %s" % 
(i["Content-Type"])         else:             print "Content-Type: text/plain"         
print                  print y.read()                  y.close()     else:         
print "Content-Type: text/plain"         print         print "Illegal request."  
except Exception, E:     print "Status: 500 Unexpected Error"     print 
"Content-Type: text/plain"     print      print "Some unexpected error occurred. 
Error text was:", E




my main script code in   js file  as bellow

OpenLayers.ProxyHost = "proxy.cgi?url=";



Ext.onReady(function() {
var bounds = new OpenLayers.Bounds(
                    100, 20,
                    110, 25 );
mapOptions = {
maxExtent: bounds, 
maxResolution: 'auto',
projection: "EPSG:4326",
numZoomLevels: 35 ,
units: "m",
allOverlays: false 
};
    var map = new OpenLayers.Map('map',mapOptions);
var basin = new OpenLayers.Layer.WMS(
"VN", "http://131.175.143.99:8081/geoserver/wms",
{
layers: 'topp:basin',

transparent: true,
format: "image/gif",
},
{isBaseLayer: false} 
);

map.addLayer(basin);

info = new OpenLayers.Control.WMSGetFeatureInfo({
            url: 'http://131.175.143.99:8081/geoserver/wms', 
            title: 'Identify features by clicking',
             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();
...........
.........
........
mainPanel = new GeoExt.form.FormPanel({
        renderTo: "mainpanel",
        layout: "border",
        height: 400,
        width: 920, 
        items: mapPanel
     });
if I change 

Could you please give me advice in this case.

Many thanks 

Quang


      
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20110318/276247d1/attachment.html


More information about the Users mailing list