Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add getLatLngs method #43

Merged
merged 1 commit into from
Nov 2, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
add getLatLngs method
Quentin Pinçon committed Nov 2, 2021
commit 9148d2d41da16cc155fb36751d93f6806d01ad8d
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -70,6 +70,7 @@ The `L.Curve` class extends `L.Path` so options, events, and methods inherited f
|setPath(`pathData[]`)|`this`|Replaces the current path with the given array of commands and coordinates.|
|getPath()|`pathData[]`|Returns array of the commands and coordinates in the path.|
|setLatLngs(`pathData[]`)|`this`|Alias to method this.setPath(`pathData[]`) using the naming convention of L.Polyline and other Leaflet components.|
|getLatLngs()|`pathData[] `|Alias to method this.getPath() using the naming convention of L.Polyline and other Leaflet components.|
|trace(`samplingDistance[]`)|`latLng[]`|Returns array of points that lie on the curve at the given distances. Sampling distance is a decimal value between 0 and 1 inclusive and is applied to each segment (i.e. command) of the curve. See [DEMO] for example.|

### License
7 changes: 4 additions & 3 deletions src/leaflet.curve.js
Original file line number Diff line number Diff line change
@@ -20,18 +20,19 @@ L.Curve = L.Path.extend({
setLatLngs: function(path) {
return this.setPath(path);
},

getLatLngs: this.getPath,

_updateBounds: function() {
var tolerance = this._clickTolerance();
var tolerancePoint = new L.Point(tolerance, tolerance);

//_pxBounds is critical for canvas renderer, used to determine area that needs redrawing
this._pxBounds = new L.Bounds([
this._rawPxBounds.min.subtract(tolerancePoint),
this._rawPxBounds.max.add(tolerancePoint)
]);
},

getPath: function(){
return this._coords;
},
1 change: 1 addition & 0 deletions types/leaflet.curve.d.ts
Original file line number Diff line number Diff line change
@@ -33,6 +33,7 @@ declare module "leaflet" {
// Public functions
setPath(pathData: CurvePathData): this;
getPath(): CurvePathData;
getLatLngs(): CurvePathData;
setLatLngs(pathData: CurvePathData): this;
trace(samplingDistance: number[]): LatLng[];
}