/**
* 地图聚合组件
* @邠心vbe on 2021/08/13
*/
import React, { useState } from 'react';
import { Image, ImageBackground, StyleSheet, Text } from 'react-native';
import { Marker } from 'react-native-maps';
export const MyMarker = ({id, coordinate, onPress}) => {
const [tracksViewChanges, setTracksViewChanges] = useState(true);
const onImageLoad = () => {
// 图片加载完成后关闭 tracksViewChanges 以提升性能
setTimeout(() => setTracksViewChanges(false), 100);
};
if (coordinate.upcoming) {
return (
)
} else {
return (
{ coordinate.hasLabel &&
}
{ coordinate.favorite
? coordinate.available
?
:
: coordinate.available
?
:
}
)
}
}
export const MyCluster = (props) => {
const {id, location, properties, onPress, available=false, onOpen} = props;
const pointCount = props.pointCount ? props.pointCount : properties.point_count
const [tracksViewChanges, setTracksViewChanges] = useState(true);
//console.log('renderCluster', props);
return (
onOpen ? onOpen(location, id) : onPress()}>
setTimeout(() => setTracksViewChanges(false), 100)}
/>
);
}
export const ClusterView = ({pointCount, available=false, onLoad}) => {
const getStyle = (count) => {
if (count >= 100) {
return [ui.flexcc, styles.large];
} else if (count >= 10) {
return [ui.flexcc, styles.middle];
} else {
return [ui.flexcc, styles.small];
}
}
return (
{pointCount}
);
}
const styles = StyleSheet.create({
marker: {
width: 48,
height: 48
},
markerTop: {
width: 24,
height: 24,
marginBottom: -2
},
small: {
width: 48,
height: 48
},
middle: {
width: 50,
height: 50
},
large: {
width: 52,
height: 52
},
textAvailable: {
color: textLight,
fontSize: 18,
fontWeight: 'bold',
paddingBottom: 10
},
textUnavailable: {
color: '#999',
fontSize: 18,
fontWeight: 'bold',
paddingBottom: 10
}
})