khajur

printing a zoomed out map on esri/tasks/PrintTask vs esri/dijit/Print

Discussion created by khajur on Mar 3, 2014
When i zoom out all the way where I can see the entire world, I get two different images from PrintTask vs print dijit.
PrintTask gives me an oval (globe-like) image, while print dojit gives me a flat image. I am trying to acquire a flat image using printtask. Any ideas?

Here is what I have:-----

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="test.aspx.cs" Inherits="TestWebApp.test" %>

  <!DOCTYPE html>
<!doctype html>
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <!--The viewport meta tag is used to improve the presentation and behavior of the samples 
      on iOS devices-->
    <meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no">
    <title>Feature Layer - display results as an InfoWindow onHover</title>

    <link rel="stylesheet" href="http://js.arcgis.com/3.8/js/dojo/dijit/themes/tundra/tundra.css">
    <link rel="stylesheet" href="http://js.arcgis.com/3.8/js/esri/css/esri.css">
    <style>
      html, body, #mapDiv {
        padding:0;
        margin:0;
        height:100%;
      }
      #mapDiv {
        position: relative;
      }
    </style>

    <script src="http://js.arcgis.com/3.8/"></script>
    <script>
        var map, dialog;
        require([
        "esri/map", "esri/tasks/PrintTemplate", "esri/tasks/PrintParameters", "esri/tasks/PrintTask", "esri/dijit/Print"
      ], function (
        Map, PrintTemplate, PrintParameters, PrintTask, Print
      ) {
          map = new Map("mapDiv", {
              basemap: "streets",
              center: [0, 33.646],
              zoom: 2,
              slider: false
          });
          esri.config.defaults.io.proxyUrl = "/proxy.ashx";
          esri.config.defaults.io.alwaysUseProxy = false;

          document.getElementById("printBtn").onclick = function () {
              var printTask = new esri.tasks.PrintTask("http://sampleserver6.arcgisonline.com/arcgis/rest/services/Utilities/PrintingTools/GPServer/Export%20Web%20Map%20Task");
              var printParams = new esri.tasks.PrintParameters();
              var template = new esri.tasks.PrintTemplate();

              template.layout = "MAP_ONLY"; //Tabloid ANSI B Landscape

              template.format = "JPG";
              printParams.map = map;
              printParams.outSpatialReference = new esri.SpatialReference({ wkid: 26917 });
              printParams.template = template;

              printTask.execute(printParams, function (mapUrl) {
                  console.log('The url to the print image is : ' + mapUrl.url);

              }, function (err) {
                  alert('error');
              });
          };
          var printer = new Print({
              map: map,
              url: "http://sampleserver6.arcgisonline.com/arcgis/rest/services/Utilities/PrintingTools/GPServer/Export%20Web%20Map%20Task"
          }, document.getElementById("printBtn2"));
          printer.startup();
      });
    </script>
  </head>
  <body class="tundra">
    <div id="mapDiv">
    </div>
    <div id ="printBtn" style="position: absolute; left: 0; top: 0;">Print</div>
    <div id ="printBtn2" style="position: absolute; left: 0; top: 20px;">Print2</div>
  </body>
</html>

Outcomes