3

I created a tile server with OSM-data in the German style. The data is quite similar to the official tile server for openstreetmap.de, provided by Fraunhofer IOSB.

http://tile.iosb.fraunhofer.de/tiles/osmde/${z}/${x}/${y}.png

If I include the standard OSM-server

http://a.tile.openstreetmap.org/${z}/${x}/${y}.png

with the following constructor

new OpenLayers.Layer.OSM("OSM",myOSMURL,{...});

I get a valid map. The OpenCycleMap tile server works as well.

If I want to use my own tile server or the one from Fraunhofer, the browser successfully gets an respond to the GET-request from the tile server and loads the tiles needed, but doesn't show them in the map.

Following the steps here, I generated a map with local data successfully. Nevertheless, if I replace the link of the local data with a link to Fraunhofer or my tile server, the browser still loads the tiles, but doesn't show them.

// This is the layer that uses the locally stored tiles
//var newLayer = new OpenLayers.Layer.OSM("Local Tiles", "tiles/${z}/${x}/${y}.png", {numZoomLevels: 19, alpha: true, isBaseLayer: false});
var newLayer = new OpenLayers.Layer.OSM("Local Tiles", "http://tile.iosb.fraunhofer.de/tiles/osmde/${z}/${x}/${y}.png", {numZoomLevels: 19, alpha: true, isBaseLayer: false});
map.addLayer(newLayer);
// This is the end of the layer

enter image description here Image in full resolution: https://i.sstatic.net/73jOX.jpg

How do I get the tiles from my tile server or Fraunhofer to my map?

10
  • OSM Wiki has the answers in this case wiki.openstreetmap.org/wiki/OpenLayers_Local_Tiles_Example (then move to your server)
    – Mapperz
    Commented May 21, 2013 at 16:23
  • I downloaded my data and stored them locally. Following the instructions on the wiki, I successfully loaded the local data. Nevertheless, if I replace the link to the local data with a link to Fraunhofer or my tile server, the browser still loads the tiles, but doesn't show them. I'll add an image to the question, which shows that.
    – ischas
    Commented May 22, 2013 at 7:41
  • You could use a TileCache Layer: openlayers.org/dev/examples/tilecache.html Commented May 22, 2013 at 8:06
  • 2
    You could also use an XYZ layer: openlayers.org/dev/examples/mapbox.html Commented May 22, 2013 at 8:09
  • 1
    Okay, I think I found a solution: I use XYZ layer and add the attribute sphericalMercator: true. Thank you all! @DevdattaTengshe: If you like, then provide your suggestion in combination with my last comment as answer. If not, I'll write an answer by myself. I'm still curious about the fact, that OpenLayers.Layer.OSM doesn't work, because it did with other data.
    – ischas
    Commented May 22, 2013 at 11:53

2 Answers 2

3

You could use an XYZ layer in Openlayers. This layer should be used in OpenLayers, whenever you have tiles arranged by a standard XYZ grid. This tileset format has been popularized by OSM & then Mapbox.

A Sample is presented here: http://openlayers.org/dev/examples/mapbox.html

For an OSM-like layer you should set the property sphericalMercator: true, so that properties like maxExtent and projectionare set to default values for OSM. For more details see the source code of the XYZ layer.

0

If the problem depends on the browser you use, it might well be a question of Same Origin Policy.

See http://romkey.com/2011/04/23/getting-around-same-origin-policy-in-web-browsers/ for some hints.

1
  • The map works on IE and Chrome, but not on Firefox. I disabled Same Origin Policy in Firefox, but it didn't help. But even if it would have helped: The map I'm building isn't just for my personal use, so a deep intrusion in the way the browser is started cannot be the answer to my problem.
    – ischas
    Commented May 22, 2013 at 13:49

Your Answer

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

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