I've deployed a local openstreetmap tile server and tried many times to show the map using openlayers3, but failed unfortunately. Here's my experiment scene. I deploy the tile server on port 80, and get the image correctly via http://127.0.0.1:80/osm_tiles/{z}/{x}/{y}.png. Besides, I place a django web on port 8099, and i can access the web page via http://127.0.0.1:8099/my/page. In the template page, i wrote like this
var layer = new ol.layer.Tile({
source: new ol.source.OSM({
attributions: [
ol.source.OSM.ATTRIBUTION
],
url:'//127.0.0.1:80/osm_tiles2/{z}/{x}/{y}.png'
})
});
var map= new ol.Map({
target : 'map_canvas',
loadTilesWhileAnimating: true,
view: new ol.View({
center:ol.proj.transform([116.391625,39.906813], 'EPSG:4326', 'EPSG:3857'),
zoom : 12
}),
layers:[layer]
});
The map_canvas shows nothing, but i can get the images from tile server in firebug.WHY? Help me, many thanks!