1

I'm having trouble serving a layer using the Cartodb JS API. Essentially, the script is being refused because of MIME type. I notice ?callback=vizjson has been appended to the end of the URL (see error below) but I haven't specified this to apply anywhere in the script (see immediately below).

cartodb.createLayer(map, 'http://samcomber.cartodb.com/u/samcomber/api/v2/viz/05ea0c96-0890-11e7-b110-0e98b61680bf/viz.json')

This is the error that is returned from Chrome debugger: Refused to execute script from 'http://samcomber.cartodb.com/u/samcomber/api/v2/viz/05ea0c96-0890-11e7-b110-0e98b61680bf/viz.json?callback=vizjson' because its MIME type ('application/json') is not executable, and strict MIME type checking is enabled.

This is the code for my project:

<!DOCTYPE html>
<html>
<head>
<title>Assignment Two</title>

<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />

<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>

<link rel="stylesheet" href="http://libs.cartocdn.com/cartodb.js/v3/themes/css/cartodb.css" />
<style>
html, body, #map {
  height: 100%;
  padding: 0;
  margin: 0;
}
</style>
</head>
<body>    
<div id="map"></div>

<!-- include google maps lib -->
<script src="https://maps.googleapis.com/maps/api/js?sensor=false"></script>
<!-- include cartodb.js library -->
<script src="https://cartodb-libs.global.ssl.fastly.net/cartodb.js/v3/3.15/cartodb.js"></script>
  <!--Load the AJAX API-->
<script>

function main() {

    var map = L.map('map', { 
      center: [53.40, -2.89],
      zoom: 12,
      zoomControl: true
    });

    L.tileLayer('https://maps.nlp.nokia.com/maptiler/v2/maptile/newest/normal.day.grey/{z}/{x}/{y}/256/png8?lg=eng&token=61YWYROufLu_f8ylE0vn0Q&app_id=qIWDkliFCtLntLma2e6O', {
      attribution: 'Nokia'
    }).addTo(map);


    var currentHover,
        newFeature = null

    cartodb.createLayer(map, 'http://samcomber.cartodb.com/u/samcomber/api/v2/viz/05ea0c96-0890-11e7-b110-0e98b61680bf/viz.json')
      .addTo(map)
      .on('done', function(layer) {

      }).on('error', function() {
        console.log("some error occurred");
      });
  }


  window.onload = main;
</script>
</body>

</html>

What should I do?

  • Seeing the same thing when using createLayer with Google Maps, but only on certain layers. Have hundreds of layers to test. – knownasilya Mar 15 '17 at 14:15
2

I submitted https://github.com/CartoDB/cartodb.js/issues/1597 with this link. Carto acknowledges it's a bug and is working on resolving it.

  • Thanks @knownasilya . Interestingly, this seems like an issue on Chrome only. – Sam Comber Mar 15 '17 at 14:19
  • Yeah, extra security. Should have been fixed yesterday. – knownasilya Mar 16 '17 at 19:17

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.