diff --git a/screens/Maps/MapsView2.tsx b/screens/Maps/MapsView2.tsx index 418801f..df9be3f 100644 --- a/screens/Maps/MapsView2.tsx +++ b/screens/Maps/MapsView2.tsx @@ -1,29 +1,25 @@ -import React, { useCallback, useState } from "react"; -import { StyleSheet, View } from "react-native"; +import { useCallback, useState } from "react"; +import { Image, StyleSheet, View } from "react-native"; // Cek versi >= 10.x gunakan ini +import API_IMAGE from "@/constants/api-storage"; +import { MainColor } from "@/constants/color-palet"; +import { apiMapsGetAll } from "@/service/api-client/api-maps"; import { - MapView, Camera, + MapView, PointAnnotation, - Images, - ShapeSource, - SymbolLayer, } from "@maplibre/maplibre-react-native"; +import { router, useFocusEffect } from "expo-router"; import { - ButtonCustom, DrawerCustom, DummyLandscapeImage, - Grid, Spacing, StackCustom, TextCustom, - ViewWrapper, + Grid, + ButtonCustom, } from "@/components"; -import { apiMapsGetAll } from "@/service/api-client/api-maps"; -import { router, useFocusEffect } from "expo-router"; -import { Image } from "expo-image"; -import API_IMAGE from "@/constants/api-storage"; import GridTwoView from "@/components/_ShareComponent/GridTwoView"; import { ICON_SIZE_SMALL } from "@/constants/constans-value"; import { openInDeviceMaps } from "@/utils/openInDeviceMaps"; @@ -31,6 +27,31 @@ import { FontAwesome, Ionicons } from "@expo/vector-icons"; const MAP_STYLE = "https://tiles.openfreemap.org/styles/liberty"; +interface TypeMaps { + id: string; + isActive: boolean; + createdAt: string; + updatedAt: string; + namePin: string; + latitude: number; + longitude: number; + authorId: string; + portofolioId: string; + imageId: string; + pinId: string | null; + Portofolio: { + id: string; + namaBisnis: string; + logoId: string; + alamatKantor: string; + tlpn: string; + MasterBidangBisnis: { + id: string; + name: string; + }; + }; +} + const defaultRegion = { latitude: -8.737109, longitude: 115.1756897, @@ -40,7 +61,7 @@ const defaultRegion = { }; export default function MapsView2() { - const [list, setList] = useState(null); + const [list, setList] = useState(null); const [loadList, setLoadList] = useState(false); const [openDrawer, setOpenDrawer] = useState(false); const [selected, setSelected] = useState({ @@ -67,6 +88,7 @@ export default function MapsView2() { const response = await apiMapsGetAll(); if (response.success) { + // console.log("[RESPONSE]", JSON.stringify(response.data, null, 2)); setList(response.data); } } catch (error) { @@ -76,57 +98,51 @@ export default function MapsView2() { } }; - // Data GeoJSON untuk marker - const markerData: GeoJSON.FeatureCollection = { - type: "FeatureCollection", - features: [ - { - type: "Feature", - geometry: { - type: "Point", - coordinates: [115.1756897, -8.737109], - }, - properties: { id: "1", title: "Lokasi A" }, - }, - { - type: "Feature", - geometry: { - type: "Point", - coordinates: [106.83, -6.18], - }, - properties: { id: "2", title: "Lokasi B" }, - }, - ], - }; - return ( <> - console.log("Missing:", imageKey)} - /> - - - + {list?.map((item: TypeMaps) => { + const imageUrl = API_IMAGE.GET({ fileId: item.Portofolio.logoId }); + + return ( + { + setOpenDrawer(true); + setSelected({ + id: item?.id, + bidangBisnis: item?.Portofolio?.MasterBidangBisnis?.name, + nomorTelepon: item?.Portofolio?.tlpn, + alamatBisnis: item?.Portofolio?.alamatKantor, + namePin: item?.namePin, + imageId: item?.imageId, + portofolioId: item?.Portofolio?.id, + latitude: item?.latitude, + longitude: item?.longitude, + }); + }} + > + + + console.log("Image error:", e.nativeEvent.error) + } // Tangkap error image + /> + + + ); + })} @@ -223,10 +239,21 @@ export default function MapsView2() { const styles = StyleSheet.create({ container: { flex: 1 }, map: { flex: 1 }, - marker: { + markerContainer: { width: 30, height: 30, borderRadius: 100, - backgroundColor: "red", + overflow: "hidden", // Wajib agar borderRadius terapply pada Image + borderWidth: 1, + borderColor: MainColor.darkblue, // Opsional, biar lebih cantik + elevation: 4, // Shadow Android + shadowColor: "#000", // Shadow iOS + shadowOffset: { width: 0, height: 2 }, + shadowOpacity: 0.3, + shadowRadius: 3, + }, + markerImage: { + width: "100%", + height: "100%", }, });