0

I'm using OpenLayers and I'm trying to create an information overlay layer. I'm using my own WMS server, so for this layer, the server always send an image with informations in it. My problem is that when I pan the Map, my "information" layer also pan, once finished panning, the layer is refreshed and the text is displayed in the right position. I would like to disable panning on this particular layer (WMS), is there any way to achieve this ?

I tried with an external div but didn't succeed, the panning was still there.

Thanks !

Edit: So here is what I've come with. It works perfectly, thanks for the idea

<script type="text/javascript"> 
    /////////////////////////////////////////
    // USE AN EMPTY LAYER WITH ATTRIBUTION //
    /////////////////////////////////////////

    var informationLayerRefreshStrategy = new OpenLayers.Strategy.Refresh({
        interval: 10000,
        force:true,
        refresh: function() {
        if (this.layer) {
            this.layer.attribution = "Data loading ...";
                // Load new attributions
            var layer = this.layer;
            $.ajax({
                url: "myURL",
                success: function(data){
                    layer.attribution = data;
                    map.getControlsByClass("OpenLayers.Control.Attribution")[0].updateAttribution();
                },
                global: false
            });
          }
     }
});

    var informationLayer =  new OpenLayers.Layer(
        "Sans fond de plan",
        {attribution:"Data loading ..."});

        informationLayerRefreshStrategy.setLayer(informationLayer);
        informationLayerRefreshStrategy.activate();
</script>
Michael Laffargue
  • 10,116
  • 6
  • 42
  • 76
  • What kind of data are you showing? Do you really have to render it with WMS? – Niklas Wulff Mar 28 '11 at 10:41
  • Data are "business" information written as text. There're generated by the server and should be refreshed automatically (refreshStrategy). I went with WMS as 95% of my layers are in this form. But I'm open to something else as long as the server part isn't too time consuming to create (I got my own server). – Michael Laffargue Mar 28 '11 at 12:18
  • Is the data related to any of the standard map layers? I'm thinking of using Attribution, have you looked at that? – Niklas Wulff Mar 28 '11 at 12:51
  • I'll take a look at it, maybe using ajax to update the attribution. But I think I may have some trouble to format it as I intend. Data aren't directly related to layers, there informations about the context of visualization (Some date, some object properties ...) – Michael Laffargue Mar 28 '11 at 13:59
  • Cool! Great to be able to help. :-) Too bad you have to refresh the values manually though, feels like a minor bug in OpenLayers. Would be great with a setter method that takes care of that. – Niklas Wulff Mar 29 '11 at 14:32

1 Answers1

3

My conclusion: Use a separate layer that only contains the attribution values. Do your querying to a separate resource that you could configure to use JSON. In the refreshStrategy, only update the Attribution for the layer with the resulting data, and style the generated attribution div to display on the correct place with regards to your map.

Niklas Wulff
  • 3,497
  • 2
  • 22
  • 43