mirror of
https://github.com/expo/react-native-maps.git
synced 2026-11-15 09:18:08 -10:00
223 lines
3.6 KiB
JavaScript
223 lines
3.6 KiB
JavaScript
import React from 'react';
|
|
import {
|
|
StyleSheet,
|
|
View,
|
|
Dimensions,
|
|
} from 'react-native';
|
|
|
|
import MapView, { ProviderPropType } from 'react-native-maps';
|
|
|
|
const { width, height } = Dimensions.get('window');
|
|
|
|
const ASPECT_RATIO = width / height;
|
|
const LATITUDE = 37.78825;
|
|
const LONGITUDE = -122.4324;
|
|
const LATITUDE_DELTA = 0.0922;
|
|
const LONGITUDE_DELTA = LATITUDE_DELTA * ASPECT_RATIO;
|
|
|
|
const customStyle = [
|
|
{
|
|
elementType: 'geometry',
|
|
stylers: [
|
|
{
|
|
color: '#242f3e',
|
|
},
|
|
],
|
|
},
|
|
{
|
|
elementType: 'labels.text.fill',
|
|
stylers: [
|
|
{
|
|
color: '#746855',
|
|
},
|
|
],
|
|
},
|
|
{
|
|
elementType: 'labels.text.stroke',
|
|
stylers: [
|
|
{
|
|
color: '#242f3e',
|
|
},
|
|
],
|
|
},
|
|
{
|
|
featureType: 'administrative.locality',
|
|
elementType: 'labels.text.fill',
|
|
stylers: [
|
|
{
|
|
color: '#d59563',
|
|
},
|
|
],
|
|
},
|
|
{
|
|
featureType: 'poi',
|
|
elementType: 'labels.text.fill',
|
|
stylers: [
|
|
{
|
|
color: '#d59563',
|
|
},
|
|
],
|
|
},
|
|
{
|
|
featureType: 'poi.park',
|
|
elementType: 'geometry',
|
|
stylers: [
|
|
{
|
|
color: '#263c3f',
|
|
},
|
|
],
|
|
},
|
|
{
|
|
featureType: 'poi.park',
|
|
elementType: 'labels.text.fill',
|
|
stylers: [
|
|
{
|
|
color: '#6b9a76',
|
|
},
|
|
],
|
|
},
|
|
{
|
|
featureType: 'road',
|
|
elementType: 'geometry',
|
|
stylers: [
|
|
{
|
|
color: '#38414e',
|
|
},
|
|
],
|
|
},
|
|
{
|
|
featureType: 'road',
|
|
elementType: 'geometry.stroke',
|
|
stylers: [
|
|
{
|
|
color: '#212a37',
|
|
},
|
|
],
|
|
},
|
|
{
|
|
featureType: 'road',
|
|
elementType: 'labels.text.fill',
|
|
stylers: [
|
|
{
|
|
color: '#9ca5b3',
|
|
},
|
|
],
|
|
},
|
|
{
|
|
featureType: 'road.highway',
|
|
elementType: 'geometry',
|
|
stylers: [
|
|
{
|
|
color: '#746855',
|
|
},
|
|
],
|
|
},
|
|
{
|
|
featureType: 'road.highway',
|
|
elementType: 'geometry.stroke',
|
|
stylers: [
|
|
{
|
|
color: '#1f2835',
|
|
},
|
|
],
|
|
},
|
|
{
|
|
featureType: 'road.highway',
|
|
elementType: 'labels.text.fill',
|
|
stylers: [
|
|
{
|
|
color: '#f3d19c',
|
|
},
|
|
],
|
|
},
|
|
{
|
|
featureType: 'transit',
|
|
elementType: 'geometry',
|
|
stylers: [
|
|
{
|
|
color: '#2f3948',
|
|
},
|
|
],
|
|
},
|
|
{
|
|
featureType: 'transit.station',
|
|
elementType: 'labels.text.fill',
|
|
stylers: [
|
|
{
|
|
color: '#d59563',
|
|
},
|
|
],
|
|
},
|
|
{
|
|
featureType: 'water',
|
|
elementType: 'geometry',
|
|
stylers: [
|
|
{
|
|
color: '#17263c',
|
|
},
|
|
],
|
|
},
|
|
{
|
|
featureType: 'water',
|
|
elementType: 'labels.text.fill',
|
|
stylers: [
|
|
{
|
|
color: '#515c6d',
|
|
},
|
|
],
|
|
},
|
|
{
|
|
featureType: 'water',
|
|
elementType: 'labels.text.stroke',
|
|
stylers: [
|
|
{
|
|
color: '#17263c',
|
|
},
|
|
],
|
|
},
|
|
];
|
|
|
|
class MapStyle extends React.Component {
|
|
constructor(props) {
|
|
super(props);
|
|
|
|
this.state = {
|
|
};
|
|
}
|
|
|
|
render() {
|
|
return (
|
|
<View style={styles.container}>
|
|
<MapView
|
|
provider={this.props.provider}
|
|
style={styles.map}
|
|
initialRegion={{
|
|
latitude: LATITUDE,
|
|
longitude: LONGITUDE,
|
|
latitudeDelta: LATITUDE_DELTA,
|
|
longitudeDelta: LONGITUDE_DELTA,
|
|
}}
|
|
customMapStyle={customStyle}
|
|
/>
|
|
</View>
|
|
);
|
|
}
|
|
}
|
|
|
|
MapStyle.propTypes = {
|
|
provider: ProviderPropType,
|
|
};
|
|
|
|
const styles = StyleSheet.create({
|
|
container: {
|
|
...StyleSheet.absoluteFillObject,
|
|
justifyContent: 'flex-end',
|
|
alignItems: 'center',
|
|
},
|
|
map: {
|
|
...StyleSheet.absoluteFillObject,
|
|
},
|
|
});
|
|
|
|
export default MapStyle;
|