3

I successfully installed tile server based on the instruction given in the switch2osm.org/serving-tiles/manually-building-a-tile-server-14-04/. Also I set up apache web-server and took slippymap.html from github.com/openstreetmap/mod_tile/blob/master/slippymap.html. But when I open slippymap in browser I got error tiles but almost all of them have request status 200 (load correctly). And size of every tile is 0 kb. But if I open tile in new tab it displayed correctly.

There is the layer that uses the locally stored tiles:

var newLayer = new OpenLayers.Layer.OSM("Local Tiles", "http://127.0.0.1/osm_tiles/${z}/${x}/${y}.png", {numZoomLevels: 19});
map.addLayer(newLayer);

This I have in console: Image from origin http://127.0.0.1 has been blocked from loading by Cross-Origin Resource Sharing policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin http://192.168.224.132 (machine IP-address in local) is therefore not allowed access.

This is in all browsers.

Max
  • 99
  • 1
  • 12
  • Is the URL of the tile server in the slippymap.html really correct? – scai Oct 02 '15 at 13:37
  • Yes it is. When I input URL from the slippymap to browser it displays tile correct. But it does not display any tiles in map. – Max Oct 02 '15 at 18:50
  • And both the slippymap.html and your tiles are hosted on the same server? – scai Oct 04 '15 at 07:39
  • Yes, they are. Is that problem? – Max Oct 04 '15 at 10:06
  • No, of course not. Your question lacks still way too many information in order to help you. What do the logs say? What does the error console of your browser say? How does *your* slippymap.html look like? What about different browsers? Can you give us access to your tile server? Etc. – scai Oct 05 '15 at 06:43
  • Ok, I got it. I fixed my question and add more details. – Max Oct 05 '15 at 15:22
  • So you have a problem with *Cross-Origin Resource Sharing (CORS)*. Try searching for "OpenLayers" and "CORS". This question has been asked various times. – scai Oct 05 '15 at 16:14
  • or, for simple cases where the html and tile server is the same, make sure that you access them using the same address, e.g. use `http://192.168.224.132/osm_tiles/...` to point to your local tile server. – headuck Oct 06 '15 at 03:19

1 Answers1

1

I found solution - https://gis.stackexchange.com/questions/71715/enabling-cors-in-openlayers. Sorry, I have no experience in web development and gis. It is my first task.

Community
  • 1
  • 1
Max
  • 99
  • 1
  • 12