hamuga-imap-sdk-react-native
v1.0.0
Published
Hamuga iMap SDK for React Native
Maintainers
Readme
hamuga-imap-react-native
Hamuga iMap SDK for React Native. Provides a powerful map component with integrated search and routing capabilities.
Installation
npm install hamuga-imap-react-nativeUsage
HamugaMap Component
The HamugaMap component is the main entry point for displaying the map.
import React, { useRef } from 'react';
import { HamugaMap, type HamugaMapRef } from 'hamuga-imap-react-native';
const MyMap = () => {
const mapRef = useRef<HamugaMapRef>(null);
const handleSearch = async () => {
if (mapRef.current) {
const results = await mapRef.current.getPoi({ query: 'restaurant' });
console.log(results);
}
};
return (
<HamugaMap
ref={mapRef}
apiKey="YOUR_HAMUGA_API_KEY"
search={true}
center={[106.9163, 47.9191]} // [longitude, latitude]
zoom={14}
/>
);
};Accessing Backend Functions via Ref
You can access essential backend functions directly through the HamugaMap reference:
getPoi(options: HamugaSearchPoisOptions): Search for Points of Interest.getSuggest(query: string): Get search suggestions/typeahead.planRoute(options: HamugaPlanRouteOptions): Plan a route (multimodal).calculateRoute(options: HamugaCalculateRouteOptions): Calculate basic routing.
Standalone Backend Client
If you need to use the backend services without the map component, you can use the standalone client:
import { createHamugaSearchClient } from 'hamuga-imap-react-native';
const client = createHamugaSearchClient({ apiKey: 'YOUR_HAMUGA_API_KEY' });
const search = async () => {
const suggestions = await client.getSuggest('central');
const route = await client.planRoute({
from: [106.9, 47.9],
to: [106.91, 47.92],
mode: 'WALK',
});
};API Reference
HamugaMap Props
| Prop | Type | Default | Description |
| ---------------- | ------------------ | --------------------------- | ---------------------------- |
| apiKey | string | Required | Your Hamuga API key |
| center | [number, number] | [106.9163, 47.9191] | Initial center of the map |
| zoom | number | 14.5 | Initial zoom level |
| search | boolean | false | Enable/disable the search UI |
| gatewayBaseUrl | string | https://gateway.hamuga.mn | Custom backend URL |
License
Apache 2.0
