Tapsi Geo Location SDK (Mapsi Location) is an Android location SDK that provides the user's location to Android applications.
The SDK is designed to provide a reliable location even when the device cannot obtain a sufficiently accurate location directly from its location providers.
Mapsi Location provides two different approaches for obtaining the user's location:
- Raw — Uses the location provided directly by the Android device.
- Denoised — Uses additional processing and backend services to provide the best possible location.
The SDK can be integrated into Android applications written in both Kotlin and Java.
In Raw mode, the SDK uses the location provided by the Android device's location provider.
No additional backend service or API key is required.
- Simple integration
- No backend configuration required
- No API key required
Because Raw mode relies on the location provided by the device, the resulting location may not be sufficiently accurate in environments with poor GPS conditions.
In Denoised mode, Mapsi Location attempts to improve the user's location by using the device's location data together with additional processing and backend services.
Denoised mode has two integration options:
- Default
- Custom
A sample project is provided with the SDK.
The sample demonstrates the different ways of initializing and using Mapsi Location so that developers can choose the integration method that best fits their application requirements.
Before using Mapsi Location, make sure the following requirements are satisfied.
The application must have the required Android location permission.
Location services must be enabled on the Android device.
If the required permission has not been granted or location services are disabled, Mapsi Location cannot provide a location.
Add the Mapsi Location dependency to your Android application.
implementation("ir.tapsi.map:geo-location-sdk:<latest_version>")Replace <latest_version> with the version you want to use.
You can find the available versions on Maven Central:
Mapsi Location SDK on Maven Central
First, create an instance of MapsiLocation.
MapsiLocationmapsiLocation = newMapsiLocation();val mapsiLocation =MapsiLocation()Next, create an ApplicationInitializer using the Android Application instance.
ApplicationInitializerapplicationInitializer =
newApplicationInitializer(getApplication());val applicationInitializer =ApplicationInitializer(application)The ApplicationInitializer is required when creating the Mapsi Location configuration.
To use Raw mode, create a MapsiLocationConfig.Raw configuration and start Mapsi Location.
MapsiLocationConfigmapsiLocationConfig =
newMapsiLocationConfig.Raw(
applicationInitializer,
newApplicationInfo("test")
);
mapsiLocation.start(mapsiLocationConfig);val mapsiLocationConfig =MapsiLocationConfig.Raw(
applicationInitializer = applicationInitializer,
applicationInfo =ApplicationInfo("test")
)
mapsiLocation.start(mapsiLocationConfig)The applicationInfo parameter is optional.
It can be used to provide a name that the library uses when storing data required by the SDK, for example in SharedPreferences.
Denoised mode supports two different integration approaches:
The Default integration requires an API key from Tapsi services.
The Default integration requires the URLs for the authentication and location services.
ServiceConfig.FullfullServiceConfig = newServiceConfig.Full(
newUrlConfig(
"auth url",
HttpRequestMethod.Post.INSTANCE
),
newUrlConfig(
"geo locate url",
HttpRequestMethod.Post.INSTANCE
)
);val fullServiceConfig =ServiceConfig.Full(
authConfig =UrlConfig(
"auth url",
HttpRequestMethod.Post
),
getLocationConfig =UrlConfig(
"geo locate url",
HttpRequestMethod.Post
)
)Then create the MapsiLocationConfig.Denoised.Default configuration.
MapsiLocationConfigmapsiLocationConfig =
newMapsiLocationConfig.Denoised.Default(
API_KEY,
fullServiceConfig,
MapsiNetworkConfig.Companion.getDefault(),
applicationInitializer,
newApplicationInfo("test")
);
mapsiLocation.start(mapsiLocationConfig);val mapsiLocationConfig:MapsiLocationConfig=MapsiLocationConfig.Denoised.Default(
apiKey =API_KEY,
fullServiceConfig = fullServiceConfig,
mapsiNetworkConfig =MapsiNetworkConfig.default,
applicationInitializer = applicationInitializer,
applicationInfo =ApplicationInfo("test")
)
mapsiLocation.start(mapsiLocationConfig)The Default configuration contains:
| Parameter | Description |
|---|---|
apiKey | API key provided by Tapsi services |
fullServiceConfig | Configuration of authentication and location endpoints |
mapsiNetworkConfig | Optional network-related configuration |
applicationInitializer | Application initializer |
applicationInfo | Optional identifier used by the SDK for storing required data |
The authentication and location URLs must be provided through ServiceConfig.Full.
The Custom integration does not require an API key inside the Android application.
Instead, the application provides a NetworkProvider implementation to Mapsi Location.
In this architecture, your application's backend communicates with Tapsi backend services. Mapsi Location communicates with your application's backend through the provided NetworkProvider.
This approach keeps the Tapsi API key on your backend instead of exposing it in the Android application.
For Custom mode, you need to provide the URL of your application's location endpoint.
ServiceConfig.DerivativederivativeServiceConfig =
newServiceConfig.Derivative(
newUrlConfig(
"your server url",
HttpRequestMethod.Post.INSTANCE
)
);val derivativeServiceConfig =ServiceConfig.Derivative(
UrlConfig(
"your server url",
HttpRequestMethod.Post
)
)The library uses NetworkProvider to communicate with your application's backend.
For Java applications, LegacyNetworkProviderAdapter can be used to implement the network provider:
NetworkProvidernetworkProvider = newLegacyNetworkProviderAdapter(
(requestData, networkCallback) -> {
// Make the API call to your application server.// Retrofit or another networking solution can be used here.
}
);In Kotlin, you can implement NetworkProvider directly:
val networkProvider:NetworkProvider=object:NetworkProvider {
overridesuspendfunapiCall(
request:RequestData
): ResponseData {
// Make the API call to your application server.// Retrofit or another networking solution can be used here.
}
}The Kotlin NetworkProvider exposes a suspend function, allowing the implementation to perform asynchronous network operations without manually managing the asynchronous execution.
MapsiLocationConfigmapsiLocationConfig =
newMapsiLocationConfig.Denoised.Custom(
derivativeServiceConfig,
networkProvider,
MapsiNetworkConfig.Companion.getDefault(),
applicationInitializer,
newApplicationInfo("test")
);
mapsiLocation.start(mapsiLocationConfig);val mapsiLocationConfig:MapsiLocationConfig=MapsiLocationConfig.Denoised.Custom(
derivativeServiceConfig = derivativeServiceConfig,
networkProvider = networkProvider,
mapsiNetworkConfig =MapsiNetworkConfig.default,
applicationInitializer = applicationInitializer,
applicationInfo =ApplicationInfo("test")
)
mapsiLocation.start(mapsiLocationConfig)When using Custom mode, the NetworkProvider must return a ResponseData.
The returned data must match the expected response structure of the API being called.
For example, the location service can return a response similar to:
{
"location": {
"latitude": 35.7448,
"longitude": 51.3753,
"altitude": 435.0
},
"timestamp": 1756630000000,
"accuracy": 5.0,
"provider": "LOCATION_PROVIDER_FUSED",
"speed": 0.0,
"bearing": 0.0,
"isMocked": true
}The JSON response should then be provided through ResponseData.
newResponseData(
200,
Map.of(),
jsonBody
);ResponseData(
code =200,
headers =mapOf(),
body = jsonBody
)After Mapsi Location has been initialized and started, there are two ways to request a location:
- Single Location
- Continuous Location
Use getLocation when you need to obtain a location once.
MapsiLocationListenermapsiLocationListener = location -> {
// Location received here
};
mapsiLocation.getLocation(
2000,
mapsiLocationListener
);val mapsiLocationListener:MapsiLocationListener=object:MapsiLocationListener {
overridefunonLocationReceived(location:Location?) {
// Location received here
}
}
mapsiLocation.getLocation(
timeoutByMilliSecond =2000,
mapsiLocationListener = mapsiLocationListener
)The timeoutByMilliSecond parameter specifies how long the SDK waits while attempting to obtain the location.
A longer timeout can provide more time to obtain a more accurate location.
If you need to cancel a single location request, use removeGetLocationListener.
mapsiLocation.removeGetLocationListener(
mapsiLocationListener
);mapsiLocation.removeGetLocationListener(
mapsiLocationListener = mapsiLocationListener
)Important: You must pass the exact same
MapsiLocationListenerinstance that was provided togetLocation.
Use getLiveLocation when you need to continuously receive location updates.
MapsiLocationListenermapsiLocationListener = location -> {
// Location received here
};
mapsiLocation.getLiveLocation(
2000,
mapsiLocationListener
);val mapsiLocationListener:MapsiLocationListener=object:MapsiLocationListener {
overridefunonLocationReceived(location:Location?) {
// Location received here
}
}
mapsiLocation.getLiveLocation(
intervalByMilliSecond =2000,
mapsiLocationListener = mapsiLocationListener
)The intervalByMilliSecond parameter determines the minimum interval at which the SDK attempts to calculate and provide a new location.
If multiple continuous location requests are registered with different intervals, the SDK uses the smallest requested interval.
To stop receiving continuous location updates, call removeLiveLocationListener.
mapsiLocation.removeLiveLocationListener(
mapsiLocationListener
);mapsiLocation.removeLiveLocationListener(
mapsiLocationListener = mapsiLocationListener
)Important: You must pass the exact same listener instance that was provided to
getLiveLocation.
If removeLiveLocationListener is not called, the SDK continues attempting to provide location updates.
MapsiNetworkConfig is an optional configuration that allows you to customize network-related behavior of Mapsi Location.
The default configuration is:
val default =MapsiNetworkConfig(
defaultDenoiseMethod =null,
denoiseMethods = emptyList(),
denoisingRequestTimeOutByMilliSecond =2000
)The configuration contains three main properties:
| Property | Description |
|---|---|
defaultDenoiseMethod | The default denoise method used by the SDK |
denoiseMethods | The list of available denoise methods |
denoisingRequestTimeOutByMilliSecond | Maximum time to wait for the denoise API request |
The default timeout for a denoising request is 2000 milliseconds.
You can configure multiple denoise methods and switch between them when needed.
For example, suppose the backend provides two denoise methods:
first
second
You can configure the SDK to start with first and make both methods available.
val firstDenoiseMethod ="first"val secondDenoiseMethod ="second"val mapsiNetworkConfig =MapsiNetworkConfig(
defaultDenoiseMethod = firstDenoiseMethod,
denoiseMethods =listOf(
firstDenoiseMethod,
secondDenoiseMethod
),
denoisingRequestTimeOutByMilliSecond =2000
)The SDK starts with first as the default denoise method.
You can change the active denoise method at runtime.
mapsiLocation.updateDenoiseMethod(
secondDenoiseMethod
);mapsiLocation.updateDenoiseMethod(
denoiseMethod = secondDenoiseMethod
)This allows the application to switch between different denoise strategies without recreating the Mapsi Location instance.
There are several ways to integrate Mapsi Location depending on your requirements.
| Mode | Backend Required | API Key in App | Custom Network Layer |
|---|---|---|---|
| Raw | No | No | No |
| Denoised / Default | Tapsi services | Yes | No |
| Denoised / Custom | Your backend | No | Yes |
For applications using Denoised mode, the Custom integration is recommended when you want to avoid exposing the Tapsi API key inside the Android application.
In this approach:
Android Application
|
| NetworkProvider
v
Your Backend
|
| API Key
v
Tapsi Backend Services
This keeps the API key on your backend while allowing Mapsi Location to obtain the required location information through your application's server.
The general integration flow is:
1. Add Mapsi Location dependency
↓
2. Create MapsiLocation
↓
3. Create ApplicationInitializer
↓
4. Select location mode
↓
5. Create MapsiLocationConfig
↓
6. Start MapsiLocation
↓
7. Request location
↓
8. Receive location through MapsiLocationListener
- Location permission must be granted before requesting a location.
- Location services must be enabled on the device.
- In Raw mode, no backend configuration is required.
- Denoised Default requires an API key.
- Denoised Custom requires implementing
NetworkProvider. - When canceling a request, use the same listener instance that was registered.
- Continuous location updates remain active until the corresponding listener is removed.
MapsiNetworkConfigcan be used to customize denoising behavior.- Multiple denoise methods can be configured and switched at runtime.
If you have any questions or encounter issues while integrating Mapsi Location, please contact the Tapsi technical team.