import React from "react";
import { Image } from "react-native";
import { Marker } from "react-native-maps";
import { lmTypes } from "../../utils/GlobalUtils";
import { Landmark } from "../../hooks/useLandmarks";

/**
 * Props for the {@link LandmarkPin} component
 */
export interface LandmarkPinProps {
    /**The landmark object being displayed. */
    landmark: Landmark
    /**The handler passed down from {@link Map} that opens up the {@link LandmarkDetails} modal to display the landmark's properties. */
    focusLandmark: (landmark: Landmark) => void
}

/**
 * Component that renders landmarks with their proper icon on the {@link Map}.
 * @category Map
 * @component
 */
const LandmarkPin: React.FC<LandmarkPinProps> = ({landmark, focusLandmark}) => {
    return (
    <Marker 
        tracksViewChanges={false}
        onPress={() => focusLandmark(landmark)}
        key={landmark.id} 
        coordinate={{latitude: landmark.latitude as number, longitude: landmark.longitude as number}} >
        { landmark.landmark_type ? <Image style={{height: 35, width: 25}} source={lmTypes[landmark.landmark_type].image} /> : null}
    </Marker> )
}

export default LandmarkPin;