import React from 'react';
import MapboxGL from '@mapbox/react-native-mapbox-gl';

import BaseExamplePropTypes from './common/BaseExamplePropTypes';
import Page from './common/Page';

import sheet from '../styles/sheet';
import { SF_OFFICE_COORDINATE } from '../utils';

const layerStyles = MapboxGL.StyleSheet.create({
  singlePoint: {
    circleColor: 'green',
    circleOpacity: 0.84,
    circleStrokeWidth: 2,
    circleStrokeColor: 'white',
    circleRadius: 5,
  },

  clusteredPoints: {
    circleColor: MapboxGL.StyleSheet.source({
      25: 'yellow',
      50: 'red',
      75: 'blue',
      100: 'orange',
      300: 'pink',
      750: 'white',
    }, 'point_count', MapboxGL.InterpolationMode.Exponential),

    circleRadius: MapboxGL.StyleSheet.source({
      0: 15,
      100: 20,
      750: 30,
    }, 'point_count', MapboxGL.InterpolationMode.Exponential),

    circleOpacity: 0.84,
    circleStrokeWidth: 2,
    circleStrokeColor: 'white',
  },

  clusterCount: {
    textField: '{point_count}',
    textSize: 12,
  },
});

class EarthQuakes extends React.Component {
  static propTypes = {
    ...BaseExamplePropTypes,
  };

  render () {
    return (
      <Page {...this.props}>
        <MapboxGL.MapView
            zoomLevel={6}
            centerCoordinate={SF_OFFICE_COORDINATE}
            style={sheet.matchParent}
            styleURL={MapboxGL.StyleURL.Dark}>

            <MapboxGL.ShapeSource
              id='earthquakes'
              cluster
              clusterRadius={50}
              clusterMaxZoom={14}
              url='https://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/all_week.geojson'>

              <MapboxGL.SymbolLayer
                id='pointCount'
                style={layerStyles.clusterCount} />

              <MapboxGL.CircleLayer
                id='clusteredPoints'
                belowLayerID='pointCount'
                filter={['has', 'point_count']}
                style={layerStyles.clusteredPoints} />

              <MapboxGL.CircleLayer
                id='singlePoint'
                filter={['!has', 'point_count']}
                style={layerStyles.singlePoint} />

            </MapboxGL.ShapeSource>
        </MapboxGL.MapView>
      </Page>
    );
  }
}

export default EarthQuakes;

@@ -466,32 +466,154 @@
 ,%0A  
-%7D,%0A%0A  clusteredPoints: %7B
+  circlePitchAlignment: MapboxGL.CirclePitchAlignment.Map,%0A  %7D,%0A%0A  clusteredPoints: %7B%0A    circlePitchAlignment: MapboxGL.CirclePitchAlignment.Map,
 %0A   
@@ -1145,16 +1145,73 @@
 ze: 12,%0A
+    textPitchAlignment: MapboxGL.TextPitchAlignment.Map,%0A
   %7D,%0A%7D);
@@ -1422,16 +1422,39 @@
 vel=%7B6%7D%0A
+            pitch=%7B45%7D%0A
         

add circlePitchAlignment to cluster example