mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-28 09:25:50 +08:00
Create declaration file for Polyline
This commit is contained in:
16
polyline/polyline-tests.ts
Normal file
16
polyline/polyline-tests.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
/// <reference path="./polyline.d.ts" />
|
||||
|
||||
// returns an array of lat, lon pairs
|
||||
polyline.decode('_p~iF~ps|U_ulLnnqC_mqNvxq`@');
|
||||
|
||||
// returns a string-encoded polyline
|
||||
polyline.encode([[38.5, -120.2], [40.7, -120.95], [43.252, -126.453]]);
|
||||
|
||||
// returns a string-encoded polyline from a GeoJSON LineString
|
||||
polyline.fromGeoJSON({ "type": "Feature",
|
||||
"geometry": {
|
||||
"type": "LineString",
|
||||
"coordinates": [[-120.2, 38.5], [-120.95, 40.7], [-126.453, 43.252]]
|
||||
},
|
||||
"properties": {}
|
||||
});
|
||||
22
polyline/polyline.d.ts
vendored
Normal file
22
polyline/polyline.d.ts
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
// Type definitions for Polyline 0.1.0
|
||||
// Project: https://github.com/mapbox/polyline
|
||||
// Definitions by: Arseniy Maximov <https://github.com/Kern0>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
/// <reference path="../geojson/geojson.d.ts" />
|
||||
|
||||
interface NumberArray {
|
||||
[index: number]: number;
|
||||
}
|
||||
|
||||
interface Polyline {
|
||||
decode(string: string, precision?: number): NumberArray[];
|
||||
encode(coordinate: NumberArray[], precision?: number): string;
|
||||
fromGeoJSON(geojson: GeoJSON.GeoJsonObject, precision?: number): string;
|
||||
}
|
||||
|
||||
declare var polyline: Polyline;
|
||||
|
||||
declare module "polyline" {
|
||||
export = polyline;
|
||||
}
|
||||
Reference in New Issue
Block a user