NOTICE: help.openstreetmap.org is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum

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's gravatar image

newbie14
319912
accept rate: 0%

edited 16 Jul '17, 18:24

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×44
×7

question asked: 16 Jul '17, 18:09

question was seen: 1,488 times

last updated: 16 Jul '17, 18:24

NOTICE: help.openstreetmap.org is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum