Welcome Guest Search | Active Topics | Sign In | Register

Google Maps Options
Ciro Castellano
Posted: Thursday, May 23, 2013 10:17:08 AM
Rank: Newbie
Groups: Member

Joined: 3/15/2013
Posts: 7
Hi,
I've tried to add a gmaps api object to a pdf without results, so i tried to render a google maps demo map on your online converter, and still no result.
How can i add a map to my pdf page?

here the code i used for the example:
Quote:
<html>
<head>
<title>Simple Map</title>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no">
<meta charset="utf-8">
<style>
html, body, #map-canvas {
margin: 0;
padding: 0;
height: 100%;
}
</style>
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false"></script>
<script>
var map;
function initialize() {
var mapOptions = {
zoom: 8,
center: new google.maps.LatLng(-34.397, 150.644),
mapTypeId: google.maps.MapTypeId.ROADMAP
};
map = new google.maps.Map(document.getElementById('map-canvas'),
mapOptions);
}

google.maps.event.addDomListener(window, 'load', initialize);

</script>
</head>
<body>
<div id="map-canvas"></div>
</body>
</html>
Ciro Castellano
Posted: Thursday, May 23, 2013 11:16:59 AM
Rank: Newbie
Groups: Member

Joined: 3/15/2013
Posts: 7
no one?
eo_support
Posted: Thursday, May 23, 2013 11:36:20 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,195
Hi,

Please do the following:

1. Change the conversion mode from Auto to Manual before you call ConvertUrl/ConvertHtml:

Code: C#
HtmlToPdf.Options.TriggerMode = HtmlToPdfTriggerMode.Manual;


2. Add the following code inside your initialize() function after you have initialized the map object (after the var map= ... line, that is, at the end of the function):

Code: JavaScript
google.maps.event.addListenerOnce(map, 'tilesloaded', function()
{
	if (typeof(eopdf) == "object")
		eopdf.convert();
});


The reason that the map was not rendered in your PDF file is because the converter started conversion before the map has been fully loaded. #1 and #2 works together to avoid this problem. The purpose of #1 is to tell the converter do not start conversion until eopdf.convert() has been called. The purpose of #2 is to listen to google map's "tilesLoaded" event, and when that event occurs, tells the converter to start conversion. Note the code only calls eopdf.convert() when variable "eopdf" exists. This variable only exists when the page runs inside our converter. Thus eopdf.convert() won't be called when you load your page in a "normal" browser (otherwise it would throw an error because variable "eopdf" wouldn't exist).

Hope this helps. Please feel free to let us know if you have any more questions.

Thanks!

Ciro Castellano
Posted: Thursday, May 23, 2013 2:28:38 PM
Rank: Newbie
Groups: Member

Joined: 3/15/2013
Posts: 7
tried but it give timeout error every time
eo_support
Posted: Thursday, May 23, 2013 2:33:46 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,195
Hi,

Make sure you updated to the latest build first. We tested the code and it works fine. You will get timeout error if for some reason eopdf.convert() is NOT called. You can debug your code to make sure eopdf.convert() is called by using the debug console feature:

http://www.essentialobjects.com/doc/4/htmltopdf/js.aspx

Thanks!


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.