import YaMap, { Geocoder, Suggest } from '../../bare'; import type { Point } from '../utils/types'; import { Platform } from 'react-native'; export class MapApi { static shared = new MapApi(); private isInitialized = false; private constructor() {} init = async (key: string, geocodeKey: string) => { if (!this.isInitialized) { // For iOS doing setup on AppDelegate via expo config plugin // Configure two times will cause potential crashes if (Platform.OS === 'android') { await YaMap.init(key); } Geocoder.init(geocodeKey); this.isInitialized = true; } }; getInitStatus = () => this.isInitialized; geocode = async (point: Point) => { return Geocoder.geoToAddress(point); }; getSuggestions = async (query: string) => { return Suggest.suggest(query); }; // Could be reverse geocode reverseGeocode = async (query: string) => { return Geocoder.addressToGeo(query); }; }