Files
react-native-mapbox-gl/javascript/components/MapView.js
T

76 lines
1.4 KiB
JavaScript
Raw Normal View History

2017-08-22 17:22:40 -07:00
import React from 'react';
import PropTypes from 'prop-types';
import { requireNativeComponent } from 'react-native';
const RCTMGLMapView = requireNativeComponent('RCTMGLMapView', MapView);
const DEFAULT_CENTER_COORDINATE = {
type: 'Point',
2017-08-24 13:17:22 -07:00
coordinates: [-77.036086, 38.910233],
};
2017-08-22 17:22:40 -07:00
2017-08-24 13:17:22 -07:00
/**
* MapView backed by Mapbox Native GL
*/
2017-08-22 17:22:40 -07:00
class MapView extends React.Component {
static StyleURL = {
Street: 'mapbox-streets',
Dark: 'mapbox-dark',
Light: 'mapbox-light',
Outdoors: 'mapbox-outdoors',
2017-08-24 13:17:22 -07:00
Satellite: 'mapbox-satellite',
};
2017-08-22 17:22:40 -07:00
static propTypes = {
2017-08-24 13:17:22 -07:00
/**
* Animates changes between pitch and bearing
*/
2017-08-22 17:22:40 -07:00
animated: PropTypes.bool,
2017-08-24 13:17:22 -07:00
/**
* Initial center coordinate on map
*/
2017-08-22 17:22:40 -07:00
centerCoordinate: PropTypes.object,
2017-08-24 13:17:22 -07:00
/**
* Initial heading on map
*/
2017-08-22 17:22:40 -07:00
heading: PropTypes.number,
2017-08-24 13:17:22 -07:00
/**
* Initial pitch on map
*/
pitch: PropTypes.number,
/**
* Style for wrapping React Native View
*/
2017-08-22 17:22:40 -07:00
style: PropTypes.any,
2017-08-24 13:17:22 -07:00
/**
* Style URL for map
*/
2017-08-22 17:22:40 -07:00
styleURL: PropTypes.string,
2017-08-24 13:17:22 -07:00
/**
* Initial zoom level of map
*/
zoomLevel: PropTypes.number,
2017-08-22 17:22:40 -07:00
};
static defaultProps = {
animated: true,
centerCoordinate: DEFAULT_CENTER_COORDINATE,
heading: 0,
pitch: 0,
zoomLevel: 16,
2017-08-24 13:17:22 -07:00
styleURL: MapView.StyleURL.Street,
2017-08-22 17:22:40 -07:00
};
render () {
return <RCTMGLMapView {...this.props} />;
}
}
export default MapView;