1

How does Map.addLayer work?

This is what I think happens: Map.addLayer gets the bounds and scale of the Map (client side), sends an API request to EE server to clip the specified image bands at the desired pyramid level. It computes the RGB values based on the visParams, and returns an RGB image. Is this correct?

1 Answer 1

2

I’m not working at Google, so at best I can give an educated guess of how this works, based on how I’m rendering EE Maps in the system I’m working on. Chances are that the Code Editor is working fairly similar. Google - feel free to correct me if I got something wrong.

When calling Map.addLayer(eeObject, visParams), eeObject.getMap(visParams) is invoked. That sends a JSON document with the processing steps needed to generate that eeObject over to the server. The server will keep track of this for some time (I think I heard 48h, but I might be wrong). It returns a map id – an id to reference that eeObject on the server.

A Google Maps layer is created, possible using ee.layers.* classes (they are on GitHub). Google maps will call the layer and ask for tiles for given x, y, z(oom) coordinates. The layer will forward this request to the server, and include the map id generated earlier in the request. The server responds with an image, styled according to visParams, with the correct bounds and zoom level, based on x, y, z. Finally, the layer renders this image inside a div on the screen.

As you pan and zoom, Google Maps will again ask for more tiles to be rendered, with different coordinates.

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.