diff --git a/types/leaflet-gpx/index.d.ts b/types/leaflet-gpx/index.d.ts new file mode 100644 index 0000000000..7eac361403 --- /dev/null +++ b/types/leaflet-gpx/index.d.ts @@ -0,0 +1,70 @@ +// Type definitions for leaflet-polylinedecorator 1.1 +// Project: https://github.com/bbecquet/Leaflet.PolylineDecorator#readme +// Definitions by: Viktor Soucek +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 + +import * as L from 'leaflet'; + +declare module 'leaflet' { + interface GPXOptions { + async?: boolean; + max_point_interval?: number; + marker_options?: MarkerOptions; + polyline_options?: PolylineOptions; + gpx_options?: { parseElements: ['track', 'route', 'waypoint'] }; + } + class GPX extends FeatureGroup { + constructor(gpx: any, options?: GPXOptions); + get_duration_string(duration: any, hidems: any): any; + get_duration_string_iso(duration: any, hidems: any): any; + to_miles(v: any): any; + to_ft(v: any): any; + m_to_km(v: any): any; + m_to_mi(v: any): any; + + get_name(): any; + get_desc(): any; + get_author(): any; + get_copyright(): any; + get_distance(): any; + get_distance_imp(): any; + + get_start_time(): any; + get_end_time(): any; + get_moving_time(): any; + get_total_time(): any; + + get_moving_pace(): any; + get_moving_pace_imp(): any; + + get_moving_speed(): any; + get_moving_speed_imp(): any; + + get_total_speed(): any; + get_total_speed_imp(): any; + + get_elevation_gain(): any; + get_elevation_loss(): any; + get_elevation_gain_imp(): any; + get_elevation_loss_imp(): any; + get_elevation_data(): any; + get_elevation_data_imp(): any; + get_elevation_max(): any; + get_elevation_min(): any; + get_elevation_max_imp(): any; + get_elevation_min_imp(): any; + + get_average_hr(): any; + get_average_temp(): any; + get_average_cadence(): any; + get_heartrate_data(): any; + get_heartrate_data_imp(): any; + get_cadence_data(): any; + get_temp_data(): any; + get_cadence_data_imp(): any; + get_temp_data_imp(): any; + + reload(): void; + } +} diff --git a/types/leaflet-gpx/leaflet-gpx-tests.ts b/types/leaflet-gpx/leaflet-gpx-tests.ts new file mode 100644 index 0000000000..342d1d00d7 --- /dev/null +++ b/types/leaflet-gpx/leaflet-gpx-tests.ts @@ -0,0 +1,27 @@ +import * as L from 'leaflet'; +import 'leaflet-gpx'; +const osmUrl = 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png'; +const osmAttrib = '© OpenStreetMap contributors'; +const osm = L.tileLayer(osmUrl, { maxZoom: 18, attribution: osmAttrib }); +const map = L.map('map', { layers: [osm], center: L.latLng(-37.7772, 175.2756), zoom: 15 }); +const gpx = new L.GPX( + '\ + \ + Garmin Connect\ + Villefontaine Course à piedrunning\ + \ + 282.399993896484375\ + 58\ + \ + 282.39999389648437558\ + \ + 28258\ + ', + { async: true }) + .on('loaded', (e: any) => { + map.fitBounds(e.target.getBounds()); + }).addTo(map); diff --git a/types/leaflet-gpx/tsconfig.json b/types/leaflet-gpx/tsconfig.json new file mode 100644 index 0000000000..68f95ad1a4 --- /dev/null +++ b/types/leaflet-gpx/tsconfig.json @@ -0,0 +1,22 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "leaflet-gpx-tests.ts" + ] +} diff --git a/types/leaflet-gpx/tslint.json b/types/leaflet-gpx/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/leaflet-gpx/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }