[OpenLayers-Dev] Creating custom 3rd party Layers
Christopher Schmidt
crschmidt at metacarta.com
Tue Jan 29 09:13:06 EST 2008
On Tue, Jan 29, 2008 at 02:16:57PM +0100, Andrea Battisti wrote:
> [...]
>
> >> 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.
> >
> >
>
> Thanks for the clarifications!
>
> I wrote a test class, (following the WMS one) and reimplemented the
> getURL() method.
> The image retrieving works well, but the interface gets kind of
> "stuck"as soon as zooming or panning is performed.
> The interface stays frozen until the image is retrieved and displayed.
>
> My guess is that the getURL is meant to be called asynchronously just to
> get the link to the image and then exit immediately; then the actual
> network transfer is deferred to later methods / calls maybe ?
Ayup. But keep in mind that at the moment, we don't have any code that
requests urls from the server asynchronously: I've explicitly avoided
layers for which that's neccesary because it's painful :)
This type of setup means that you will need a more complex solution.
Specifically, you will probably need to:
* Create a subclass of OpenLayers.Tile, similar to WFS, which requests
data asynchronously
* Create the image before you send the request, but 'hide' it
* When you ge the async request back, set the img.src on the tile
This would be a more complex subclassing of Layer.WMS, since at the
moment, I don't believe we allow the tile "class" to be determined as an
option, so that would need improving to make this easier.
It's not impossible, but it would probably be a comparitively complex
mechanism, and we don't have any documentation on ho wto do it at the
moment.
Regards,
--
Christopher Schmidt
MetaCarta
More information about the Dev
mailing list