Wednesday, April 20, 2016

No 'Access-Control-Allow-Origin' header is present on the requested resource


Tileserver:
-----------------------------------------------------------------------------------------------------------------------
This is error message

XMLHttpRequest cannot load http://vectortile.mydomain/city/13/1411/3282.pbf. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:100' is therefore not allowed access.

I setup subdomain as
vectortile.mydomain =  http://ip:port/tileserver/tileserver.php?/index.json?/

So if i run http://vectortile.mydomain/city/13/1411/3282.pbf from my local pc, it correctly response the file.

If i run website http://localhost:100/mywebsite,  I get above error.

If tile sever run on local pc, no problem. The problem is only when I use domain host tile server.


I think the problem is subdomain with two "?"

if I do not use subdomain, instead use IP and port, will solve the problem.
------------
Not work: error message above.
set subdomain = http://ip:port/tileserver/tileserver.php?/index.json?/

tile_url = 'http://subdomain/' + 'city//{z}/{x}/{y}.pbf'
---------------------------------------------------------------------------------
remove subdomain.

Work!
tile_url = 'http://ip:port/tileserver/tileserver.php?/index.json?/city//{z}/{x}/{y}.pbf'


=======================================================================


   
    //_tileserver_base_url = 'http://vectortile.transparentgov.net/'; // NOT work,with error No 'Access-Control-Allow-Origin' header is present on the requested resource
        _tileserver_base_url = 'http://166.62.80.50:10/tileserver/tileserver.php?/index.json?/'; // must use this



    // _tileserver_url = 'http://localhost:10/tileserver/tileserver.php?/index.json?/' + _area + '/{z}/{x}/{y}.pbf';
     //   _tileserver_url = _tileserver_base_url + 'tileserver.php?/index.json?/' + _area + '/{z}/{x}/{y}.pbf';


        _tileserver_url = _tileserver_base_url + _area + '/{z}/{x}/{y}.pbf';
==============================================================

tilestream:
both ip:port or subdomain will work. 


var _tile_baseURL = 'http://166.62.80.50:8888/v2/';



            //http://tile.transparentgov.net/v2/cityadr/{z}/{x}/{y}.png
            _tile_baseURL = 'http://tile.transparentgov.net/v2/';
            // _tile_baseURL = 'http://localhost:8888/v2/cityadr/{z}/{x}/{y}.png';





                    return _tile_baseURL + _areaID + '_' + _subjectID + '/' + zoom + '/' + coord.x + '/' + coord.y + '.png';

No comments: