import { View, Map } from '@tarojs/components'
import style from './index.module.less'

import Taro from '@tarojs/taro';
interface Props {
  children?: React.ReactChild |  React.ReactChild[];
  longitude: number
  latitude: number 
  enableZoom?: boolean
  name?: string
  address?: string
  enableScroll?: boolean
}



const Index: React.FC<Props> = ({children, latitude, longitude, name = '', address = '', enableZoom = false, enableScroll = false }) => {
  const onError = (e)=> {
    console.log(e)
  }

  // const handleClick = () => {
  //   Taro.openLocation({
  //     latitude,
  //     longitude,
  //     scale: 18,
  //     name: name,
  //     address: address,
  //   })
  // }
  return (
    <View className='flex flex-col gap-16 px-16'>
      <View className={`flex items-center gap-8`}>
        <View className="component-icon-address"></View>
        <View className='flex-1 truncate'>
          {children}
        </View>
      </View>
      <View className='rounded-10 overflow-clip relative'>
        <Map
            onError={onError}
            longitude={longitude}
            latitude={latitude}
            enableZoom={enableZoom}
            enableScroll={enableScroll}

            style={{width: '100%', height: '300px'}}
            scale={14} />
        <View className={style.goButton}></View>
      </View>
    </View>    
  )
}

export default Index
