Skip to content
This repository has been archived by the owner on Jan 31, 2023. It is now read-only.

Commit

Permalink
separate into files and build with browserify
Browse files Browse the repository at this point in the history
  • Loading branch information
kelvinabrokwa committed May 18, 2017
1 parent 6c78c39 commit e46978e
Show file tree
Hide file tree
Showing 8 changed files with 2,764 additions and 362 deletions.
24 changes: 0 additions & 24 deletions API.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

### Table of Contents

- [FontCanvas](#fontcanvas)
- [VectorTiles](#vectortiles)
- [initialize](#initialize)
- [search](#search)
Expand All @@ -11,26 +10,10 @@
- [restyleByProperty](#restylebyproperty)
- [setFeatureStyle](#setfeaturestyle)
- [resetFeatureStyle](#resetfeaturestyle)
- [getFeatureGroup](#getfeaturegroup)
- [getLayer](#getlayer)
- [getGeoJSON](#getgeojson)
- [removeFeature](#removefeature)

## FontCanvas

**Extends Canvas**

A canvas renderer that can draw fonts.
Useful for icon fonts.

**Examples**

```javascript
var map = L.map('map', {
renderer: new L.FontCanvas()
});
```

## VectorTiles

**Extends GridLayer**
Expand Down Expand Up @@ -124,13 +107,6 @@ Revert a feature to its origin style.

- `id` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)**

## getFeatureGroup

Returns the feature group that holds all features in the GridLayer
intended for use with Leaflet.Draw

Returns **L.FeatureGroup**

## getLayer

Returns a reference to the layer identified by the id
Expand Down
44 changes: 44 additions & 0 deletions Leaflet.FontCanvas.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/**
* A canvas renderer that can draw fonts.
* Useful for icon fonts.
*
* @class FontCanvas
* @extends Canvas
*
* @example
* var map = L.map('map', {
* renderer: new L.FontCanvas()
* });
*/

L.FontCanvas = L.Canvas.extend({
_updateCircle(layer) {
if (!this._drawing || layer._empty()) { return; }

const p = layer._point;
const ctx = this._ctx;
const r = layer._radius;
const s = (layer._radiusY || r) / r;

this._drawnLayers[layer._leaflet_id] = layer;

if (layer.options.content && layer.options.font) {
ctx.font = layer.options.font;
ctx.fillStyle = layer.options.color;
ctx.fillText(layer.options.content, p.x, p.y);
} else {
if (s !== 1) {
ctx.save();
ctx.scale(1, s);
}
ctx.beginPath();
ctx.arc(p.x, p.y / s, r, 0, Math.PI * 2, false);

if (s !== 1) {
ctx.restore();
}

this._fillStroke(ctx, layer);
}
}
});
Loading

0 comments on commit e46978e

Please sign in to comment.