import * as WebBrowser from 'expo-web-browser'; import * as React from 'react'; import { Div, Image, Text } from 'react-native-magnus'; import useModel from 'flooks'; import { useRequest, useCreation } from '@umijs/hooks'; import MapModel from './model'; // detail模块通用方法 export default function MapMarkImg({ imgType, info, label }) { const { personImg, merchatImg, riderImg } = useModel(MapModel, []); const { merLocation, location, merShowName, riderLocation } = info; const merLocations = merLocation ? merLocation.split(',') : []; const locations = location ? location.split(',') : []; const ridLocations = riderLocation ? riderLocation.split(',') : []; const persoMark = locations.length > 0 ? `markers=icon:${personImg}%7C${locations[1]},${locations[0]}` : ''; const merchatMark = merLocation.length > 0 ? `markers=icon:${merchatImg}%7C${merLocations[1]},${merLocations[0]}` : ''; const riderMark = ridLocations.length > 0 ? `markers=icon:${riderImg}%7C${ridLocations[1]},${ridLocations[0]}` : ''; const markers = useCreation(() => { const str = ''; let list = []; switch (imgType) { case 'rider': list.push(riderMark); list.push(merchatMark); list.push(persoMark); break; case 'merchant': list.push(merchatMark); list.push(riderMark); list.push(persoMark); break; default: list.push(persoMark); list.push(riderMark); list.push(merchatMark); break; } list = list.filter((item) => { return !!item; }); return list.length > 0 ? `&${list.join('&')}` : str; }, [persoMark, merchatMark, riderMark, info, imgType]); const center = useCreation(() => { let str = ''; switch (imgType) { case 'rider': str = '31.982155,118.734716'; break; case 'merchant': str = `${merLocations[1]},${merLocations[0]}`; break; default: str = `${merLocations[1]},${merLocations[0]}`; break; } return str; }, [persoMark, merchatMark, riderMark, info, imgType]); return ( <>