[GIS] CartoDB Runtime Layers with Angular

angularjscartocarto-jsleaflet

Has anyone ever tried adding a CartoDB runtime layer to a leaflet using an Angular Directive or angular-leaflet-directive (Leaflet Javascript Library)?

I tried this, which does not throw errors but my layer doesn't show. Is this a digest cycle issue?

angular.module('cartoDbDirectives', []).directive('cdbRuntime', function(){

 return {
  restrict: "A",
  scope: false,
  replace: false,

  link: function(scope, elm, attrs, controller){

    var map = L.map("mapCanvas", {
      zoom: 9,
      minZoom: 8,
      maxZoom: 19,
      center: [38.98, -75.511667], 
      zoomControl: false,
    });

    cartodb.createLayer(map, {
      user_name: 'czajk',
      type: 'cartodb',
      sublayers: [{
        sql: 'select crossing, the_geom_webmercator from crossings',
        cartocss:'#crossings{marker-fill:#ff0000;}',
        interactivity: 'crossing'
      }]
    })
    .addTo(map);
  }
 }
});

Best Answer

I found that one way to do this is using the CartoDB Core API. Check this example: http://jsfiddle.net/eczajk1/ok0nseom/

Related Question