import React from 'react'; import { SafeAreaView, ScrollView, StatusBar, StyleSheet, Text, Image, TouchableOpacity, View, DeviceEventEmitter, } from 'react-native'; //@ts-ignore import MapboxGL from 'fengsheng-rnmaps'; import { BjTypeImage, BjTypeMapConfig, BjTypeMapMarker, BjTypeResearchNameDict } from './../../utils/types'; import { colors, px2dp } from './../../utils'; import redux from './../../redux/store'; interface Props { marker: BjTypeMapMarker zoomLevel: number customKey: string } interface State { } export default class CustomMarker extends React.Component { constructor(props: Props) { super(props); }; public markerRef = null; public readonly state: Readonly = { }; getIconUrl() { const { marker } = this.props; let url = './../../assets/icons/research-icon-1.png'; let nameText = ""; let tintColor = "#ffc000" switch (marker.researchType) { case 'communityProfileResearch': url = require('./../../assets/icons/research-icon-1.png'); tintColor = "#6df90d" break; case 'actualMeasurementResearch': url = require('./../../assets/icons/research-icon-2.png'); // nameText = '森'; tintColor = "#6df90d" break; case 'sampleLineResearch': url = require('./../../assets/icons/research-icon-3.png'); // nameText = '灌'; tintColor = "#6df90d" break; case 'sampleSquareResearch': url = require('./../../assets/icons/research-icon-4.png'); // nameText = '草'; tintColor = "#6df90d" break; default: break; } return { icon: url, nameText, tintColor } } showResearchData() { const { marker, customKey } = this.props; console.log("marker----->", marker); DeviceEventEmitter.emit('on-press-research-marker', { screen: customKey, researchMarker: marker }) }; render() { // const initDateNs = new Date().getTime(); const { tintColor = colors.greenTextColor, icon = require('./../../assets/icons/research-icon-1.png'), nameText } = this.getIconUrl(); console.log("url", icon) const { marker, zoomLevel } = this.props; console.log("zoomLevel----->", zoomLevel) const mapConfig: BjTypeMapConfig = redux.getState().mapConfig; // const { selected } = this.state; return ( <> { alert("1") }} > { icon ? : null } { nameText ? {nameText} : null } { mapConfig && mapConfig.showResearchDataLabel ? 16 ? [marker.longitude, marker.latitude] : [0, 0]} > {marker.serialNumberAndCode} : null } { mapConfig && mapConfig.showResearchDataLabel && marker.rowList && marker.rowList.length ? 16 ? marker.rowList : [], }, }} > : null } { mapConfig && mapConfig.showResearchDataLabel && marker.rowList && marker.rowList.length && zoomLevel > 16 ? marker.rowList.map((rowPoint, rowIndex) => { return ( {/* */} ) }) : null } ) } } const styles = StyleSheet.create({ testMarker: { // position: 'relative', width: px2dp(42), height: px2dp(48), justifyContent: 'center', alignItems: 'center', }, markerInnerContainer: { position: 'relative', width: px2dp(96), height: px2dp(56), backgroundColor: 'rgba(0,0,0,0)', // backgroundColor: 'rgba(0,0,0,1)', justifyContent: 'flex-start', alignItems: 'center', overflow: 'visible', }, touchableContainer: { position: 'absolute', width: px2dp(48), height: px2dp(48), // backgroundColor: 'red', zIndex: 999, opacity: 0.6 }, touchableContent: { width: '100%', height: '100%' }, markerContent: { position: 'absolute', top: px2dp(5), left: px2dp(9), width: px2dp(30), height: px2dp(30), backgroundColor: '#fff', justifyContent: 'center', alignItems: 'center', zIndex: 999, borderRadius: px2dp(15), // overflow: 'visible' }, icon: { width: px2dp(24), height: px2dp(24) }, nameTextContainer: { position: 'absolute', bottom: px2dp(24), width: px2dp(32), height: px2dp(20), justifyContent: 'center', alignItems: 'center', // backgroundColor: 'red', zIndex: 999, }, researchCodeLine: { position: 'absolute', bottom: 0, left: 0, width: px2dp(96), height: px2dp(18), // backgroundColor: 'blue', justifyContent: 'center', alignItems: 'center', zIndex: 998 }, });