Source

src/components/LandmarkPin.tsx

import React, { memo } from "react";
import { Image } from "react-native";
import { Marker } from "react-native-maps";
import { Icons } from "../globals";
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={Icons[landmark.landmark_type]} /> : null}
    </Marker> )
}

export default memo(LandmarkPin);