[OpenLayers-Users] Re: Layer.HTTPRequest

christopher.schmidt at nokia.com christopher.schmidt at nokia.com
Mon Mar 21 07:50:39 EDT 2011


On Mar 21, 2011, at 4:51 AM, ext Joost Molenaar wrote:

> There's a difference in OpenLayers between params and options, which
> is pretty confusing if you ask me. I'm not really sure which is which
> and often end up trying to set an option first in the params object
> and then in the options object when initializing a Layer, just to see
> where it has an effect.

Params are literal values that are sent to the server, and never interpreted
by the client. Options are local options, which override existing properties
of the object you pass the options to, as documented at:

  http://docs.openlayers.org/library/syntax.html

One thing that makes this more confusing is that:
 1. Most people don't which things are part of OpenLayers, and which are not.
    (For example, the WMSGetFeatureInfo class may have a 'tolerance' option
     which is local, and the WMS server may also have a parameter called tolerance
     that implements the same thing.)

 2. In OpenLayers, 'options' aren't always optional (TextLayer)

 3. Javascript doesn't have keyword-based arguments to functions, so you can't
    say name="name", etc. Which means most people don't actually know what they're
    passing.

For this reason, there's been a shift in Javascript towards using a single argument
to functions, and having it just contain key/value pairs (ExtJS style); it's possible
OpenLayers will move towards this at some point in order to limit confusion.

-- Chris
 
> The code I have for the layer is pretty simple:
> 
>    OpenLayers.Layers.MyLayer = OpenLayers.Class(OpenLayers.Layer.TMS, {
>        initialize: function(name, url, params, options) {
>            OpenLayers.Layer.TMS.prototype.initialize.apply(this,
> [name, url, params, options]);
>        },
> 
>        getURL: function(bounds) {
>            return
> 'http://example.com/some/url/based/on/bounds/parameter/that/works/for/your/server';
>        },
> 
>        CLASS_NAME: 'OpenLayers.Layers.MyLayer'
>    };
> 
> Hope this helps,
> 
> Joost
> 
> On 18 March 2011 17:46, Marco Scheuble <mail at marco-scheuble.de> wrote:
>> Hi Joost,
>> 
>> thanks for your answer. So I will try the same.
>> But I have some problems:
>> http://osgeo-org.1803224.n2.nabble.com/Implementing-new-Class-tp6181195p6181195.html
>> , so maybe you could post your code?
>> 
>> cheers, Marco
>> 
>> --
>> View this message in context: http://osgeo-org.1803224.n2.nabble.com/Layer-HTTPRequest-tp6172617p6185261.html
>> Sent from the OpenLayers Users mailing list archive at Nabble.com.
>> _______________________________________________
>> Users mailing list
>> Users at lists.osgeo.org
>> http://lists.osgeo.org/mailman/listinfo/openlayers-users
>> 
> _______________________________________________
> Users mailing list
> Users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/openlayers-users



More information about the Users mailing list