1

Has anyone shown a carto map in an ionic 2 app? When I used ionic 1 there was no problem, because it is angular js and I could add the library in the index.html:

<link rel="stylesheet" href="http://libs.cartocdn.com/cartodb.js/v3/3.15/themes/css/cartodb.css">
  <script src="http://libs.cartocdn.com/cartodb.js/v3/3.15/cartodb.js"></script>

and then use it in a controller.js like that:

var mapa;
      mapa = new L.Map('mapa', { 
        center: [39,-6],
        zoom: 9
      })

But the problem is that now I'm using ionic 2, so it's angular 2, typescript. After adding the libraries I try to do the same code above in the .ts file, but it can't find the name L.

Has anyone idea how to show my map? Or how to use a js library in typescript?

  • I'm not familiar with the ionic platform, but I do use Angular 2 so forgive me if this is not applicable. The Carto.js library is on github, and you can install it as a node package - npmjs.com/package/cartodb – Jags Jun 6 '17 at 0:15
  • Regarding the tagging, this looks more a ionic question than anything related with CARTO – Jorge Sanz Jun 6 '17 at 10:51
  • I have asked this question in other pages, and finally I used the answer of this one: es.stackoverflow.com/questions/76234/… That works for me. I tried to use the node package but it was easier for me not to change my code, so that's why I first chose that solution. Thanks! – Cristina Extremera Romero Jun 7 '17 at 7:47

Your Answer

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

Browse other questions tagged or ask your own question.