[OpenLayers-Dev] Creating custom 3rd party Layers

Christopher Schmidt crschmidt at metacarta.com
Tue Jan 29 13:03:04 EST 2008


On Tue, Jan 29, 2008 at 06:00:23PM +0100, Andrea Battisti wrote:
> 
> [...]
> 
> >>
> >> 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 :)
> >
> >   
> 
> Ok.
> I've not clear what is the chain of events that is triggered when the 
> map is loaded, or refreshed after a zoom or pan.
> The getURL is called, but the image is not downloaded yet; when/who will 
> load it in the tiles' src ?

A tile is created. A tile is an "Object", it has no HTML representation
yet. The tile is added to a grid, and it knows where it should create an
image.

The tile object uses the information it has, and calls getURL() on the
layer to ask what the tile URL should be.  

The Tile Object creates a tile "img" tag. It inserts this image tag into
the DOM. The img tag has a 'src' attribute set to the return of the
getURL function.

The browser then does the requesting of the image -- once we create an
<img> element in the DOM with the correct URL, we never touch it again.  

> What about tiles? Are they updated in background? How many at a time?

Tiles are updated as they become placed -- when dragging, tiles are
'swapped' from one side of the map to the other and their URLs are
updated based on the new location.   

> Probably, as you said, it is too complex to getting OL to work in a way 
> it was not meant to; maybe I should come up with some sort of 
> server-side wrapper that can be queried with an url and gives back an 
> image, similar to what a WMS server does.

This is one alternative. The other is to write a more complex Tile
subclass -- it's more difficult, for sure, but it's not impossible, and  
it's not outside the design: just no existing *image* Layers do it.
(WFS, on the other hand, does, but since it's not an Image tile, it's
not trivial to see how this would work to a non-developer.)

If you can figure out a way to write a WMS-like proxy, I'd recommend
that -- and once you do that, you'll be able to use TileCache with it
too ;)

Regards,
-- 
Christopher Schmidt
MetaCarta



More information about the Dev mailing list