Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I am new to OpenLayers and I want to add OpenLayers.Control.WMSGetFeatureInfo to get feature
info to website.But i can't figure out right method.

I also see the source code of GeoServer OpenLayers page and still I can't find the syntax of OpenLayers.Control.WMSGetFeatureInfo code?

I use geoserver,apache-tomcat-6.0.35 and open layer 2.10.Should i use proxy to call OpenLayers.Control.WMSGetFeatureInfo?

This is my GeoServer WMS URL:

http://localhost:8080/geoserver/sac/wms?
service=WMS&
version=1.1.0&
request=GetMap&
layers=sac:contour&
styles=&
bbox=187754.5,204980.703125,192031.40625,210022.890625&
width=434&height=512&s
rs=EPSG:5235&
format=application/openlayers

Pls give me sample code which calling OpenLayers.Control.WMSGetFeatureInfo? Thank you.

share|improve this question
1  
What do you mean when you say you see the source code but you can't find the code? Please don't just ask for "code", be very specific in what you are looking for. –  blah238 Apr 26 '12 at 2:53

1 Answer 1

up vote 4 down vote accepted

you can check this example on openlayers.

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

    var map;

    function load() {
        map = new OpenLayers.Map('map', {
            maxExtent: new OpenLayers.Bounds(143.834,-43.648,148.479,-39.573)
        });

        var political = new OpenLayers.Layer.WMS("State Boundaries",
            "http://demo.opengeo.org/geoserver/wms", 
            {'layers': 'topp:tasmania_state_boundaries', 
transparent: true, format: 'image/gif'},
            {isBaseLayer: true}
        );
        };

        map.addLayer(political); 

if it didnt help you, you can read Open Layer with GeoSever example.

EDIT:

for wms get info function you have to add this code to which i have gave before:

info = new OpenLayers.Control.WMSGetFeatureInfo({
            url: 'http://demo.opengeo.org/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();

i hope it helps you...

share|improve this answer
    
I look your links and those are really helpful.I change the question –  sacprasanna Apr 26 '12 at 11:44
    
@sacprasanna if the first post work for you, pls set it accepted and then ask another question for another people who want to profit by this answer...and for your new question i have updated my answer.. –  Aragon Apr 26 '12 at 12:10
    
Ok,Yes it is the good way –  sacprasanna Apr 26 '12 at 14:03
    
Good one. But this gives muliple feature info. How to close previous popup and reload new one on next click. –  Pari Feb 19 '13 at 11:40

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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