react-native-india-maps
v0.5.0
Published
React Native SDK for India Maps using MapLibre GL with Ola Maps and Mappls (MapMyIndia) APIs
Maintainers
Readme
react-native-india-maps
A React Native SDK for India Maps powered by MapLibre for rendering and supporting both Ola Maps and Mappls API backends.
Features
- 🗺️ Map rendering via
@maplibre/maplibre-react-native(no proprietary native SDKs) - 🔄 Dual-provider: Ola Maps (default) and Mappls backends
- 📍 Full Places API (autocomplete, geocode, reverse geocode, nearby, text search)
- 🛣️ Routing API (directions, distance matrix, route optimizer)
- 🛤️ Roads API (snap to road, nearest roads, speed limits)
- 🏔️ Elevation API
- 📐 Geofencing API (Ola Maps only)
- 🎨 Multiple map styles (light, dark, satellite, and more)
- ⚡ Expo config plugin for location permissions
Install
bun add react-native-india-maps @maplibre/maplibre-react-native@^11.0.0Requires React >=19.2.0 and React Native >=0.83.0 (Expo SDK 55+ development builds are supported). See docs/installation.md for details.
Expo setup
Use an Expo development build, not Expo Go.
{
"expo": {
"plugins": [
[
"react-native-india-maps",
{
"iosWhenInUsePermission": "Allow $(PRODUCT_NAME) to access your location while using the app.",
"backgroundLocation": false
}
]
]
}
}The plugin adds location permissions for both Android and iOS. No native SDK configuration files are needed — MapLibre handles all map rendering.
MapLibre React Native v11 requires the React Native New Architecture. Expo Go is not supported.
Provider and hooks
import {
IndiaMapsProvider,
IndiaMapsClient,
MapView,
Marker,
useAutocomplete,
} from 'react-native-india-maps';
// Ola Maps (default provider)
const client = new IndiaMapsClient({ apiKey: 'YOUR_OLA_MAPS_API_KEY' });
// Or Mappls provider
// const client = new IndiaMapsClient({ accessToken: 'YOUR_MAPPLS_TOKEN', provider: 'mappls' });
function SearchBox() {
const { results, debouncedSearch } = useAutocomplete({ debounceMs: 300 });
return null;
}
export function App() {
return (
<IndiaMapsProvider client={client}>
<MapView
style={{ flex: 1 }}
styleName="default-light-standard"
initialRegion={{ latitude: 28.6139, longitude: 77.209, zoomLevel: 12 }}
>
<Marker
id="delhi"
coordinate={{ latitude: 28.6139, longitude: 77.209 }}
/>
</MapView>
<SearchBox />
</IndiaMapsProvider>
);
}Dual-provider support
The SDK supports two backends:
| Feature | Ola Maps | Mappls |
| --- | --- | --- |
| Auth param | api_key | access_token |
| Base URL | https://api.olamaps.io | https://atlas.mappls.com |
| Map tiles | ✅ Vector tiles | ❌ Not public |
| Geofencing | ✅ | ❌ Not public |
// Ola Maps (default)
const olaClient = new IndiaMapsClient({ apiKey: 'YOUR_KEY' });
// Mappls
const mapplsClient = new IndiaMapsClient({
accessToken: 'YOUR_TOKEN',
provider: 'mappls',
});API coverage
Places
- Autocomplete / Autosuggest
- Geocode
- Reverse Geocode
- Place Details
- Nearby Search
- Text Search
Routing
- Directions (driving, walking, biking)
- Distance Matrix
- Route Optimizer
Roads
- Snap to Road
- Nearest Roads
- Speed Limits
Elevation
- Single point elevation
- Multi-point elevation
Geofencing (Ola Maps only)
- Create / Read / Update / Delete geofences
- Check point status (inside/outside)
Tiles
- Vector tile style URLs for MapLibre
- Static map image URLs
- Request transform helper for API key injection
Map styles
Use the MAP_STYLES presets or any provider-specific style name:
import { MAP_STYLES } from 'react-native-india-maps';
// MAP_STYLES.lightStandard === 'default-light-standard'
<MapView styleName={MAP_STYLES.darkStandard} style={{ flex: 1 }} />;Available Ola Maps styles: default-light-standard, default-dark-standard, default-light-lite, default-dark-lite, default-light-full, default-dark-full, eclipse-light-standard, eclipse-dark-standard, bolt-light, bolt-dark, vintage-light, vintage-dark, and more.
Migrating from 0.2.x
Version 0.3.0 redesigns the public API. The most common changes:
- Methods return domain types directly. The
ApiResponse/PaginatedResponseenvelopes were removed. For example,autocompletenow resolves toAutocompleteSuggestion[], andgeocodetoGeocodeResult[]. - Positional, typed signatures.
geocode(address, options?),reverseGeocode(location, options?)andplaceDetails(placeId, options?)take their primary input as a positional argument. Coordinate inputs acceptLatLng,{ latitude, longitude },[lng, lat]or'lat,lng'strings (LatLngInput). - camelCase option names.
rankby→rankBy,strictbounds→strictBounds,roundtrip→roundTrip,traffic_metadata→trafficMetadata,routepreference→routePreference. - Closed unions.
TravelModeis'driving' | 'walking' | 'biking' | 'trucking', andoverviewis'full' | 'simplified' | false. - Single error type. All failures throw
IndiaMapsErrorwith acodeof'CONFIGURATION_ERROR' | 'NETWORK_ERROR' | 'API_ERROR' | 'PARSE_ERROR' | 'UNSUPPORTED_ERROR'. - Style presets.
MAP_STYLESexports well-known Ola Maps style names;MapViewusesstyleName(defaultdefault-light-standard) instead ofaccessToken-keyed style resolution.
Migrating from 0.4.x
Version 0.5.0 removes previously-deprecated aliases. Update your imports:
- Replace
OlaMapsClientwithIndiaMapsClient - Replace
OlaMapsProviderwithIndiaMapsProvider - Replace
useOlaMapswithuseIndiaMaps - Replace
OlaMapsConfigwithIndiaMapsConfig - Replace
OlaMapsErrorwithIndiaMapsError - Replace
OlaMapsErrorCodewithIndiaMapsErrorCode - Replace
OlaMapViewPropswithIndiaMapViewProps - Replace
SnapToRoadPointwithRoadPoint - Replace
autoSuggestwithautocomplete(no longer an alias) - Replace
placeDetailsAdvancedwithplaceDetails(no longer an alias) - Replace
nearbySearchAdvancedwithnearbySearch(no longer an alias) - Replace
getDirectionsBasicwithgetDirections(no longer an alias) - Replace
getDistanceMatrixBasicwithgetDistanceMatrix(no longer an alias) RoutingApi.fleetPlannerhas been removed — fleet planning has no public REST API
Notes
apiKeyis used for Ola Maps API authenticationaccessTokenis used for Mappls API authentication
License
LGPL-3.0-or-later. See LICENSE.txt.
