print_map: function (template, title) { var params = new esri.tasks.PrintParameters(); var legend_layers = this.get_legend_layers(); params.map = this.map; for (var x = 0; x < this.templates.length; x++) { if (this.templates.label == template) params.template = this.templates; } params.template.layoutOptions.titleText = title; params.template.layoutOptions.legendLayers = legend_layers; var printtask = new esri.tasks.PrintTask(this.printService, params); printtask.execute(params, function (result) { console.log(result); var mywindow = window.open(result.url); }, function (err) { alert("Error printing map"); }); },
get_legend_layers: function () { var legend_layers = Array(); for (var x in this.defaults) { // Interate thru the application configuration structure (index is service id, contains info on service and individual layers) // Did we go in or out of scale var myservice = this.layers; if (myservice != null && myservice.visible == true) { var vis_layers = this.layers.visibleLayers; //iterate thru this services visible layers for (var y = 0; y < vis_layers.length; y++) { var name = this.layers.layerInfos[vis_layers].name.toString() //console.log(name); // Check with configuration settings that this layer is something we want in the legend if (this.defaults[name].is_listed == true && this.defaults[name].attribute_list != "") { var ll = new esri.tasks.LegendLayer(); console.log(name); ll.layerId = name; legend_layers.push(ll); } } } } console.log(legend_layers); return (legend_layers); }
Signed in members can post, follow updates, and more. New here? Register a free account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.