Sha256: fa4d5f6f2c28dfbc9fca773e06079d2f3eaf5e23e9a1a773378aabb1446a40d9
Contents?: true
Size: 775 Bytes
Versions: 3
Compression:
Stored size: 775 Bytes
Contents
L.Polygon.include(!L.Path.CANVAS ? {} : { _containsPoint: function (p) { var inside = false, part, p1, p2, i, j, k, len, len2; // TODO optimization: check if within bounds first if (L.Polyline.prototype._containsPoint.call(this, p, true)) { // click on polygon border return true; } // ray casting algorithm for detecting if point is in polygon for (i = 0, len = this._parts.length; i < len; i++) { part = this._parts[i]; for (j = 0, len2 = part.length, k = len2 - 1; j < len2; k = j++) { p1 = part[j]; p2 = part[k]; if (((p1.y > p.y) !== (p2.y > p.y)) && (p.x < (p2.x - p1.x) * (p.y - p1.y) / (p2.y - p1.y) + p1.x)) { inside = !inside; } } } return inside; } });
Version data entries
3 entries across 3 versions & 1 rubygems