Select to view content in your preferred language

create bookmark thumbnail image from the current layers, extent, and graphics

2527
10
Jump to solution
08-08-2016 11:18 AM
Alexwang
Frequent Contributor

Hello, how to create a bookmark thumbnail image based on the current layers, extent, and graphics? Thanks

Tags (2)
0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus

Alex,

  Here is a code snippet that I use for the purpose of getting a map image:

var printTask = new PrintTask('your server ExportWebMap url');
        var template = new PrintTemplate();
        this.imgHeight = (740/oWid) * oHgt;
        template.exportOptions = {
          width: 1542,
          height: (1542/oWid) * oHgt,
          dpi: 200
        };
        template.format = "jpg";
        template.layout = "MAP_ONLY";
        template.preserveScale = false;
        template.showAttribution = false;

        var params = new PrintParameters();
        params.map = this.map;
        params.template = template;
        printTask.execute(params, lang.hitch(this, function(rsltURL){
            var mapImg = domConstruct.toDom('<img src="'+rsltURL.url+'" border="0" style="width:740px;height:'+this.imgHeight+'px;"/>');
            domConstruct.place(mapImg, dom.byId('mapImgDiv'), 'replace');
        }));

View solution in original post

10 Replies
RobertScheitlin__GISP
MVP Emeritus

Alex,

  As there is no cross browser ability in the JS API to scrape the map image, your option is to click printscreen on your computer and edit the saved screen image to your liking and use that image.

0 Kudos
Alexwang
Frequent Contributor

Thanks Robert. I saw the Print widget can generate a map in graphics format. Can I use it for my purpose? sorry I haven't tried it yet.

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Alex,

  Absolutely you can use the PrintTask in the JS API to get "MAP_ONLY" output. I use the PrintTask to get a map image in several of my custom apps.

0 Kudos
Alexwang
Frequent Contributor

Thanks Robert. Can you please direct me any online resources of how to create my own Export Web Map Task GP services? is it possible or i have to use ESRI's?

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Alex,

  Here is a code snippet that I use for the purpose of getting a map image:

var printTask = new PrintTask('your server ExportWebMap url');
        var template = new PrintTemplate();
        this.imgHeight = (740/oWid) * oHgt;
        template.exportOptions = {
          width: 1542,
          height: (1542/oWid) * oHgt,
          dpi: 200
        };
        template.format = "jpg";
        template.layout = "MAP_ONLY";
        template.preserveScale = false;
        template.showAttribution = false;

        var params = new PrintParameters();
        params.map = this.map;
        params.template = template;
        printTask.execute(params, lang.hitch(this, function(rsltURL){
            var mapImg = domConstruct.toDom('<img src="'+rsltURL.url+'" border="0" style="width:740px;height:'+this.imgHeight+'px;"/>');
            domConstruct.place(mapImg, dom.byId('mapImgDiv'), 'replace');
        }));
Alexwang
Frequent Contributor

Awesome! One last question - is there a way to name the jpg to the way i want?

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Alex,

  I have only used the jpg in a html img element and never had a need to name the image specifically, so I am not sure.

0 Kudos
Alexwang
Frequent Contributor

thanks Robert. Good enough info.

0 Kudos
deleted-user-CQZbjNeBXm49
Deactivated User

Hi Alex,

Export Web Map Task depends on what you want it to achieve and the resource below shows examples, steps and various ways to achieve them.

A quick tour of publishing a geoprocessing service—Sharing geoprocessing workflows | ArcGIS for Desk...

Baba