I'm quite cartography illiterate.

I implemented an OpenLayers 3 map on my website and everything's working fine except for the zoom in/out. The first time the map loads, I can zoom into any city and it will update the zoomed in tiles accordingly showing the streets and all the info. However, after this initial zoom-in, if I zoom out and then try to zoom in on any other city, it won't load the tiles. It will still zoom in but I will only see some pixelated map tile because the current zoom level tiles are not updating properly.

I've tried pulling the tiles specifying other OSM sources (for example: "http://labs.metacarta.com/wms-c/Basic.py/1.0.0/basic/{z}/{x}/{y}.png") but this made no difference.

I've also tried setting an event on the map to refresh the tiles on click. I tried a couple of functions from OpenLayers API website, redraw(), render(), renderSync(), but none did the trick.

The only moment when zooming in/out actually works properly is when I don't explicitly set the projection on the view.

      var view = new ol.View({
      // projection: 'EPSG:4326',
      center: [0, 0],
      numZoomLevels: 1,
      zoom: 2

Uncommenting the projection parameter will make the zoom in/out work flawlessly. Unfortunately, I have a set of coordinates I need to make the map aware of, and the only way of having them placed correctly is by using that projection.

Can you show me any way around this?

  • Your map is in web mercator so if you tell it that you have lat/long it won't work. – Ian Turton Jan 19 '17 at 17:53
  • The coordinates work fine on EPSG:4326. However, using EPSG:4326 is what makes the zoomed tiles not work and I only have lat/long, therefore I really need to use EPSG:4326 (if I understood it all correctly). Can you think of any way to use EPSG:4326 and make the zoomed in tiles appear correctly? As I noted in the post, the first zoom-in always works fine, it's later on the subsequent zooms when it's not working fine anymore. – John Cartodoe Jan 19 '17 at 18:01
  • You need to reproject your points to match the map – Ian Turton Jan 19 '17 at 18:02

Your Answer

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

Browse other questions tagged or ask your own question.