@opentripplanner/trip-viewer-overlay 1.1.1 → 2.0.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm/index.js +58 -92
- package/esm/index.js.map +1 -1
- package/lib/index.d.ts +18 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +67 -74
- package/lib/index.js.map +1 -1
- package/package.json +6 -6
- package/src/{TripViewerOverlay.story.js → TripViewerOverlay.story.tsx} +7 -8
- package/src/index.tsx +62 -0
- package/tsconfig.json +15 -0
- package/tsconfig.tsbuildinfo +3680 -0
- package/src/index.js +0 -70
package/src/index.js
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import coreUtils from "@opentripplanner/core-utils";
|
|
2
|
-
import PropTypes from "prop-types";
|
|
3
|
-
import React from "react";
|
|
4
|
-
import { FeatureGroup, MapLayer, Polyline, withLeaflet } from "react-leaflet";
|
|
5
|
-
|
|
6
|
-
import polyline from "@mapbox/polyline";
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* An overlay that will display the geometry of a trip.
|
|
10
|
-
*/
|
|
11
|
-
class TripViewerOverlay extends MapLayer {
|
|
12
|
-
componentDidMount() {}
|
|
13
|
-
|
|
14
|
-
// TODO: determine why the default MapLayer componentWillUnmount() method throws an error
|
|
15
|
-
componentWillUnmount() {}
|
|
16
|
-
|
|
17
|
-
componentDidUpdate(prevProps) {
|
|
18
|
-
const oldGeometry = prevProps.tripData && prevProps.tripData.geometry;
|
|
19
|
-
const newGeometry = this.props.tripData && this.props.tripData.geometry;
|
|
20
|
-
if (oldGeometry === newGeometry || !newGeometry) return;
|
|
21
|
-
const pts = polyline.decode(newGeometry.points);
|
|
22
|
-
this.props.leaflet.map.fitBounds(pts);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
createLeafletElement() {}
|
|
26
|
-
|
|
27
|
-
updateLeafletElement() {}
|
|
28
|
-
|
|
29
|
-
render() {
|
|
30
|
-
const { leafletPath, tripData } = this.props;
|
|
31
|
-
|
|
32
|
-
if (!tripData || !tripData.geometry) return <FeatureGroup />;
|
|
33
|
-
|
|
34
|
-
const pts = polyline.decode(tripData.geometry.points);
|
|
35
|
-
return (
|
|
36
|
-
<FeatureGroup>
|
|
37
|
-
{/* eslint-disable-next-line react/jsx-props-no-spreading */}
|
|
38
|
-
<Polyline {...leafletPath} positions={pts} />
|
|
39
|
-
</FeatureGroup>
|
|
40
|
-
);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
TripViewerOverlay.propTypes = {
|
|
45
|
-
/**
|
|
46
|
-
* Leaflet path properties to use to style the polyline that represents the
|
|
47
|
-
* trip.
|
|
48
|
-
*
|
|
49
|
-
* See https://leafletjs.com/reference-1.6.0.html#path
|
|
50
|
-
*/
|
|
51
|
-
leafletPath: coreUtils.types.leafletPathType,
|
|
52
|
-
/**
|
|
53
|
-
* This represents data about a trip as obtained from a transit index.
|
|
54
|
-
* Typically a trip has more data than these items, so this is only a list of
|
|
55
|
-
* the properties that this component actually uses.
|
|
56
|
-
*/
|
|
57
|
-
tripData: PropTypes.shape({
|
|
58
|
-
geometry: coreUtils.types.encodedPolylineType
|
|
59
|
-
})
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
TripViewerOverlay.defaultProps = {
|
|
63
|
-
leafletPath: {
|
|
64
|
-
color: "#00bfff",
|
|
65
|
-
opacity: 0.6,
|
|
66
|
-
weight: 8
|
|
67
|
-
}
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
export default withLeaflet(TripViewerOverlay);
|