route-plan.tsx
1.06 KB
import * as React from "react";
import { requireNativeComponent } from "react-native";
import Component from "../component";
// @ts-ignore
import resolveAssetSource from "react-native/Libraries/Image/resolveAssetSource";
import { RouteProps, LatLng, RouteType } from "../types";
export default class extends Component<RouteProps> {
name = name;
static defaultProps = { width: 8, throughPointVisible: true, type: RouteType.DRIVE };
/**
* 路线规划
*/
public routePlan(start: LatLng, end: LatLng, throughPointList: LatLng[] = []) {
this.invoke("searchRoute", [start, end, throughPointList]);
}
render() {
const props = {
...this.props,
};
return (
<NativeRoutePlan
{...props}
startIcon={resolveAssetSource(props.startIcon)}
endIcon={resolveAssetSource(props.endIcon)}
throughPointIcon={resolveAssetSource(props.throughPointIcon)}
roadLine={resolveAssetSource(props.roadLine)}
/>
);
}
}
const name = "RoutePlan";
const NativeRoutePlan = requireNativeComponent<RouteProps>(name);