import React, { useState, useEffect } from 'react';
import { View, Text, Button } from 'react-native';
import MapView, { Marker } from 'react-native-maps';
import * as XLSX from 'xlsx';
const StoreMapScreen = () => {
const [stores, setStores] = useState([]);
useEffect(() => {
// Đọc dữ liệu từ file Excel khi màn hình được load
readExcelData();
}, []);
const readExcelData = async () => {
try {
const fileUri = 'path_to_your_excel_file/data.xlsx';
const workbook = XLSX.readFile(fileUri);
const sheetName = workbook.SheetNames[0];
const sheet = workbook.Sheets[sheetName];
const data = XLSX.utils.sheet_to_json(sheet);
setStores(data);
} catch (error) {
console.error('Error reading Excel file:', error);
}
};
const updateStoreInfo = (storeId, newInfo) => {
// Cập nhật thông tin cửa hàng với ID cho trước
// Cập nhật dữ liệu stores và cập nhật trực tiếp lên bản đồ
};
return (
<View flex: 1 }}>
<MapView
flex: 1 }}
initialRegi
latitude: 37.78825,
longitude: -122.4324,
latitudeDelta: 0.0922,
longitudeDelta: 0.0421,
}}
>
{stores.map(store => (
<Marker
key={store.id} // Giả sử cửa hàng có trường id
coordinate={{ latitude: store.latitude, longitude: store.longitude }} // Giả sử các cửa hàng có thông tin vị trí
title={store.name}
descripti
=> console.log('Marker pressed:', store)}
/>
))}
</MapView>
<View position: 'absolute', bottom: 20, left: 20 }}>
<Button title="Update Store Info" => updateStoreInfo(storeId, newInfo)} />
</View>
</View>
);
};
export default StoreMapScreen;
{"html5":"htmlmixed","css":"css","javascript":"javascript","php":"php","python":"python","ruby":"ruby","lua":"text\/x-lua","bash":"text\/x-sh","go":"go","c":"text\/x-csrc","cpp":"text\/x-c++src","diff":"diff","latex":"stex","sql":"sql","xml":"xml","apl":"apl","asterisk":"asterisk","c_loadrunner":"text\/x-csrc","c_mac":"text\/x-csrc","coffeescript":"text\/x-coffeescript","csharp":"text\/x-csharp","d":"d","ecmascript":"javascript","erlang":"erlang","groovy":"text\/x-groovy","haskell":"text\/x-haskell","haxe":"text\/x-haxe","html4strict":"htmlmixed","java":"text\/x-java","java5":"text\/x-java","jquery":"javascript","mirc":"mirc","mysql":"sql","ocaml":"text\/x-ocaml","pascal":"text\/x-pascal","perl":"perl","perl6":"perl","plsql":"sql","properties":"text\/x-properties","q":"text\/x-q","scala":"scala","scheme":"text\/x-scheme","tcl":"text\/x-tcl","vb":"text\/x-vb","verilog":"text\/x-verilog","yaml":"text\/x-yaml","z80":"text\/x-z80"}