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

47 lines
1.3 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import React from 'react';
import PropTypes from 'prop-types';
import { NativeModules, requireNativeComponent } from 'react-native';
import { cloneReactChildrenWithProps } from '../utils';
const MapboxGL = NativeModules.MGLModule;
export const NATIVE_MODULE_NAME = 'RCTMGLVectorSource';
const RCTMGLVectorSource = requireNativeComponent(NATIVE_MODULE_NAME, VectorSource);
/**
* VectorSource is a map content source that supplies tiled vector data in Mapbox Vector Tile format to be shown on the map.
* The location of and metadata about the tiles are defined either by an option dictionary or by an external file that conforms to the TileJSON specification.
*/
class VectorSource extends React.Component {
static propTypes = {
/**
* A string that uniquely identifies the source.
*/
id: PropTypes.string,
/**
* A URL to a TileJSON configuration file describing the sources contents and other metadata.
*/
url: PropTypes.string,
};
static defaultProps = {
id: MapboxGL.StyleSource.DefaultSourceID,
};
render () {
const props = {
id: this.props.id,
url: this.props.url,
};
return (
<RCTMGLVectorSource {...props}>
{cloneReactChildrenWithProps(this.props.children, { sourceID: this.props.id })}
</RCTMGLVectorSource>
);
}
}
export default VectorSource;