1

I'm with geoserver on my local machine running on port 8080 on jetty which is standard in windows installer. I want to use my GetFeatureInfo WMS layers, but I have the following questions:

I need to configure proxyHost even being on my local machine?

Can I use ProxyHosto GeoServer running with Jetty as the default installation for WindosEstou with geoserver on my local machine running on port 8080 on jetty which is standard in windows installer. I want to use my GetFeatureInfo WMS layers, but I have the following questions:

I need to configure proxyHost even being on my local machine?

Can I use ProxyHosto with GeoServer running on Jetty as is standard for Windows installation or do I have to install it in Tomcat?

This is my code, when I click is carrying too much time and nothing appears:

** EDITED CODE **

<!DOCTYPE html>
<html lang='en'>
<head>
 <meta charset='utf-8' />
 <title>My OpenLayers Map</title>
 <script type='text/javascript' src='OpenLayers.js'></script>
 <script type='text/javascript'>

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

 var map;

 function init() { 

    var bounds = new OpenLayers.Bounds(
                -51.280762, -30.241074,
                -51.020828, -29.969619
            );
            var options = {
    controls :[new OpenLayers.Control.Navigation(),
            new OpenLayers.Control.PanZoom()],
                maxExtent: bounds,
                maxResolution: 0.00106037109375,
                projection: "EPSG:4326",
                units: 'degrees'
            };
    map = new OpenLayers.Map('map_element', options);    

var wms = new OpenLayers.Layer.WMS(
            "Paradas de ônibus",
            "http://localhost:8080/geoserver/wms?",
            {
               layers: 'Teste:Stops',                                
               isBaseLayer: false,
               styles : '', 
               format :"image/jpeg"
            }            
        );

    map.addLayers([wms]);

    //GetFeatureInfo Simples
    info = new OpenLayers.Control.WMSGetFeatureInfo({
        url: 'http://localhost:8080/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();

    var point = new OpenLayers.LonLat(-51.22,-30.08); 
    point.transform(new OpenLayers.Projection("EPSG:4326"), 
    map.getProjectionObject()); 
    map.setCenter(point, 3); 

    map.addControl(new OpenLayers.Control.LayerSwitcher({}));

 if(!map.getCenter()){
    map.zoomToMaxExtent();
 }
}

 </script>

</script>
</head>

<body onload='init();'> <!-- Chama a função js init() --> 

<!--Elemento HTML onde o mapa é exibido -->
 <div id='map_element' style='width: 800px; height: 800px;'>
 </div>

</body>
</html>

2 Answers 2

1

If you want to avoid cross origin issue and dont't want use proxy then you have to open your web application from the same host and port as your wfs server. If your wfs server listens 8080 port on localhost that means URL of your web app should be http://localhost:8080/index.html for example (not file:///...). In your case you shoud publish your static files using the same Web server (Jetty).

0

If your WMS and WFS are on the same server and the same server port then you will not need to set up a proxy.

If you're just using a local WMS then you don't need a proxy, and your issue lies elsewhere.

Have you tested that you can get a Map and FeatureInfo outside of OpenLayers?

Do the bounds that you request in your code match the bounds you get when you do a GetCapabilities request like:

http://localhost:8080/geoserver/wms?Service=WFS&request=GetCapabilities&

I see your default bounds are listed in degrees but your default projection is Spherical Mercator which uses metres, could this also be an issue?

4
  • Okay, I get it. Can you help me understand what's wrong in my code? Not the error is only Loading (loop)
    – csf
    Commented Apr 2, 2014 at 20:06
  • nmtoken Even putting the www geoserver does not work the GetFeatureInfo
    – csf
    Commented Apr 4, 2014 at 11:57
  • I wrote about WFS, but actually reading your question you seem to be talking just about WMS. Have you tested that your service is working correctly outside of OpenLayers.
    – nmtoken
    Commented Apr 4, 2014 at 12:14
  • I edited my code in question. Really was using projection in meters and coordinates in degrees. Now put my layer in geoserver in 4326 and fix the code. Performed within the www geoserver, and the same thing happened was in the loop. My scenario is: 1 - My pages are inside the www folder of geoserver running on port 8080 2 - Inside the www folder of geoserver openlayers put files: OpenLayers.js and folders metadata, img, theme without it the openlayers does not work
    – csf
    Commented Apr 4, 2014 at 13:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.