Specify scale when printing map

1515
7
08-06-2014 09:16 AM
RyanSellman
Occasional Contributor II

I am wondering if in the JavaScript API, I can give users the ability to specify the scale before creating a printout with ArcGIS Server printing tools.  With the print widget in the Flex Viewer, the "Use this scale" option seems to be built in as you can see in the attached photo.

Capture.PNG

Has anyone been able to implement this option in the JS API?

Thanks!

0 Kudos
7 Replies
JoshHevenor
Occasional Contributor II

The usual workflow is to print what you see but this can be done.

The print task accepts a map object. Set the scale on that map object (I'd set your dropdown list to the zoom levels that your map supports) and then call your print task. You could try a workflow like this:

- click print button

- show print dialog, print button disabled

- Set scale

---> map updates

---> enable print button

The map on you screen is your 'print preview' more or less.

RyanSellman
Occasional Contributor II

Hi Josh,

Thanks for your response!  I have actually been working on a similar workflow to what you described in your reply.  I set up a text box that passes a value into the map.setScale method.  However, the issue that I just ran into is I can only set the scale to a zoom level defined in my basemap (so, 350000, 250000, 125000, 64000, 32000, etc.)  For example, if a user types in 260000, its going to send the map to 250000.  Anyway around this?  Maybe this isn't the best approach?

Ryan

0 Kudos
JoshHevenor
Occasional Contributor II

If you're using someone elses basemaps then I think you're stuck to their zoom levels (no fractional zoom supported). If you don't define a basemap, or you roll your own basemap, then I think you can choose your own Levels of Detail (see map.LOD in API doc).

RyanSellman
Occasional Contributor II

Looks like if I specify the LODs used in the map, any tiled services added to the map must match specified LODs.  So, unfortunately I think I'm stuck since I am adding a tiled service at the mentioned scales - scales that are limiting.  Maybe I need to re-configure my tiled service so it includes scales that I might want users to able able to print at?  Not so sure I want to do that...

0 Kudos
KenBuja
MVP Esteemed Contributor

If you re-configure your service like that, you won't be able to use any of the Esri basemaps.

0 Kudos
RyanSellman
Occasional Contributor II

Exactly - definitely something I don't want to do.

0 Kudos
RyanSellman
Occasional Contributor II

Is there a way to change or get at the scale in the mapOptions object in the Export Web Map JSON?

0 Kudos