Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>When I first read your post, I misunderstand your "marker" with <a href="http://dev.openlayers.org/docs/files/OpenLayers/Marker-js.html" rel="nofollow">OpenLayers.Marker</a>, I think you'd better still call your "marker" <a href="http://dev.openlayers.org/apidocs/files/OpenLayers/Control/WMSGetFeatureInfo-js.html" rel="nofollow">WMSGetFeatureInfo</a>. It's easier for readers to follow it :)</p> <p>Personally I think the problem you get is due to your map projection, your layer projection is "ESPG:3163" when you define the parameter "lonlatfrompx", you didn't reproject lon/lat (EPSG:4326) to "ESPG:3163". So it will be wrong lon/lat for the popup...</p> <p><strong>Update</strong></p> <p>By reading your "EDIT 1" I just notice that the way you write your "var info = new OpenLayers.Control.WMSGetFeatureInfo" function is very strange, why do you need add a ajax call inside your WMSGetFeatureInfo? the usual way to do this is using "url" parameter to query the wms instead of using the ajax call. for example: </p> <pre><code>info = new OpenLayers.Control.WMSGetFeatureInfo({ url: 'http://demo.opengeo.org/geoserver/wms', title: 'Identify features by clicking', queryVisible: true, layers: [layer], eventListeners: { getfeatureinfo: function(event) { // add popup here map.addPopup(new OpenLayers.Popup.FramedCloud( "chicken", map.getLonLatFromPixel(event.xy), null, event.text, null, true )); }, beforegetfeatureinfo: function(event) { ...... }, nogetfeatureinfo: function(event) { ...... } ...... } }); </code></pre> <p><strong>update 2</strong></p> <p>First: </p> <p>Yes, the WMSGetFeatureInfo will send multiple requests to WMS server if you include multiple source (layers). that's why your ajax called multiple times.</p> <p>Do all layers on the same map position (mouse click point) have the same id (idGeoEad)? if they do, there is a quick and dirty way which is only providing the "layers" parameter one layer (instead of array of layers), then the ajax call will only trigger one time. Or just don't set the layer &amp; url parameters, it will find the first eligible layer itself.</p> <p>Second: </p> <p>Even if that's the case, in my opinion it should not affect your popup position. Because "event.xy" and "lonlatfrompx" should always the same. So I think the popup is pointing far away from the related marker is still caused by wrong projection. So please double check your map projection, map display projection and all layers' projection. Also please check if all your layers' projection on your mapfile setting correct? Does all the layers use "EPSG:3163" ? In your code above I notice that a typo "srs : 'ESPG:3163'", it should be EPSG:3163. </p> <p>If you use fire-bug or google developer tool, please debug or console.log to see if "event.xy" and "lonlatfrompx" will get the correct position every time.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload