DAB Sources example

In this example below you will see how to do a DAB Sources example with some HTML / CSS and Javascript

Thumbnail
This awesome code was written by fpape, you can see more from this user in the personal repository.
You can find the original code on Codepen.io
Copyright fpape ©
  • HTML
  • CSS
  • JavaScript
     <head>
    <meta charset="utf-8" />	                           
    <!-- API minified js -->
    <script type="text/javascript" src="http://api.eurogeoss-broker.eu/download/giapi/lib/min/giapi.min.js"></script>
</head>
 
<body>
		<h1 style='margin-left: 15px'>Usage of DAB.sources method</h1>
		<div  id="outDiv"   style="margin-top: 5px; width:1000px; height: 600px"></div>  
</body>
         
    

/*Downloaded from https://www.codeseek.co/fpape/dab-sources-example-bwmBZd */
    


/*Downloaded from https://www.codeseek.co/fpape/dab-sources-example-bwmBZd */
     jQuery(function(){
   
          // creates a new DAB instance with the given endpoint
          var dab = GIAPI.DAB('http://arpa-er.geodab.eu/gi-cat-plata/');

	        // defines the callback
	        var onResponse = function(response){
	        		    
	          	if(response.error){
	                 
	        		     $('#outDiv').append("Error occurred: "+response.error); 
	                 return;
	            }
              
              // get the sources
              var sources = response.result;
                        
              for(var i=0; i< sources.length; i++){
                  
                  var source = sources[i];
                  var report = source.report();
                
                  var id = report.id;
                  var title = report.title;
                  var onlineURL = report.online[0].url;
                 
                  $('#outDiv').append('- Source id: '+id+'<br>');
                  $('#outDiv').append('- Source title: '+title+'<br>');
                  $('#outDiv').append('- Source url: '+onlineURL+'<br>');
                  $('#outDiv').append('---- <br>');
              }         
	           
	        };         
          
          // invokes the sources method
          dab.sources(onResponse);
});

Comments