GithubHelp home page GithubHelp logo

fredbwang / tcpdf-easykmz Goto Github PK

View Code? Open in Web Editor NEW
5.0 2.0 0.0 26.32 MB

This is a tcpdf library for kmz and kml file parsing. Drawing map, overlay, placemarks has never been easier!

License: MIT License

PHP 100.00%
tcpdf tcpdf-extension kml-parser pdf-generation pdf php kml google-maps kmz

tcpdf-easykmz's Introduction

TCPDF-easyKMZ

This library is built to render kmz and kml file into pdf file. Originally kmz and kml file could be read through google map and google earth pro. When I tried to print a map with overlay and points onto a pdf page, I can only take a screenshot and insert it into pdf as an image. It becomes obscure when you zoom in and you cannot remove default layer of google map out of that image. So I decide to write a little tool for parsing and rendering geo-info on pdf page like an overlay.

Firstly I choose to implemented basic placemark, then my most-in-demand feature Ground Overlay. More features like lines will be done in future. And help from more advanced pdf or geo coder is welcomed.

Prerequisites

You will have to install php and a webserver in your computer, which in my case XAMPP. And you have to install tcpdf in your directory. I simple put the tcpdf php source code in my directory and import it in my php script:

require_once(dirname(__FILE__).'/tcpdf/tcpdf.php');

And to use easyKMZ, simply put easyKMZ under the same directory and require it in your php script:

require_once(dirname(FILE).'/easyKMZ.php'); 

You also have to have a google map api key for basic map.

Usage

Your will create an instance TCPDF and of easyKMZ. Configurable parameters are as follows:

$map = new easyKMZ($pdf, 'path/to/KMZ.kmz', 'google map api key', 'map type', 'bounds', 'whether to display color',  'file id');
  • $pdf: tcpdf instance you just created;
  • $path to kmz file;
  • $bound is an array which specifies the coordinates of the area that you want to put the map in;
  • $displayColor actually is an issue to be fixed, I can't fill color to some icon as google does to some of their icons, so I use colored circles instead temporarily. If you desire colored placemark, set it to true;
  • I use a google map api key to get a base map (in case you need it), right now I use google map as my basic layer. if you have other source, you can modify the code to change the basic map source.
  • File ID is for kmz temp folder. I use a temp folder(which will be deleted after creating pdf) to store extracted kmz, and if you want to name extracted file specifically, set the id yourself.

Then add page, set bounds and print map, end printing. You can specify layers when printing:

$map->print('OP');

Here O stands for overlay, P stands for placemarks, you can also add M for basic map and L for legends.

Example

Examples can be found in KMZ-sample folder

License

TCPDF-easyKMZ is open-sourced software licensed under the MIT license.

tcpdf-easykmz's People

Contributors

fredbwang avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.