Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 21 additions & 29 deletions __example/App.js
Original file line number Diff line number Diff line change
@@ -1,32 +1,26 @@
var React = require('react');
var ReactNative = require('react-native');
var {
import React from 'react';
import {
View,
StyleSheet,
TouchableOpacity,
ScrollView,
Text,
} = ReactNative;
var DisplayLatLng = require('./examples/DisplayLatLng');
var ViewsAsMarkers = require('./examples/ViewsAsMarkers');
var EventListener = require('./examples/EventListener');
var MarkerTypes = require('./examples/MarkerTypes');
var DraggableMarkers = require('./examples/DraggableMarkers');
var PolygonCreator = require('./examples/PolygonCreator');
var AnimatedViews = require('./examples/AnimatedViews');
var AnimatedMarkers = require('./examples/AnimatedMarkers');
var Callouts = require('./examples/Callouts');
var Overlays = require('./examples/Overlays');
var DefaultMarkers = require('./examples/DefaultMarkers');
} from 'react-native';
import DisplayLatLng from './examples/DisplayLatLng';
import ViewsAsMarkers from './examples/ViewsAsMarkers';
import EventListener from './examples/EventListener';
import MarkerTypes from './examples/MarkerTypes';
import DraggableMarkers from './examples/DraggableMarkers';
import PolygonCreator from './examples/PolygonCreator';
import AnimatedViews from './examples/AnimatedViews';
import AnimatedMarkers from './examples/AnimatedMarkers';
import Callouts from './examples/Callouts';
import Overlays from './examples/Overlays';
import DefaultMarkers from './examples/DefaultMarkers';


var App = React.createClass({

getInitialState() {
return { Component: null };
},

renderExample([Component, title], i) {
export default class App extends React.Compoennt{
renderExample([Component, title], i) {
return (
<TouchableOpacity
key={i}
Expand All @@ -36,7 +30,7 @@ var App = React.createClass({
<Text>{title}</Text>
</TouchableOpacity>
);
},
}

renderBackButton() {
return (
Expand All @@ -47,7 +41,7 @@ var App = React.createClass({
<Text style={{ fontWeight: 'bold', fontSize: 30 }}>&larr;</Text>
</TouchableOpacity>
);
},
}

renderExamples(examples) {
var { Component } = this.state;
Expand All @@ -64,7 +58,7 @@ var App = React.createClass({
)}
</View>
);
},
}

render() {
return this.renderExamples([
Expand All @@ -80,8 +74,8 @@ var App = React.createClass({
[Overlays, 'Circles, Polygons, and Polylines'],
[DefaultMarkers, 'Default Markers'],
]);
},
});
}
}

var styles = StyleSheet.create({
container: {
Expand Down Expand Up @@ -117,5 +111,3 @@ var styles = StyleSheet.create({
justifyContent: 'center',
},
});

module.exports = App;
24 changes: 11 additions & 13 deletions __example/examples/AnimatedMarkers.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
var React = require('react-native');
var {
import React from 'react';
import {
StyleSheet,
PropTypes,
View,
Expand All @@ -8,7 +8,7 @@ var {
TouchableOpacity,
Animated,
Platform,
} = React;
} from 'react-native';

import MapView from 'react-native-amap-view'

Expand All @@ -20,23 +20,24 @@ const LONGITUDE = -122.4324;
const LATITUDE_DELTA = 0.0922;
const LONGITUDE_DELTA = LATITUDE_DELTA * ASPECT_RATIO;

var AnimatedMarkers = React.createClass({
getInitialState() {
return {
export default class AnimatedMarkers extends React.Component {
constructor(props) {
super(props);
this.state = {
coordinate: new Animated.Region({
latitude: LATITUDE,
longitude: LONGITUDE,
}),
};
},
}

animate() {
var { coordinate } = this.state;
coordinate.timing({
latitude: LATITUDE + (Math.random() - 0.5) * LATITUDE_DELTA / 2,
longitude: LONGITUDE + (Math.random() - 0.5) * LONGITUDE_DELTA / 2,
}).start();
},
}

render() {
return (
Expand All @@ -61,9 +62,8 @@ var AnimatedMarkers = React.createClass({
</View>
</View>
);
},
});

}
};


var styles = StyleSheet.create({
Expand Down Expand Up @@ -106,5 +106,3 @@ var styles = StyleSheet.create({
backgroundColor: 'transparent',
},
});

module.exports = AnimatedMarkers;
22 changes: 11 additions & 11 deletions __example/examples/AnimatedPriceMarker.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React, {
import React from 'react';
import {
StyleSheet,
PropTypes,
View,
Expand All @@ -7,7 +8,6 @@ import React, {
} from 'react-native';

const PriceMarker = ({ amount, selected, style }) => {

var background = selected.interpolate({
inputRange: [0, 1],
outputRange: ['#FF5A5F', '#4da2ab'],
Expand All @@ -21,19 +21,19 @@ const PriceMarker = ({ amount, selected, style }) => {
return (
<Animated.View style={[styles.container, style]}>
<Animated.View style={[styles.bubble, {
backgroundColor: background,
borderColor: border,
}]}
>
backgroundColor: background,
borderColor: border,
}]}
>
<Text style={styles.dollar}>$</Text>
<Text style={styles.amount}>{amount}</Text>
</Animated.View>
<Animated.View style={[styles.arrowBorder, {
borderTopColor: border,
}]} />
borderTopColor: border,
}]} />
<Animated.View style={[styles.arrow, {
borderTopColor: background,
}]} />
borderTopColor: background,
}]} />
</Animated.View>
);
};
Expand Down Expand Up @@ -96,4 +96,4 @@ const styles = StyleSheet.create({
},
});

module.exports = PriceMarker;
export default PriceMarker;
35 changes: 16 additions & 19 deletions __example/examples/AnimatedViews.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
var React = require('react-native');
var {
import React from 'react';
import {
StyleSheet,
PropTypes,
View,
Expand All @@ -8,7 +8,7 @@ var {
TouchableOpacity,
Animated,
Platform,
} = React;
} from 'react-native';

import MapView from 'react-native-amap-view'
var PanController = require('./PanController');
Expand All @@ -33,8 +33,9 @@ var BREAKPOINT2 = 350;

const ANDROID = Platform.OS === 'android';

var AnimatedViews = React.createClass({
getInitialState() {
export default class AnimatedViews extends React.Component {
constructor(props) {
super(props);
const panX = new Animated.Value(0);
const panY = new Animated.Value(0);

Expand Down Expand Up @@ -182,7 +183,7 @@ var AnimatedViews = React.createClass({
};
});

return {
this.state = {
panX,
panY,
animations,
Expand All @@ -200,7 +201,7 @@ var AnimatedViews = React.createClass({
longitudeDelta: LONGITUDE_DELTA,
}),
};
},
}

componentDidMount() {
var { region, panX, panY, scrollX, markers } = this.state;
Expand All @@ -220,7 +221,7 @@ var AnimatedViews = React.createClass({
}),
duration: 0,
}).start();
},
}

onStartShouldSetPanResponder(e) {
// we only want to move the view if they are starting the gesture on top
Expand All @@ -232,7 +233,7 @@ var AnimatedViews = React.createClass({
var topOfTap = screen.height - pageY;

return topOfTap < topOfMainWindow;
},
}

onMoveShouldSetPanResponder(e) {
var { panY } = this.state;
Expand All @@ -241,15 +242,15 @@ var AnimatedViews = React.createClass({
var topOfTap = screen.height - pageY;

return topOfTap < topOfMainWindow;
},
}

onPanXChange({ value }) {
var { index, region, panX, markers } = this.state;
var newIndex = Math.floor((-1 * value + SNAP_WIDTH / 2) / SNAP_WIDTH);
if (index !== newIndex) {
this.setState({ index: newIndex });
}
},
}

onPanYChange({ value }) {
var { canMoveHorizontal, region, scrollY, scrollX, markers, index } = this.state;
Expand Down Expand Up @@ -292,11 +293,11 @@ var AnimatedViews = React.createClass({
}).start();
}
}
},
}

onRegionChange(region) {
//this.state.region.setValue(region);
},
}

