I have setup an ubuntu server based on the switch2osm steps. So now I have downloaded the latest openlayer scripts and below is my script.
<script>
var map = new ol.Map({
layers: [
new ol.layer.Tile({
source: new ol.source.OSM({
url: 'http://mapserverIP/osm_tiles/{z}/{x}/{y}.png'
})
})
],
target: 'map',
controls: ol.control.defaults({
attributionOptions: /** @type {olx.control.AttributionOptions} */ ({
collapsible: false
})
}),
view: new ol.View({
center: [244780.24508882355, 7386452.183179816],
zoom:5
})
});
I get the following errors.
Access to Image at 'http://mapserverIP/osm_tiles/5/16/10.png' from origin 'http://webserIP' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://webserIP' is therefore not allowed access. The response had HTTP status code 404.
Then I added this
source: new ol.source.OSM({
url: 'http://mapserverIP/osm_tiles/{z}/{x}/{y}.png',
crossOrigin: null
})
})
the above error is gone but now I get this error GET http://mapserverIP/osm_tiles/5/16/10.png 404 (Not Found)
I have added this now
view: new ol.View({
center: ol.proj.transform([4.258768357307995, 101.832275390625], 'EPSG:4326', 'EPSG:3857'),
zoom:5
})
There is no error but the map is empty white color ?
asked
16 Jul '17, 18:09
newbie14
31●9●9●12
accept rate:
0%