【问题标题】:php - create pdf from googlemap contents using mpdf toolphp - 使用 mpdf 工具从 googlemap 内容创建 pdf
【发布时间】:2014-04-28 14:21:36
【问题描述】:

今天我发现mpdf 工具可以从 html 生成 pdf,虽然我可以从普通段落、div 等生成 pdf,但我有兴趣从谷歌地图内容生成 pdf..

我正在使用 simplegooglemap api v3,其中我使用标记生成这样的地图

<?php
        require_once("simpleGMapAPI.php");
        $map = new simpleGMapAPI();
        $map->setWidth('500px');
        $map->setHeight('500px');
        $map->addMarker("48.983307", "72.808907","My first marker","");
        $map->printGMapsJS();
        $map->showMap(true); 
?>

请有人帮我从谷歌地图生成 pdf

提前谢谢..

【问题讨论】:

    标签: javascript php html google-maps mpdf


    【解决方案1】:

    你能做的是;而不是直接在浏览器中加载谷歌地图 api - 使用他们的Google Maps Image APIs

    因此,您的 html 将如下所示:

    <html>
        <head>
            <title>Test</title>
        </head>
        <body>
            <h1>This is a test.</h1>
            <p>We are located here:</p>
            <img width="200" height="200" src="http://maps.googleapis.com/maps/api/staticmap?center=-15.800513,-47.91378&zoom=11&size=200x200&sensor=false">
        </body>
    </html>
    

    这样,mpdf 库应该能够下载和加载图像源,并将其作为普通图像嵌入到 PDF 中。


    如果您需要在静态地图图像上为内嵌包含标记;看看这个: https://developers.google.com/maps/documentation/staticmaps/?hl=en#Markers

    【讨论】:

    • 但我有超过 1 个标记,有时 50-100 个标记,请建议
    • 根据文档,这是允许的; markers=markerStyles|markerLocation1| markerLocation2|... etc.
    • 静态地图的 URL 长度有限制(约 2000 个符号),所以你不能在那里放置 50-100 个标记
    猜你喜欢
    • 1970-01-01
    • 2020-05-27
    • 2015-08-08
    • 1970-01-01
    • 2014-08-25
    • 1970-01-01
    • 2017-03-18
    • 1970-01-01
    • 2015-03-17
    相关资源
    最近更新 更多