0

I created a map in carto and then applied to my c# application like CartoDB source example that I saw on openlayers web page. like this:

     var mapConfig = {
        'layers': [{
            'type': 'cartodb',
            'options': {
                'cartocss_version': '2.1.1',
                'cartocss': '#layer { polygon-fill: #374C70; polygon-opacity: 0.9; ::outline { line-color: #FFF; line width: 1; line-opacity: 0.5; } }',
                'sql': 'SELECT * FROM kitap1'
            }
        }]
    };

    var cartoDBSource = new ol.source.CartoDB({
        account: 'seymacengiz',
        config: mapConfig
    });

    var map = new ol.Map({
        layers: [
          new ol.layer.Tile({
              source: new ol.source.OSM()
          }),
          new ol.layer.Tile({
              source: cartoDBSource
          })
        ],
        target: 'map',
        view: new ol.View({
            center: [0, 0],
            zoom: 2
        })
    });

At first, it was working .But now I'm getting this error:

    XMLHttpRequest cannot load https://seymacengiz.cartodb.com/api/v1/map. Response for preflight is invalid (redirect)

And also this link goes to "https://carto.com/noneuser.html" I saw v1 in link.I think, it means version1 .

Can this be the reason for the error?

1

I think the OpenLayers source is directing you to cartodb.com instead of carto.com. The old domain works for old accounts (but eventually we will shut down the domain also for them) but for new accounts, only the carto.com endpoints are going to resolve.

I don't know how the OL layer works, but maybe there's a way to force the endpoint. In the meantime I've sent an issue to the OL bug tracker to fix this.

Disclaimer: I work at CARTO

  • In fact, I'm using free trial version now. And I signed up 2 days ago. I think it can not be old account. Thanks for issue. – seymacengiz Sep 4 '17 at 14:20
1

I guess, openlayers force to cartodb.com in their js file. I fixed this issue with changing a part of ol.js file. I created my own js file and copied ol.js to mine.I saw this code block in js file:

    function cx(a){var b=JSON.stringify(a.i);if(a.o[b])dx(a,a.o[b]);else{var c="https://"+a.B+".cartodb.com/api/v1/map";a.C&&(c+="/named/"+a.C);var d=new XMLHttpRequest;d.addEventListener("load",a.Pl.bind(a,b));d.addEventListener("error",a.Ol.bind(a));d.open("POST",c);d.setRequestHeader("Content-type","application/json");d.send(JSON.stringify(a.i))}}

then changed cartodb.com to carto.com. I used my js file instead of ol.js. It works now thank you

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.