chore(maps): display position in DMS

This commit is contained in:
Tran Anh Tuan
2025-10-08 09:38:54 +07:00
parent 28739ddcd9
commit 65f9468bbd
6 changed files with 23 additions and 10 deletions

View File

@@ -15,8 +15,8 @@ export const BASEMAP_ATTRIBUTIONS = '© OpenStreetMap contributors, © CartoDB';
export const INITIAL_VIEW_CONFIG = {
// Dịch tâm bản đồ ra phía biển và zoom ra xa hơn để thấy bao quát
center: [109.5, 16.0],
zoom: 5.5,
center: [116.152685, 15.70581],
zoom: 6.5,
minZoom: 5,
maxZoom: 12,
minScale: 0.1,
@@ -62,3 +62,14 @@ export const getShipIcon = (type: number, isFishing: boolean) => {
return shipUndefineIcon;
}
};
export const convertToDMS = (value: number, isLat: boolean): string => {
const deg = Math.floor(Math.abs(value));
const minFloat = (Math.abs(value) - deg) * 60;
const min = Math.floor(minFloat);
const sec = (minFloat - min) * 60;
const direction = value >= 0 ? (isLat ? 'N' : 'E') : isLat ? 'S' : 'W';
return `${deg}°${min}'${sec.toFixed(2)}"${direction}`;
};