mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
add type for leaflet-gpx (#20015)
This commit is contained in:
parent
172dd79c16
commit
2da08c2f7a
70
types/leaflet-gpx/index.d.ts
vendored
Normal file
70
types/leaflet-gpx/index.d.ts
vendored
Normal file
@ -0,0 +1,70 @@
|
||||
// Type definitions for leaflet-polylinedecorator 1.1
|
||||
// Project: https://github.com/bbecquet/Leaflet.PolylineDecorator#readme
|
||||
// Definitions by: Viktor Soucek <https://github.com/soucekv>
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
27
types/leaflet-gpx/leaflet-gpx-tests.ts
Normal file
27
types/leaflet-gpx/leaflet-gpx-tests.ts
Normal file
@ -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 = '© <a href="http://openstreetmap.org/copyright">OpenStreetMap</a> 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(
|
||||
'<?xml version="1.0" encoding="UTF-8"?>\
|
||||
<gpx creator="Garmin Connect" version="1.1" xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/11.xsd" \
|
||||
xmlns="http://www.topografix.com/GPX/1/1" \
|
||||
xmlns:ns3="http://www.garmin.com/xmlschemas/TrackPointExtension/v1" \
|
||||
xmlns:ns2="http://www.garmin.com/xmlschemas/GpxExtensions/v3" \
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">\
|
||||
<metadata><link href="connect.garmin.com"><text>Garmin Connect</text></link><time>2017-09-12T18:02:33.000Z</time>\
|
||||
</metadata><trk><name>Villefontaine Course à pied</name><type>running</type><trkseg>\
|
||||
<trkpt lat="45.6159922666847705841064453125" lon="5.14371019788086414337158203125">\
|
||||
<ele>282.399993896484375</ele><time>2017-09-12T18:02:33.000Z</time><extensions>\
|
||||
<ns3:TrackPointExtension><ns3:cad>58</ns3:cad></ns3:TrackPointExtension></extensions></trkpt>\
|
||||
<trkpt lat="45.61599235050380229949951171875" lon="5.1437102816998958587646484375">\
|
||||
<ele>282.399993896484375</ele><time>2017-09-12T18:02:34.000Z</time><extensions><ns3:TrackPointExtension><ns3:cad>58</ns3:cad>\
|
||||
</ns3:TrackPointExtension></extensions></trkpt><trkpt lat="45.6161034107208251953125" lon="5.14358597807586193084716796875">\
|
||||
<ele>282</ele><time>2017-09-12T18:03:44.000Z</time><extensions><ns3:TrackPointExtension><ns3:cad>58</ns3:cad></ns3:TrackPointExtension></extensions>\
|
||||
</trkpt></trkseg></trk></gpx>',
|
||||
{ async: true })
|
||||
.on('loaded', (e: any) => {
|
||||
map.fitBounds(e.target.getBounds());
|
||||
}).addTo(map);
|
||||
22
types/leaflet-gpx/tsconfig.json
Normal file
22
types/leaflet-gpx/tsconfig.json
Normal file
@ -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"
|
||||
]
|
||||
}
|
||||
1
types/leaflet-gpx/tslint.json
Normal file
1
types/leaflet-gpx/tslint.json
Normal file
@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Loading…
Reference in New Issue
Block a user