|
| 1 | +import React from 'react'; |
| 2 | +import MapboxGL from '@react-native-mapbox-gl/maps'; |
| 3 | + |
| 4 | +import sheet from '../../styles/sheet'; |
| 5 | + |
| 6 | +import BaseExamplePropTypes from '../common/BaseExamplePropTypes'; |
| 7 | +import Page from '../common/Page'; |
| 8 | + |
| 9 | +class GradientLine extends React.Component { |
| 10 | + static propTypes = { |
| 11 | + ...BaseExamplePropTypes, |
| 12 | + }; |
| 13 | + |
| 14 | + render() { |
| 15 | + return ( |
| 16 | + <Page {...this.props}> |
| 17 | + <MapboxGL.MapView style={sheet.matchParent}> |
| 18 | + <MapboxGL.Camera centerCoordinate={[-77.035, 38.875]} zoomLevel={12} /> |
| 19 | + <MapboxGL.ShapeSource id="source1" lineMetrics={true} |
| 20 | + shape={{ |
| 21 | + type: 'Feature', |
| 22 | + geometry: { |
| 23 | + type: 'LineString', |
| 24 | + coordinates: [ |
| 25 | + [-77.044211, 38.852924], |
| 26 | + [-77.045659, 38.860158], |
| 27 | + [-77.044232, 38.862326], |
| 28 | + [-77.040879, 38.865454], |
| 29 | + [-77.039936, 38.867698], |
| 30 | + [-77.040338, 38.86943], |
| 31 | + [-77.04264, 38.872528], |
| 32 | + [-77.03696, 38.878424], |
| 33 | + [-77.032309, 38.87937], |
| 34 | + [-77.030056, 38.880945], |
| 35 | + [-77.027645, 38.881779], |
| 36 | + [-77.026946, 38.882645], |
| 37 | + [-77.026942, 38.885502], |
| 38 | + [-77.028054, 38.887449], |
| 39 | + [-77.02806, 38.892088], |
| 40 | + [-77.03364, 38.892108], |
| 41 | + [-77.033643, 38.899926], |
| 42 | + ], |
| 43 | + }, |
| 44 | + }}> |
| 45 | + <MapboxGL.LineLayer id="layer1" style={{ |
| 46 | + lineColor: 'red', |
| 47 | + lineCap: "round", |
| 48 | + lineJoin: "round", |
| 49 | + lineWidth: 14, |
| 50 | + lineGradient: [ |
| 51 | + 'interpolate', |
| 52 | + ['linear'], |
| 53 | + ['line-progress'], |
| 54 | + 0, |
| 55 | + 'blue', |
| 56 | + 0.1, |
| 57 | + 'royalblue', |
| 58 | + 0.3, |
| 59 | + 'cyan', |
| 60 | + 0.5, |
| 61 | + 'lime', |
| 62 | + 0.7, |
| 63 | + 'yellow', |
| 64 | + 1, |
| 65 | + 'red' |
| 66 | + ] |
| 67 | + }} /> |
| 68 | + </MapboxGL.ShapeSource> |
| 69 | + </MapboxGL.MapView> |
| 70 | + </Page> |
| 71 | + ); |
| 72 | + } |
| 73 | +} |
| 74 | + |
| 75 | +export default GradientLine; |
0 commit comments