0

I'm using leaflet and esri-leaflet to create a map from a proprietary ArcGIS server. I am trying to get a PDF back from a print server. I have examples using ESRI API 3.x but can't find any using esri-leaflet.

I know the format of and can create the print server request, with the exception of the mapOptions section, where I need extent, spatialReference, and scale. I also know that there is an export requst sent to the map server every time the image changes, and the response from that request contains the information I need. But the request is not generated by my code--it happens as the result of an event.

Esri-leaflet has a event requestsuccess that seems like what I need. If I can intercept all successful requests, I can check to see if it was an export request and save the extent and scale (the extent has the SR embedded). However, I can't find any examples and the documentation gives me little clue as to how to proceed.

I'm not wedded to intercepting the request, but seems the most straightforward way to get what I need. I do know that I could get the bounds from leaflet and convert to extent, but getting the scale is harder (have to get the zoom level and have a mapping for that). So that may be another option.

ScottG
  • 534
  • 4
  • 9

1 Answers1

0

Esri leaflet includes a handy utility method to convert Leaflet bounds objects to Esri extent object literals

// http://esri.github.io/esri-leaflet/api-reference/util.html
L.esri.Util.boundsToExtent(map.getBounds())

to get the scale, you just need to do a little math on the current zoom level.

// https://gis.stackexchange.com/a/81390/21012
591657550.500000 / Math.pow(2, map.getZoom() - 1)

live demo: http://jsbin.com/ceceqir/edit?html,output

john gravois
  • 392
  • 2
  • 8