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.

This code set works for me in IE but not in Firefox and chrome.What is the problem? Map is showing in all browsers ,but when i click on point of map nothing showing in Firefox and chrome.

Welcome any idea!

<!DOCTYPE html>
<html lang='en'>
<head>
<title>My OpenLayers Map</title>
 <script type='text/javascript' src='OpenLayers.js'></script>
 <link rel="stylesheet" href="1.css" type="text/css">
 <link rel="stylesheet" href="2.css" type="text/css">
 <script type='text/javascript'>
 var map;
 function init() {
 map = new OpenLayers.Map('map_element', {
 projection: 'EPSG:5235',
 maxExtent: new OpenLayers.Bounds(105097.88755998248, 181965.81596899,
 107146.57905998248, 183739.10926899),
 maxResolution: 156543.0339,
 units: 'm'
 })

var wms1 = new OpenLayers.Layer.WMS('OpenLayers      WMS','http://localhost:8080/geoserver/sac/wms',{layers: 'sac:Luse'},{});
var highlight = new OpenLayers.Layer.Vector("Highlighted Features", {displayInLayerSwitcher: false, isBaseLayer: false });

    map.addLayers([wms1,highlight]); 

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

    map.addControl(new OpenLayers.Control.LayerSwitcher());
  if(!map.getCenter()){
  map.zoomToMaxExtent();
  }
  }

  </script>
 </head>
 <body onload="init()">
  <h1 id="title">Feature Info in Popup</h1>

  <div id="tags">
    WMS, GetFeatureInfo, popup
  </div>

  <p id="shortdesc">
    Demonstrates the WMSGetFeatureInfo control for fetching information
    about a position from WMS (via GetFeatureInfo request).  Results
    are displayed in a popup.
  </p>

  <div id="map_element" class="smallmap"></div>

  <div id="docs"></div>
  </body>
  </html>
share|improve this question
    
    
Thanks for your comment.But this is not proxy problem. Reasons were commented below. –  sacprasanna May 2 '12 at 9:00
add comment

3 Answers

up vote 0 down vote accepted

I have the same problem, and i removed from OpenLayers.Popup.FramedCloud the FrameCloud part. Also I added a line (i modified for your implementation)

layerUrls: ['http://localhost:8080/geoserver/sac/wms'],

after

url: 'http://localhost:8080/geoserver/sac/wms', 

which should be modified by eliminating 'sac'.

Now i get the pop-up but not the content i want. But it is a small step ahead.

Mihai

share|improve this answer
add comment

can you try adding proxyhost for getting information? i am not sure proxy host will solve this problem, but it is useful to try and dont forget adding defination of variables, sometimes they really being big problem...

var info;

and proxyhost:

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

some information about proxyhost you can read this.

i hope it helps you...

share|improve this answer
    
Thanks for your answer.But i am using same port.I use tomcat and geoserver in 8080 port.So i think this is not a proxy problem. –  sacprasanna May 2 '12 at 8:57
    
Ohh it woks in IE after removing duplicated /HTML tag but not works GETfeature part in firefox or chorme.Any idea? –  sacprasanna May 2 '12 at 10:15
add comment

The problem is localhost - change it to the IP address (or web address) of the machine and it works OK -just fixed the same problem - now works in all 3 browsers. Chrome and Firefox obviously deal with these differently than IE.

share|improve this answer
add comment

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.