[OpenLayers-Dev] Creating custom 3rd party Layers
Christopher Schmidt
crschmidt at metacarta.com
Thu Jan 24 11:19:12 EST 2008
On Thu, Jan 24, 2008 at 04:44:58PM +0100, Andrea Battisti wrote:
> Hi all,
>
> I recently very much appreciated the OL's ability to connect to and
> display different kind of layers on a web page.
>
> I was wondering how difficult is to extend it to make use of third party
> geospatial data and protocols.
> I took a quick look at some of the 3rd party implementations (i.e. the
> WMS and Google classes ...) but what I miss is the general understanding
> of the whole process of requesting tiles, and the "behind the scenes"
> working of the Layer class and subclasses.
Note that WMS is not considered "Third Party", because it is not using a
seperate *api* to interact with another HTML element, but instead
talking directly to a server.
Depending on the type of implementation you are looking to work with,
this may or may not apply to your data as well.
If you're working with a service like WMS, where your service can take
arbitrary bounding boxes, you probably want to subclass from WMS, and
override just the 'getURL' function: the getURL function is expected to
be passed an OL.Bounds() object, and return a string which can be put in
<img src="" /> to display an image for that bounds.
If you're working with something that is tiled, you can do something
similar; http://trac.openlayers.org/wiki/UsingCustomTiles has an
explanation of that which may help.
> I guess it is OpenLayers.Layer.EventPane as it is written in the doc,
> but is there a simple example to start with?
Event pane is *only* useful if you have a third party API -- one that
requests the images for you.
> Basically for each tile I have to build a formatted request string
> specifying the spatial bounds, projection and some options, submit the
> request using http, reading and parsing the reply and extracting from it
> an url pointing to the actual image data to be displayed.
Yep, you want to subclass WMS, and probably just override the getURL
method: you'll be passed a bounds, and yu'll have 'this' available with
all the properties of your laayer to take advantage of.
Regards,
--
Christopher Schmidt
MetaCarta
More information about the Dev
mailing list