0

I defined a XYZ source and added to map

var source = new ol.source.XYZ({
  url: 'http://blabla.com/{x}/{y}/{z}.png',
  crossOrigin: 'anonymous'
})

During runtime I can access specific tile by

map.getLayers().getArray()[0].getSource().getTile(2,1,-3)

Now I want to change this tile image. I tried setting src_ and image_ properties but no change.

1

OK, I found the solution.

Firstly change tile's src by calling

map.getLayers().getArray()[0].getSource().getTile(2,1,-3).image_.src="base64 or new url"

Then call changed() function on the tile

map.getLayers().getArray()[0].getSource().getTile(2,1,-3).changed()

After all to refresh this tile call changed() function on the source object

map.getLayers().getArray()[0].getSource().changed()

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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