aboutsummaryrefslogtreecommitdiffstats
path: root/extlib/leaflet/src/layer/vector/Polygon.js
diff options
context:
space:
mode:
authorJoar Wandborg <git@wandborg.com>2012-01-28 18:47:01 +0100
committerJoar Wandborg <git@wandborg.com>2012-01-28 18:47:01 +0100
commit3d0d3bc97270095fae5f9a2508068631c46a5e61 (patch)
tree76778fcacaae35fc5662f276dab512a07bcee186 /extlib/leaflet/src/layer/vector/Polygon.js
parentd7bec8577ea1b4d83df097f586324445fed1ef50 (diff)
parent9542a2ba076b7e00e79d7adb1a4e90a095427645 (diff)
downloadmediagoblin-3d0d3bc97270095fae5f9a2508068631c46a5e61.tar.lz
mediagoblin-3d0d3bc97270095fae5f9a2508068631c46a5e61.tar.xz
mediagoblin-3d0d3bc97270095fae5f9a2508068631c46a5e61.zip
Merge remote-tracking branch 'joar/exif-rebase'
Diffstat (limited to 'extlib/leaflet/src/layer/vector/Polygon.js')
-rw-r--r--extlib/leaflet/src/layer/vector/Polygon.js58
1 files changed, 58 insertions, 0 deletions
diff --git a/extlib/leaflet/src/layer/vector/Polygon.js b/extlib/leaflet/src/layer/vector/Polygon.js
new file mode 100644
index 00000000..52bf2d6b
--- /dev/null
+++ b/extlib/leaflet/src/layer/vector/Polygon.js
@@ -0,0 +1,58 @@
+/*
+ * L.Polygon is used to display polygons on a map.
+ */
+
+L.Polygon = L.Polyline.extend({
+ options: {
+ fill: true
+ },
+
+ initialize: function(latlngs, options) {
+ L.Polyline.prototype.initialize.call(this, latlngs, options);
+
+ if (latlngs[0] instanceof Array) {
+ this._latlngs = latlngs[0];
+ this._holes = latlngs.slice(1);
+ }
+ },
+
+ projectLatlngs: function() {
+ L.Polyline.prototype.projectLatlngs.call(this);
+
+ // project polygon holes points
+ // TODO move this logic to Polyline to get rid of duplication
+ this._holePoints = [];
+
+ if (!this._holes) return;
+
+ for (var i = 0, len = this._holes.length, hole; i < len; i++) {
+ this._holePoints[i] = [];
+
+ for(var j = 0, len2 = this._holes[i].length; j < len2; j++) {
+ this._holePoints[i][j] = this._map.latLngToLayerPoint(this._holes[i][j]);
+ }
+ }
+ },
+
+ _clipPoints: function() {
+ var points = this._originalPoints,
+ newParts = [];
+
+ this._parts = [points].concat(this._holePoints);
+
+ if (this.options.noClip) return;
+
+ for (var i = 0, len = this._parts.length; i < len; i++) {
+ var clipped = L.PolyUtil.clipPolygon(this._parts[i], this._map._pathViewport);
+ if (!clipped.length) continue;
+ newParts.push(clipped);
+ }
+
+ this._parts = newParts;
+ },
+
+ _getPathPartStr: function(points) {
+ var str = L.Polyline.prototype._getPathPartStr.call(this, points);
+ return str + (L.Path.SVG ? 'z' : 'x');
+ }
+}); \ No newline at end of file