PDF for GravityView Hooks – gfpdf_gv_static_map_max_fetches
Description
Use this filter to change how many map images one PDF can fetch from Google. If a Multiple Entries PDF shows maps for the first rows and then blank space for the rest, this limit is the likely cause.
An Entry Map field in a Multiple Entries PDF needs one map image per row, and each image is a separate request to Google (see Maps in PDFs for billing). One PDF can fetch 25 different maps. Rows past that point print nothing where the map would be, with no error message. Rows that need an identical map share one request, so the limit counts distinct maps, not rows.
A Single Entry PDF has one map per Entry Map field, so the limit doesn't matter there. The Multiple Entries Map widget draws one map for the whole PDF and isn't counted.
Before raising the limit, try these settings:
- Lower the View's Number of Entries to Display, so each PDF has fewer mapped rows (see How many entries are included).
- Add a Multiple Entries Map widget, which shows every entry on one map instead of a map per row.
A higher limit makes long PDFs slower to generate (see gfpdf_gv_static_map_timeout).
Version
This hook was introduced in PDF for GravityView 2.0.
Arguments
The following arguments are passed to functions that use this hook:
$max | int
- The most distinct map images one PDF can fetch from Google.
- Return
0to stop Entry Map fields drawing maps in any PDF. The Multiple Entries Map widget still draws its map. To turn off every map, return an empty string from gfpdf_gv_static_map_api_key. - The default value is
25
Usage
Allow up to 60 maps in one PDF:
add_filter( 'gfpdf_gv_static_map_max_fetches', function( $max ) {
return 60;
} );
Turn off Entry Map fields in PDFs, but still draw the Multiple Entries Map widget:
add_filter( 'gfpdf_gv_static_map_max_fetches', '__return_zero' );
A cached PDF keeps its blank rows until it's regenerated. After changing the limit, add &nocache=1 to the PDF link (while logged in as a user who can edit Views) to see the result right away.
Source Code
This filter is located in src/Pdf/Maps/StaticMapRenderer.php of the PDF for GravityView extension.