Integrasi Map Business
Add:
components/Map/MapSelected.tsx
components/_ShareComponent/GridTwoView.tsx
service/api-client/api-maps.ts
utils/openInDeviceMaps.ts
Fix:
modified: app/(application)/(user)/maps/[id]/edit.tsx
modified: app/(application)/(user)/maps/create.tsx
modified: app/(application)/(user)/maps/index.tsx
modified: app/(application)/(user)/portofolio/[id]/index.tsx
modified: components/Map/MapCustom.tsx
modified: screens/Portofolio/BusinessLocationSection.tsx
modified: screens/Portofolio/DataPortofolio.tsx
modified: screens/Portofolio/ListPage.tsx
### No issue
This commit is contained in:
37
utils/openInDeviceMaps.ts
Normal file
37
utils/openInDeviceMaps.ts
Normal file
@@ -0,0 +1,37 @@
|
||||
import { Platform, Linking, Alert } from "react-native";
|
||||
|
||||
export const openInDeviceMaps = async ({
|
||||
latitude,
|
||||
longitude,
|
||||
title = "Lokasi",
|
||||
}: {
|
||||
latitude: number;
|
||||
longitude: number;
|
||||
title?: string;
|
||||
}) => {
|
||||
let url = "";
|
||||
|
||||
if (Platform.OS === "ios") {
|
||||
// Apple Maps
|
||||
url = `maps://?q=${encodeURIComponent(title)}&ll=${latitude},${longitude}`;
|
||||
} else {
|
||||
// Android: Google Maps
|
||||
url = `geo:${latitude},${longitude}?q=${latitude},${longitude}(${encodeURIComponent(
|
||||
title
|
||||
)})`;
|
||||
}
|
||||
|
||||
try {
|
||||
const canOpen = await Linking.canOpenURL(url);
|
||||
if (canOpen) {
|
||||
await Linking.openURL(url);
|
||||
} else {
|
||||
// Fallback ke web
|
||||
const webUrl = `https://www.google.com/maps/search/?api=1&query=${latitude},${longitude}`;
|
||||
await Linking.openURL(webUrl);
|
||||
}
|
||||
} catch (error) {
|
||||
console.warn("Gagal membuka Maps:", error);
|
||||
Alert.alert("Error", "Tidak dapat membuka aplikasi Maps.");
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user