Jump to content

Recommended Posts

Posted

Hello PW Community,

Do you know how to export current page's map as a pdf?

Extended explanation: I have a template which has lots of fields, among which there is a field "geolocation" populated by the googlemapmarker module. Now, I wish to export the whole template as a pdf (with pages2pdf module), but the normal code that works on the ordinary pw's templates does not seems to work within the Pages2pdf dedicated templates.

Below the code (working but not producing anything within Pages2pdf module):

// alternative 01
<?php
    $map = $modules->get('MarkupGoogleMap');
    echo $map->render($page, 'geolocation');
?>

// alternative 02
<?php
    $page = wire('page');
    $map = $modules->get('MarkupGoogleMap');
    echo $map->render($page, 'geolocation');
?>

Thanks in advance!

Posted

I'm quite sure that pages2pdf does not execute any javascript. You might be able to get what you need using google's static maps api, where maps are rendered as images, but that's not part of the mapmarker module. Also I'd suggest reading the terms of service in detail, not that such operations are prohibited by google. 

  • Like 1
Posted

Thanks LostKobrakai,

you pointed me in the right path by suggesting the static google map. I've achieved the above by simply doing this in the pages2pdf template:

<img src="https://maps.googleapis.com/maps/api/staticmap?center=40.714728,-73.998672&zoom=12&size=400x400&key=______">

which simply return a static image map. Useful enough!

 

  • Like 2

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...