render() {
const {
Expand Down Expand Up @@ -382,10 +383,8 @@ var AnimatedViews = React.createClass({
</PanController>
</View>
);
},
});


}
};

var styles = StyleSheet.create({
container: {
Expand Down Expand Up @@ -422,5 +421,3 @@ var styles = StyleSheet.create({
borderColor: '#000',
},
});

module.exports = AnimatedViews;
20 changes: 9 additions & 11 deletions __example/examples/Callouts.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
var React = require('react-native');
var {
import React from 'react';
import {
StyleSheet,
PropTypes,
View,
Text,
Dimensions,
TouchableOpacity,
Image,
} = React;
} from 'react-native';

import MapView from 'react-native-amap-view'
var PriceMarker = require('./PriceMarker');
Expand All @@ -22,7 +22,7 @@ const LATITUDE_DELTA = 0.0922;
const LONGITUDE_DELTA = LATITUDE_DELTA * ASPECT_RATIO;
const SPACE = 0.01;

var Callouts = React.createClass({
export default class Callouts extends React.Component {
getInitialState() {
return {
region: {
Expand Down Expand Up @@ -52,15 +52,15 @@ var Callouts = React.createClass({
},
],
};
},
}

show() {
this.refs.m1.showCallout();
},
}

hide() {
this.refs.m1.hideCallout();
},
}

render() {
const { region, markers } = this.state;
Expand Down Expand Up @@ -111,8 +111,8 @@ var Callouts = React.createClass({
</View>
</View>
);
},
});
}
};

var styles = StyleSheet.create({
container: {
Expand Down Expand Up @@ -154,5 +154,3 @@ var styles = StyleSheet.create({
backgroundColor: 'transparent',
},
});

module.exports = Callouts;
Loading