Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 1,000,000+ packages pre-installed, including maptalks.geo2img with all npm packages installed. Try it out:

require("maptalks/package.json"); // maptalks is a peer dependency. var maptalksGeo2img = require("maptalks.geo2img")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

maptalks.geo2img v0.2.0-beta.1

A tool to get base64 data src for html-tag<img> by geometry.

maptalks.geo2img

A tool to get base64 data src for html-tag< img > by geometry.

Examples

DEMO

Install

  • Install with npm: npm install maptalks.geo2img.
  • Install with yarn: yarn add maptalks.geo2img.
  • Download from dist directory.
  • Use unpkg CDN: https://cdn.jsdelivr.net/npm/maptalks.geo2img/dist/maptalks.geo2img.min.js

Usage

As a plugin, maptalks.geo2img must be loaded after maptalks.js in browsers. You can also use 'import { Geo2img } from "maptalks.geo2img" when developing with webpack.

<!-- ... -->
<script src="https://cdn.jsdelivr.net/npm/maptalks.geo2img/dist/maptalks.geo2img.min.js"></script>
<!-- ... -->
const geo2img = new maptalks.Geo2img()
const base64src = geo2img.convert(geometry)
// <img src=base64src >

API Reference

new maptalks.Geo2img(options)
  • options
    • useGeoExtent boolean set true to use geometry extent and false to use map extent, default be true.

convert(geometry, map) The result is base64 data for img src="%s", geometry should be add to layer, the second attr is unessential. setMap(map) if you geometry has not add to layer, you need set map for plugin(or push map to the second attr of convert ). remove()

BUG Already

  • svg-path often exceed boundary of SVG-tag

Contributing

We welcome any kind of contributions including issue reportings, pull requests, documentation corrections, feature requests and any other helps.

Develop

The only source file is index.js.

It is written in ES6, transpiled by babel and tested with mocha and expect.js.

Scripts

  • Install dependencies
$ npm install
  • Watch source changes and generate runnable bundle repeatedly
$ gulp watch
  • Package and generate minified bundles to dist directory
$ gulp minify
  • Lint
$ npm run lint

More Things

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free