Hello, how to create a bookmark thumbnail image based on the current layers, extent, and graphics? Thanks
Solved! Go to Solution.
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'); }));
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.
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.
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.
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?
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'); }));
Awesome! One last question - is there a way to name the jpg to the way i want?
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.
thanks Robert. Good enough info.
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.
Baba