I am using esriRequest to export a map to PNG. How would I set a dynamic zoom level in mapOptions so that the entire selected parcel is zoomed in with some padding, as shown in the bottom image? If I include a scale value, the parcel zoom level is not dynamic, and is either zoomed in too much, or too little.
Solved! Go to Solution.
Hi Gregory,
You could try using your min max values to create an extent. Then expanding that extent and passing those new extent min max values to your JSON.
var extent = new Extent({"xmin":-122.68,"ymin":45.53,"xmax":-122.45,"ymax":45.6})
extent.expand(1.3);
console.log('Afer expand: ' + extent.xmin + ', '
+ extent.ymin + ', '
+ extent.xmax + ', '
+ extent.ymax)
Gregory,
You would set the maps zoom to your desired extent before you consider doing the export request. In all my apps I get the selected parcels geometry and expand it by 30%.
map.setExtent(pPoly.getExtent().expand(1.3), true).then(lang.hitch(this, function() {
//print the map
}));
Is there a translation to use "expand" using json? I am building a json Web_Map_as_JSON request.
Not that I am aware of.
Hi Gregory,
You could try using your min max values to create an extent. Then expanding that extent and passing those new extent min max values to your JSON.
var extent = new Extent({"xmin":-122.68,"ymin":45.53,"xmax":-122.45,"ymax":45.6})
extent.expand(1.3);
console.log('Afer expand: ' + extent.xmin + ', '
+ extent.ymin + ', '
+ extent.xmax + ', '
+ extent.ymax)
If the min/max values in your code snippet above are not for the parcel, you can get those values through the REST API with a query:
So just replace the parcel id (I hard coded it as 1101902509) with your parid variable to get the extent dynamically. Then you can expand as I showed above.
Yes! Thank you, Ben. I am able to expand the extent prior to adding it to json using your method.