CSUNRAE


Help Please,

I am about to give up on Firefox and tell the client that we cannot support printing maps in Firefox browser.

Basically I have a custom printing option for my map, it works fine in IE but for some odd reason it won't print the map in firefox. It sure does print the route but not just the map image. Anyone have any idea how to do this

Please Help, I am attaching the source code.

Thanks,

Csunrae

Code Snippet

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>:: Custom Print Option ::</title>

<script type="text/javascript" src="http://dev.virtualearth.net/mapcontrol/mapcontrol.ashx v=5"></script>

<script type="text/javascript" language="javascript">

var map = null;

function GetMap() {

map = new VEMap('myMap');

map.LoadMap(null, 4, 'r', true);

var ffv = 0;

var ffn = "Firefox/"

var ffp = navigator.userAgent.indexOf(ffn);

if (ffp != -1) ffv = parseFloat(navigator.userAgent.substring(ffp + ffn.length));

// If we're using Firefox 1.5 or above override the Virtual Earth drawing functions to use SVG

if (ffv >= 1.5) {

Msn.Drawing.Graphic.CreateGraphic=function(f,b) { return new Msn.Drawing.SVGGraphic(f,b) }

}

map.HideDashboard();

map.GetRoute("Space Needle", "Microsoft", null, null, OnGetRoute);

}

function OnGetRoute(route) {

if (route) {

var _rr = document.getElementById('dRouteResults');

var _ri =

"<div id='routeSummary'><h3>Route summary</h3>" +

" <table>" +

" <tbody>" +

" <tr>" +

" <td id='startLabel'>Start:</td>" +

" <td>" + route.StartLocation.Address + "</td>" +

" </tr>" +

" <tr>" +

" <td id='endLabel'>End:</td>" +

" <td>" + route.EndLocation.Address + "</td>" +

" </tr>" +

" </tbody>"+

" </table>" +

" <ul>" +

" <li>Total distance: " + route.Itinerary.Distance + " " + route.Itinerary.DistanceUnit + "</li>" +

" <li>Estimated time: " + route.Itinerary.Time + "</li>" +

" </ul>" +

"</div>" +

"<table>" +

" <tbody>" +

" <tr>" +

" <td id='directionsInstructionHeader' colspan='2'>" +

" <ul class='listOne'><li><b>Driving directions</b></li></ul>" +

" </td>" +

" </tr>";

for (var i = 1; i < (route.Itinerary.Segments.length); i++) {

if (i % 2 == 0) {

_ri += "<tr vAlign='middle'>";

}

else {

_ri += "<tr id='shadedInstructionLabel' vAlign='middle'>";

}

if (i == 1) {

pinImage = "http://local.live.com/i/bin/1.3.20070327220207.22/pins/mapicon_start.gif";

}

else if (i == route.Itinerary.Segments.length-1) {

pinImage = "http://local.live.com/i/bin/1.3.20070327220207.22/pins/mapicon_end.gif";

}

else {

pinImage = "http://local.live.com/i/bin/1.3.20070327220207.22/pins/RedCircle" + (i-1) + ".gif";

}

distance = route.Itinerary.Segments[i].Distance;

if (distance != 0) {

distance = " (" + route.Itinerary.Segments[i].Distance + " " + route.Itinerary.DistanceUnit + ")";

}

else {

distance = "";

}

_ri +=

" <td vAlign='top' align='center'>" +

" <IMG alt='" + (i-1) + "' src='" + pinImage + "' border='0' />" +

" </td>" +

" <td vAlign='top'>" + route.Itinerary.Segments[i].Instruction + distance + "</td>" +

"</tr>";

}

_ri +=

" </tbody>" +

"</table>";

_rr.innerHTML = _ri;

}

}

</script>

</head>

<body onload="GetMap();">

<div id="myMap" style="position: relative; width: 500px; height: 500px; border: 2px solid #004080;">

</div>

<div id="dRouteResults" style="display: block;">

</div>

</body>

</html>





Re: Custom Map Print Option

SoulSolutions


You don't need the FF2.0 hack any more but either with or without it I have no issues with a print preview in FF2.0.0.3. The map shows up fine.

Is this what you mean Or does the preview look fine but the actual print not work (I don't have a printer attached)

John.







Re: Custom Map Print Option

Derek Chan

I've tested the code and it works under FireFox 1.5 too. Also on a side note you can "fake" prints out on your CPU using the Microsft Office Document Image Writer that comes with MS Office 2003-2007 to print out a paper copy onto your CPU for testing purposes.





Re: Custom Map Print Option

CSUNRAE

Yes John the print preview is always fine but when you actually print it onto a prnter then you don't see the map.

I am using the latest version of FF 2.0.0.3, I even tried this on FF 1.5.03, but it IE the print to the printer works and looks fine.

Csunrae






Re: Custom Map Print Option

Harvester

I'll second this. I've not been able to get FF to print yet. IE7 will (sort of, after making some CSS changes to ensure the ERO stuff is truly gone, not just hidden) but FF will not print the map tiles, just my pins. Our customer is about singe me re. printing so any advice would be appreciated.

BTW, Thanks for the tip re MS Doc Writer! Great paper saver.




Re: Custom Map Print Option

bcamp1973

Has anyone found a solution to this yet We're trying to deploy VE as part of our locator service and this is proving to be a big issue...I'm having no luck finding a solution online and this seems to be the only page on the internet on the topic!



Re: Custom Map Print Option

Magnus Naslund

I've tried the code and I have problems both in Firefox (2.0.0.5) and Internet Explorer (7.0.5730.11)

In Firefox I get the polylines (route) and icons but no map.
In IE I get the map and icons but not the polylines.

Magnus





Re: Custom Map Print Option

bcamp1973

We're seeing very similar behavior in PC (and Mac FF) browsers as well. At a loss at this point...