react-native-anavi
Version:
react native amap navigation component, Android + iOS
121 lines (100 loc) • 3.49 kB
JavaScript
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
import React from 'react';
import { number, string, oneOfType, bool, object, arrayOf } from 'prop-types';
import { ViewPropTypes, requireNativeComponent, Platform, Image } from 'react-native';
import Component from '../map-view/component';
import { mapEventsPropType, NaviLatLngPropType, DriveNaviPointPropType, NaviPoiPropType, NaviTrackingModePropType } from '../prop-types';
const events = ['onInitNaviFailure', 'onInitNaviSuccess', 'onStartNavi', 'onLocationChange', 'onGetNavigationText', 'onEndEmulatorNavi', 'onCalculateRouteFailure', 'onArrivedWayPoint', 'onGpsStatusChanged', 'onCalculateRouteSuccess', 'onPlayRing', 'onNaviSettingChanged', 'onNaviCancel', 'onNaviComplete', 'onNaviViewLoaded', 'onNaviBackClick', 'onScanViewButtonClick', 'onNaviMapModeChanged', 'onNaviMapViewModeChanged', 'onNaviMapViewTrackingModeChanged', 'onLockMap'];
export class DriveNaviView extends Component {
constructor(...args) {
super(...args);
_defineProperty(this, "nativeComponent", 'ADriveNaviView');
}
startNavi(type, speed) {
this.call('startNavi', [type, speed || 60]);
}
stopNavi() {
this.call('stopNavi', []);
}
pauseNavi() {
this.call('puaseNavi', []);
}
resumeNavi() {
this.call('resumeNavi', []);
}
startGPS(time, dis) {
this.call('startPGS', [time, dis]);
}
stopGPS() {
this.call('stopGPS', []);
}
render() {
let {
from,
to,
wayPoints,
strategy,
...restProps
} = this.props;
if (from && !Array.isArray(from) && Platform.OS === 'ios') {
from = [from];
}
if (to && !Array.isArray(to) && Platform.OS === 'ios') {
to = [to];
}
if (from && Array.isArray(from) && Platform.OS === 'android') {
from = from[0];
}
if (to && Array.isArray(to) && Platform.OS === 'android') {
to = to[0];
}
const props = { ...restProps,
...this.handlers(events),
navi: {
from,
to,
wayPoints,
strategy
}
};
for (let k in props) {
if (k.indexOf('Icon') > -1) {
props[k] = Image.resolveAssetSource(props[k]);
}
}
return /*#__PURE__*/React.createElement(ADriveNaviView, props);
}
} // @ts-ignore
_defineProperty(DriveNaviView, "propTypes", { ...ViewPropTypes,
...mapEventsPropType(events),
from: DriveNaviPointPropType,
to: DriveNaviPointPropType.isRequired,
wayPoints: oneOfType([arrayOf(string), arrayOf(NaviLatLngPropType), arrayOf(NaviPoiPropType)]),
strategy: number,
layoutVisible: bool,
autoChangeZoom: bool,
autoDayNightMode: bool,
cameraBubbleVisible: bool,
compassVisible: bool,
leaderLineColor: string,
turnArrowVisible: bool,
screenAlwaysBright: bool,
browseButtonVisible: bool,
moreButtonVisible: bool,
tilt: number,
trafficBarVisible: bool,
trafficButtonVisible: bool,
trafficLineVisible: bool,
carMarkerIcon: object,
startMarkerIcon: object,
endMarkerIcon: object,
wayMarkerIcon: object,
fourCornersIcon: object,
showMode: number,
trackingMode: NaviTrackingModePropType
});
_defineProperty(DriveNaviView, "defaultProps", {
strategy: 10 // 单路径
});
const ADriveNaviView = requireNativeComponent('ADriveNaviView', DriveNaviView);
//# sourceMappingURL=drive-navi.js.map