Skip to content Skip to sidebar Skip to footer

How To Fix The Google Map Api When Print The Whole Page?

I'm trying to just print exactly what the user sees in maps when he clicks in the Print Button, but I don't know why, the map changes completely. I just want that the map resizes

Solution 1:

Google Map API does not support printing:

Printing from the JavaScript API is not supported. This is because printing support is inconsistent across commonly used browsers. We recommend using the Static Maps API for printing purposes.

As it is mentioned, a solution is to use Static Map API. You simply need to get the viewpoint of the map (boundaries) and send it to static map API and retrieve an image that you can easily print. The Static Map API even supports things like markers.

An example

https://maps.googleapis.com/maps/api/staticmap?center=Brooklyn+Bridge,New+York,NY&zoom=13&size=600x300&maptype=roadmap
&markers=color:blue%7Clabel:S%7C40.702147,-74.015794&markers=color:green%7Clabel:G%7C40.711614,-74.012318
&markers=color:red%7Clabel:C%7C40.718217,-73.998284
&key=YOUR_API_KEY

Post a Comment for "How To Fix The Google Map Api When Print The Whole Page?"