django - How to use the attribute 'url' of ol.source.OSM -
i've deployed local openstreetmap tile server , tried many times show map using openlayers3, failed unfortunately. here's experiment scene. deploy tile server on port 80, , image correctly via http://127.0.0.1:80/osm_tiles/{z}/{x}/{y}.png. besides, place django web on port 8099, , can access web page via http://127.0.0.1:8099/my/page. in template page, wrote 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, can images tile server in firebug.why? me, many thanks!
try adding crossorigin: null
source, so:
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', crossorigin: null }) });
Comments
Post a Comment