"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/layer/vector/Polyline.js" between
Leaflet-1.8.0.tar.gz and Leaflet-1.9.0.tar.gz

About: Leaflet is a JavaScript library for mobile-friendly interactive maps.

Polyline.js  (Leaflet-1.8.0):Polyline.js  (Leaflet-1.9.0)
skipping to change at line 122 skipping to change at line 122
return minPoint; return minPoint;
}, },
// @method getCenter(): LatLng // @method getCenter(): LatLng
// Returns the center ([centroid](https://en.wikipedia.org/wiki/Centroid) ) of the polyline. // Returns the center ([centroid](https://en.wikipedia.org/wiki/Centroid) ) of the polyline.
getCenter: function () { getCenter: function () {
// throws error when not yet added to map as this center calculat ion requires projected coordinates // throws error when not yet added to map as this center calculat ion requires projected coordinates
if (!this._map) { if (!this._map) {
throw new Error('Must add layer to map before using getCe nter()'); throw new Error('Must add layer to map before using getCe nter()');
} }
return LineUtil.polylineCenter(this._defaultShape(), this._map.op
var i, halfDist, segDist, dist, p1, p2, ratio, tions.crs);
points = this._rings[0],
len = points.length;
if (!len) { return null; }
// polyline centroid algorithm; only uses the first ring if there
are multiple
for (i = 0, halfDist = 0; i < len - 1; i++) {
halfDist += points[i].distanceTo(points[i + 1]) / 2;
}
// The line is so small in the current view that all points are o
n the same pixel.
if (halfDist === 0) {
return this._map.layerPointToLatLng(points[0]);
}
for (i = 0, dist = 0; i < len - 1; i++) {
p1 = points[i];
p2 = points[i + 1];
segDist = p1.distanceTo(p2);
dist += segDist;
if (dist > halfDist) {
ratio = (dist - halfDist) / segDist;
return this._map.layerPointToLatLng([
p2.x - ratio * (p2.x - p1.x),
p2.y - ratio * (p2.y - p1.y)
]);
}
}
}, },
// @method getBounds(): LatLngBounds // @method getBounds(): LatLngBounds
// Returns the `LatLngBounds` of the path. // Returns the `LatLngBounds` of the path.
getBounds: function () { getBounds: function () {
return this._bounds; return this._bounds;
}, },
// @method addLatLng(latlng: LatLng, latlngs?: LatLng[]): this // @method addLatLng(latlng: LatLng, latlngs?: LatLng[]): this
// Adds a given point to the polyline. By default, adds to the first ring of // Adds a given point to the polyline. By default, adds to the first ring of
 End of changes. 1 change blocks. 
34 lines changed or deleted 2 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)