Repository files navigation

Mapsi Location SDK

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.


Table of Contents


Overview

Mapsi Location provides two different approaches for obtaining the user's location:

  1. Raw — Uses the location provided directly by the Android device.
  2. 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.


Location Modes

Raw

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.

Advantages

  • Simple integration
  • No backend configuration required
  • No API key required

Limitations

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.


Denoised

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:

  1. Default
  2. Custom

Sample Project

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.


Requirements

Before using Mapsi Location, make sure the following requirements are satisfied.

1. Location Permission

The application must have the required Android location permission.

2. Location Services

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.


Installation

Add the Mapsi Location dependency to your Android application.

Gradle

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


Initialization

First, create an instance of MapsiLocation.

Java

MapsiLocationmapsiLocation = newMapsiLocation();

Kotlin

val mapsiLocation =MapsiLocation()

Next, create an ApplicationInitializer using the Android Application instance.

Java

ApplicationInitializerapplicationInitializer =
newApplicationInitializer(getApplication());

Kotlin

val applicationInitializer =ApplicationInitializer(application)

The ApplicationInitializer is required when creating the Mapsi Location configuration.


Raw Mode

To use Raw mode, create a MapsiLocationConfig.Raw configuration and start Mapsi Location.

Java

MapsiLocationConfigmapsiLocationConfig =
newMapsiLocationConfig.Raw(
applicationInitializer,
newApplicationInfo("test")
);
mapsiLocation.start(mapsiLocationConfig);

Kotlin

val mapsiLocationConfig =MapsiLocationConfig.Raw(
applicationInitializer = applicationInitializer,
applicationInfo =ApplicationInfo("test")
)
mapsiLocation.start(mapsiLocationConfig)

ApplicationInfo

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

Denoised mode supports two different integration approaches:


Denoised Default

The Default integration requires an API key from Tapsi services.

Service Configuration

The Default integration requires the URLs for the authentication and location services.

Java

ServiceConfig.FullfullServiceConfig = newServiceConfig.Full(
newUrlConfig(
"auth url",
HttpRequestMethod.Post.INSTANCE
),
newUrlConfig(
"geo locate url",
HttpRequestMethod.Post.INSTANCE
)
);

Kotlin

val fullServiceConfig =ServiceConfig.Full(
authConfig =UrlConfig(
"auth url",
HttpRequestMethod.Post
),
getLocationConfig =UrlConfig(
"geo locate url",
HttpRequestMethod.Post
)
)

Then create the MapsiLocationConfig.Denoised.Default configuration.

Java

MapsiLocationConfigmapsiLocationConfig =
newMapsiLocationConfig.Denoised.Default(
API_KEY,
fullServiceConfig,
MapsiNetworkConfig.Companion.getDefault(),
applicationInitializer,
newApplicationInfo("test")
);
mapsiLocation.start(mapsiLocationConfig);

Kotlin

val mapsiLocationConfig:MapsiLocationConfig=MapsiLocationConfig.Denoised.Default(
apiKey =API_KEY,
fullServiceConfig = fullServiceConfig,
mapsiNetworkConfig =MapsiNetworkConfig.default,
applicationInitializer = applicationInitializer,
applicationInfo =ApplicationInfo("test")
)
mapsiLocation.start(mapsiLocationConfig)

Configuration Parameters

The Default configuration contains:

ParameterDescription
apiKeyAPI key provided by Tapsi services
fullServiceConfigConfiguration of authentication and location endpoints
mapsiNetworkConfigOptional network-related configuration
applicationInitializerApplication initializer
applicationInfoOptional identifier used by the SDK for storing required data

The authentication and location URLs must be provided through ServiceConfig.Full.


Denoised Custom

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.

Service Configuration

For Custom mode, you need to provide the URL of your application's location endpoint.

Java

ServiceConfig.DerivativederivativeServiceConfig =
newServiceConfig.Derivative(
newUrlConfig(
"your server url",
HttpRequestMethod.Post.INSTANCE
)
);

Kotlin

val derivativeServiceConfig =ServiceConfig.Derivative(
UrlConfig(
"your server url",
HttpRequestMethod.Post
)
)

NetworkProvider

The library uses NetworkProvider to communicate with your application's backend.

Java

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.
}
);

Kotlin

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.


Starting Custom Mode

Java

MapsiLocationConfigmapsiLocationConfig =
newMapsiLocationConfig.Denoised.Custom(
derivativeServiceConfig,
networkProvider,
MapsiNetworkConfig.Companion.getDefault(),
applicationInitializer,
newApplicationInfo("test")
);
mapsiLocation.start(mapsiLocationConfig);

Kotlin

val mapsiLocationConfig:MapsiLocationConfig=MapsiLocationConfig.Denoised.Custom(
derivativeServiceConfig = derivativeServiceConfig,
networkProvider = networkProvider,
mapsiNetworkConfig =MapsiNetworkConfig.default,
applicationInitializer = applicationInitializer,
applicationInfo =ApplicationInfo("test")
)
mapsiLocation.start(mapsiLocationConfig)

ResponseData

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.

Java

newResponseData(
200,
Map.of(),
jsonBody
);

Kotlin

ResponseData(
code =200,
headers =mapOf(),
body = jsonBody
)

Getting Location

After Mapsi Location has been initialized and started, there are two ways to request a location:

  1. Single Location
  2. Continuous Location

Single Location

Use getLocation when you need to obtain a location once.

Java

MapsiLocationListenermapsiLocationListener = location -> {
// Location received here
};
mapsiLocation.getLocation(
2000,
mapsiLocationListener
);

Kotlin

val mapsiLocationListener:MapsiLocationListener=object:MapsiLocationListener {
overridefunonLocationReceived(location:Location?) {
// Location received here
}
}
mapsiLocation.getLocation(
timeoutByMilliSecond =2000,
mapsiLocationListener = mapsiLocationListener
)

Timeout

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.


Cancel Single Location Request

If you need to cancel a single location request, use removeGetLocationListener.

Java

mapsiLocation.removeGetLocationListener(
mapsiLocationListener
);

Kotlin

mapsiLocation.removeGetLocationListener(
mapsiLocationListener = mapsiLocationListener
)

Important: You must pass the exact same MapsiLocationListener instance that was provided to getLocation.


Continuous Location

Use getLiveLocation when you need to continuously receive location updates.

Java

MapsiLocationListenermapsiLocationListener = location -> {
// Location received here
};
mapsiLocation.getLiveLocation(
2000,
mapsiLocationListener
);

Kotlin

val mapsiLocationListener:MapsiLocationListener=object:MapsiLocationListener {
overridefunonLocationReceived(location:Location?) {
// Location received here
}
}
mapsiLocation.getLiveLocation(
intervalByMilliSecond =2000,
mapsiLocationListener = mapsiLocationListener
)

intervalByMilliSecond

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.


Cancel Continuous Location

To stop receiving continuous location updates, call removeLiveLocationListener.

Java

mapsiLocation.removeLiveLocationListener(
mapsiLocationListener
);

Kotlin

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

MapsiNetworkConfig is an optional configuration that allows you to customize network-related behavior of Mapsi Location.

The default configuration is:

Kotlin

val default =MapsiNetworkConfig(
defaultDenoiseMethod =null,
denoiseMethods = emptyList(),
denoisingRequestTimeOutByMilliSecond =2000
)

The configuration contains three main properties:

PropertyDescription
defaultDenoiseMethodThe default denoise method used by the SDK
denoiseMethodsThe list of available denoise methods
denoisingRequestTimeOutByMilliSecondMaximum time to wait for the denoise API request

The default timeout for a denoising request is 2000 milliseconds.


Denoise Methods

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.

Kotlin

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.


Changing Denoise Method

You can change the active denoise method at runtime.

Java

mapsiLocation.updateDenoiseMethod(
secondDenoiseMethod
);

Kotlin

mapsiLocation.updateDenoiseMethod(
denoiseMethod = secondDenoiseMethod
)

This allows the application to switch between different denoise strategies without recreating the Mapsi Location instance.


Integration Summary

There are several ways to integrate Mapsi Location depending on your requirements.

ModeBackend RequiredAPI Key in AppCustom Network Layer
RawNoNoNo
Denoised / DefaultTapsi servicesYesNo
Denoised / CustomYour backendNoYes

Recommended Integration

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.


Complete Basic Flow

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

Important Notes

  • 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.
  • MapsiNetworkConfig can be used to customize denoising behavior.
  • Multiple denoise methods can be configured and switched at runtime.

Support

If you have any questions or encounter issues while integrating Mapsi Location, please contact the Tapsi technical team.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Add copy buttons to all
 blocks\n(function() {\n function addCopyButtons() {\n document.querySelectorAll('pre code').forEach(function(codeBlock) {\n if (codeBlock.parentElement.hasAttribute('data-copy-added')) return;\n codeBlock.parentElement.setAttribute('data-copy-added', 'true');\n \n var btn = document.createElement('button');\n btn.textContent = 'Copy';\n btn.style.cssText = 'position:absolute;top:4px;right:4px;padding:2px 8px;font-size:11px;background:#4ecdc4;border:none;border-radius:4px;color:#1a1a2e;cursor:pointer;opacity:0.7;transition:opacity 0.2s;';\n btn.onmouseover = function() { this.style.opacity = '1'; };\n btn.onmouseout = function() { this.style.opacity = '0.7'; };\n btn.onclick = function() {\n navigator.clipboard.writeText(codeBlock.textContent).then(function() {\n btn.textContent = 'Copied!';\n setTimeout(function() { btn.textContent = 'Copy'; }, 1500);\n });\n };\n codeBlock.parentElement.style.position = 'relative';\n codeBlock.parentElement.appendChild(btn);\n });\n }\n \n addCopyButtons();\n \n // Re-run on dynamic content\n var observer = new MutationObserver(addCopyButtons);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Add Copy Buttons to Code Blocks");
}
} catch(__e) { console.warn('[Userscript:Add Copy Buttons to Code Blocks]', __e); }
})();
(function(){
try {
var __m = "github.com";
var __re = new RegExp('^' + "github\\.com" + '
Skip to content

Repository files navigation

Mapsi Location SDK

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.


Table of Contents


Overview

Mapsi Location provides two different approaches for obtaining the user's location:

  1. Raw — Uses the location provided directly by the Android device.
  2. 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.


Location Modes

Raw

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.

Advantages

  • Simple integration
  • No backend configuration required
  • No API key required

Limitations

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.


Denoised

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:

  1. Default
  2. Custom

Sample Project

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.


Requirements

Before using Mapsi Location, make sure the following requirements are satisfied.

1. Location Permission

The application must have the required Android location permission.

2. Location Services

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.


Installation

Add the Mapsi Location dependency to your Android application.

Gradle

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


Initialization

First, create an instance of MapsiLocation.

Java

MapsiLocationmapsiLocation = newMapsiLocation();

Kotlin

val mapsiLocation =MapsiLocation()

Next, create an ApplicationInitializer using the Android Application instance.

Java

ApplicationInitializerapplicationInitializer =
newApplicationInitializer(getApplication());

Kotlin

val applicationInitializer =ApplicationInitializer(application)

The ApplicationInitializer is required when creating the Mapsi Location configuration.


Raw Mode

To use Raw mode, create a MapsiLocationConfig.Raw configuration and start Mapsi Location.

Java

MapsiLocationConfigmapsiLocationConfig =
newMapsiLocationConfig.Raw(
applicationInitializer,
newApplicationInfo("test")
);
mapsiLocation.start(mapsiLocationConfig);

Kotlin

val mapsiLocationConfig =MapsiLocationConfig.Raw(
applicationInitializer = applicationInitializer,
applicationInfo =ApplicationInfo("test")
)
mapsiLocation.start(mapsiLocationConfig)

ApplicationInfo

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

Denoised mode supports two different integration approaches:


Denoised Default

The Default integration requires an API key from Tapsi services.

Service Configuration

The Default integration requires the URLs for the authentication and location services.

Java

ServiceConfig.FullfullServiceConfig = newServiceConfig.Full(
newUrlConfig(
"auth url",
HttpRequestMethod.Post.INSTANCE
),
newUrlConfig(
"geo locate url",
HttpRequestMethod.Post.INSTANCE
)
);

Kotlin

val fullServiceConfig =ServiceConfig.Full(
authConfig =UrlConfig(
"auth url",
HttpRequestMethod.Post
),
getLocationConfig =UrlConfig(
"geo locate url",
HttpRequestMethod.Post
)
)

Then create the MapsiLocationConfig.Denoised.Default configuration.

Java

MapsiLocationConfigmapsiLocationConfig =
newMapsiLocationConfig.Denoised.Default(
API_KEY,
fullServiceConfig,
MapsiNetworkConfig.Companion.getDefault(),
applicationInitializer,
newApplicationInfo("test")
);
mapsiLocation.start(mapsiLocationConfig);

Kotlin

val mapsiLocationConfig:MapsiLocationConfig=MapsiLocationConfig.Denoised.Default(
apiKey =API_KEY,
fullServiceConfig = fullServiceConfig,
mapsiNetworkConfig =MapsiNetworkConfig.default,
applicationInitializer = applicationInitializer,
applicationInfo =ApplicationInfo("test")
)
mapsiLocation.start(mapsiLocationConfig)

Configuration Parameters

The Default configuration contains:

ParameterDescription
apiKeyAPI key provided by Tapsi services
fullServiceConfigConfiguration of authentication and location endpoints
mapsiNetworkConfigOptional network-related configuration
applicationInitializerApplication initializer
applicationInfoOptional identifier used by the SDK for storing required data

The authentication and location URLs must be provided through ServiceConfig.Full.


Denoised Custom

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.

Service Configuration

For Custom mode, you need to provide the URL of your application's location endpoint.

Java

ServiceConfig.DerivativederivativeServiceConfig =
newServiceConfig.Derivative(
newUrlConfig(
"your server url",
HttpRequestMethod.Post.INSTANCE
)
);

Kotlin

val derivativeServiceConfig =ServiceConfig.Derivative(
UrlConfig(
"your server url",
HttpRequestMethod.Post
)
)

NetworkProvider

The library uses NetworkProvider to communicate with your application's backend.

Java

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.
}
);

Kotlin

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.


Starting Custom Mode

Java

MapsiLocationConfigmapsiLocationConfig =
newMapsiLocationConfig.Denoised.Custom(
derivativeServiceConfig,
networkProvider,
MapsiNetworkConfig.Companion.getDefault(),
applicationInitializer,
newApplicationInfo("test")
);
mapsiLocation.start(mapsiLocationConfig);

Kotlin

val mapsiLocationConfig:MapsiLocationConfig=MapsiLocationConfig.Denoised.Custom(
derivativeServiceConfig = derivativeServiceConfig,
networkProvider = networkProvider,
mapsiNetworkConfig =MapsiNetworkConfig.default,
applicationInitializer = applicationInitializer,
applicationInfo =ApplicationInfo("test")
)
mapsiLocation.start(mapsiLocationConfig)

ResponseData

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.

Java

newResponseData(
200,
Map.of(),
jsonBody
);

Kotlin

ResponseData(
code =200,
headers =mapOf(),
body = jsonBody
)

Getting Location

After Mapsi Location has been initialized and started, there are two ways to request a location:

  1. Single Location
  2. Continuous Location

Single Location

Use getLocation when you need to obtain a location once.

Java

MapsiLocationListenermapsiLocationListener = location -> {
// Location received here
};
mapsiLocation.getLocation(
2000,
mapsiLocationListener
);

Kotlin

val mapsiLocationListener:MapsiLocationListener=object:MapsiLocationListener {
overridefunonLocationReceived(location:Location?) {
// Location received here
}
}
mapsiLocation.getLocation(
timeoutByMilliSecond =2000,
mapsiLocationListener = mapsiLocationListener
)

Timeout

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.


Cancel Single Location Request

If you need to cancel a single location request, use removeGetLocationListener.

Java

mapsiLocation.removeGetLocationListener(
mapsiLocationListener
);

Kotlin

mapsiLocation.removeGetLocationListener(
mapsiLocationListener = mapsiLocationListener
)

Important: You must pass the exact same MapsiLocationListener instance that was provided to getLocation.


Continuous Location

Use getLiveLocation when you need to continuously receive location updates.

Java

MapsiLocationListenermapsiLocationListener = location -> {
// Location received here
};
mapsiLocation.getLiveLocation(
2000,
mapsiLocationListener
);

Kotlin

val mapsiLocationListener:MapsiLocationListener=object:MapsiLocationListener {
overridefunonLocationReceived(location:Location?) {
// Location received here
}
}
mapsiLocation.getLiveLocation(
intervalByMilliSecond =2000,
mapsiLocationListener = mapsiLocationListener
)

intervalByMilliSecond

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.


Cancel Continuous Location

To stop receiving continuous location updates, call removeLiveLocationListener.

Java

mapsiLocation.removeLiveLocationListener(
mapsiLocationListener
);

Kotlin

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

MapsiNetworkConfig is an optional configuration that allows you to customize network-related behavior of Mapsi Location.

The default configuration is:

Kotlin

val default =MapsiNetworkConfig(
defaultDenoiseMethod =null,
denoiseMethods = emptyList(),
denoisingRequestTimeOutByMilliSecond =2000
)

The configuration contains three main properties:

PropertyDescription
defaultDenoiseMethodThe default denoise method used by the SDK
denoiseMethodsThe list of available denoise methods
denoisingRequestTimeOutByMilliSecondMaximum time to wait for the denoise API request

The default timeout for a denoising request is 2000 milliseconds.


Denoise Methods

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.

Kotlin

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.


Changing Denoise Method

You can change the active denoise method at runtime.

Java

mapsiLocation.updateDenoiseMethod(
secondDenoiseMethod
);

Kotlin

mapsiLocation.updateDenoiseMethod(
denoiseMethod = secondDenoiseMethod
)

This allows the application to switch between different denoise strategies without recreating the Mapsi Location instance.


Integration Summary

There are several ways to integrate Mapsi Location depending on your requirements.

ModeBackend RequiredAPI Key in AppCustom Network Layer
RawNoNoNo
Denoised / DefaultTapsi servicesYesNo
Denoised / CustomYour backendNoYes

Recommended Integration

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.


Complete Basic Flow

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

Important Notes

  • 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.
  • MapsiNetworkConfig can be used to customize denoising behavior.
  • Multiple denoise methods can be configured and switched at runtime.

Support

If you have any questions or encounter issues while integrating Mapsi Location, please contact the Tapsi technical team.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Force GitHub README to respect dark mode\n(function() {\n var style = document.createElement('style');\n style.textContent = '\n .markdown-body {\n color-scheme: dark light;\n }\n .markdown-body pre { background: #161b22 !important; }\n .markdown-body code { background: rgba(110, 118, 129, 0.4) !important; }\n .markdown-body table th, .markdown-body table td { border-color: #30363d !important; }\n .markdown-body img { background: #0d1117; }\n .markdown-body blockquote { border-left-color: #8b949e; }\n .markdown-body hr { border-color: #30363d; }\n ';\n document.head.appendChild(style);\n})();", "GitHub Dark Mode README Fix"); } } catch(__e) { console.warn('[Userscript:GitHub Dark Mode README Fix]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Repository files navigation

Mapsi Location SDK

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.


Table of Contents


Overview

Mapsi Location provides two different approaches for obtaining the user's location:

  1. Raw — Uses the location provided directly by the Android device.
  2. 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.


Location Modes

Raw

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.

Advantages

  • Simple integration
  • No backend configuration required
  • No API key required

Limitations

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.


Denoised

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:

  1. Default
  2. Custom

Sample Project

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.


Requirements

Before using Mapsi Location, make sure the following requirements are satisfied.

1. Location Permission

The application must have the required Android location permission.

2. Location Services

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.


Installation

Add the Mapsi Location dependency to your Android application.

Gradle

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


Initialization

First, create an instance of MapsiLocation.

Java

MapsiLocationmapsiLocation = newMapsiLocation();

Kotlin

val mapsiLocation =MapsiLocation()

Next, create an ApplicationInitializer using the Android Application instance.

Java

ApplicationInitializerapplicationInitializer =
newApplicationInitializer(getApplication());

Kotlin

val applicationInitializer =ApplicationInitializer(application)

The ApplicationInitializer is required when creating the Mapsi Location configuration.


Raw Mode

To use Raw mode, create a MapsiLocationConfig.Raw configuration and start Mapsi Location.

Java

MapsiLocationConfigmapsiLocationConfig =
newMapsiLocationConfig.Raw(
applicationInitializer,
newApplicationInfo("test")
);
mapsiLocation.start(mapsiLocationConfig);

Kotlin

val mapsiLocationConfig =MapsiLocationConfig.Raw(
applicationInitializer = applicationInitializer,
applicationInfo =ApplicationInfo("test")
)
mapsiLocation.start(mapsiLocationConfig)

ApplicationInfo

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

Denoised mode supports two different integration approaches:


Denoised Default

The Default integration requires an API key from Tapsi services.

Service Configuration

The Default integration requires the URLs for the authentication and location services.

Java

ServiceConfig.FullfullServiceConfig = newServiceConfig.Full(
newUrlConfig(
"auth url",
HttpRequestMethod.Post.INSTANCE
),
newUrlConfig(
"geo locate url",
HttpRequestMethod.Post.INSTANCE
)
);

Kotlin

val fullServiceConfig =ServiceConfig.Full(
authConfig =UrlConfig(
"auth url",
HttpRequestMethod.Post
),
getLocationConfig =UrlConfig(
"geo locate url",
HttpRequestMethod.Post
)
)

Then create the MapsiLocationConfig.Denoised.Default configuration.

Java

MapsiLocationConfigmapsiLocationConfig =
newMapsiLocationConfig.Denoised.Default(
API_KEY,
fullServiceConfig,
MapsiNetworkConfig.Companion.getDefault(),
applicationInitializer,
newApplicationInfo("test")
);
mapsiLocation.start(mapsiLocationConfig);

Kotlin

val mapsiLocationConfig:MapsiLocationConfig=MapsiLocationConfig.Denoised.Default(
apiKey =API_KEY,
fullServiceConfig = fullServiceConfig,
mapsiNetworkConfig =MapsiNetworkConfig.default,
applicationInitializer = applicationInitializer,
applicationInfo =ApplicationInfo("test")
)
mapsiLocation.start(mapsiLocationConfig)

Configuration Parameters

The Default configuration contains:

ParameterDescription
apiKeyAPI key provided by Tapsi services
fullServiceConfigConfiguration of authentication and location endpoints
mapsiNetworkConfigOptional network-related configuration
applicationInitializerApplication initializer
applicationInfoOptional identifier used by the SDK for storing required data

The authentication and location URLs must be provided through ServiceConfig.Full.


Denoised Custom

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.

Service Configuration

For Custom mode, you need to provide the URL of your application's location endpoint.

Java

ServiceConfig.DerivativederivativeServiceConfig =
newServiceConfig.Derivative(
newUrlConfig(
"your server url",
HttpRequestMethod.Post.INSTANCE
)
);

Kotlin

val derivativeServiceConfig =ServiceConfig.Derivative(
UrlConfig(
"your server url",
HttpRequestMethod.Post
)
)

NetworkProvider

The library uses NetworkProvider to communicate with your application's backend.

Java

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.
}
);

Kotlin

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.


Starting Custom Mode

Java

MapsiLocationConfigmapsiLocationConfig =
newMapsiLocationConfig.Denoised.Custom(
derivativeServiceConfig,
networkProvider,
MapsiNetworkConfig.Companion.getDefault(),
applicationInitializer,
newApplicationInfo("test")
);
mapsiLocation.start(mapsiLocationConfig);

Kotlin

val mapsiLocationConfig:MapsiLocationConfig=MapsiLocationConfig.Denoised.Custom(
derivativeServiceConfig = derivativeServiceConfig,
networkProvider = networkProvider,
mapsiNetworkConfig =MapsiNetworkConfig.default,
applicationInitializer = applicationInitializer,
applicationInfo =ApplicationInfo("test")
)
mapsiLocation.start(mapsiLocationConfig)

ResponseData

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.

Java

newResponseData(
200,
Map.of(),
jsonBody
);

Kotlin

ResponseData(
code =200,
headers =mapOf(),
body = jsonBody
)

Getting Location

After Mapsi Location has been initialized and started, there are two ways to request a location:

  1. Single Location
  2. Continuous Location

Single Location

Use getLocation when you need to obtain a location once.

Java

MapsiLocationListenermapsiLocationListener = location -> {
// Location received here
};
mapsiLocation.getLocation(
2000,
mapsiLocationListener
);

Kotlin

val mapsiLocationListener:MapsiLocationListener=object:MapsiLocationListener {
overridefunonLocationReceived(location:Location?) {
// Location received here
}
}
mapsiLocation.getLocation(
timeoutByMilliSecond =2000,
mapsiLocationListener = mapsiLocationListener
)

Timeout

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.


Cancel Single Location Request

If you need to cancel a single location request, use removeGetLocationListener.

Java

mapsiLocation.removeGetLocationListener(
mapsiLocationListener
);

Kotlin

mapsiLocation.removeGetLocationListener(
mapsiLocationListener = mapsiLocationListener
)

Important: You must pass the exact same MapsiLocationListener instance that was provided to getLocation.


Continuous Location

Use getLiveLocation when you need to continuously receive location updates.

Java

MapsiLocationListenermapsiLocationListener = location -> {
// Location received here
};
mapsiLocation.getLiveLocation(
2000,
mapsiLocationListener
);

Kotlin

val mapsiLocationListener:MapsiLocationListener=object:MapsiLocationListener {
overridefunonLocationReceived(location:Location?) {
// Location received here
}
}
mapsiLocation.getLiveLocation(
intervalByMilliSecond =2000,
mapsiLocationListener = mapsiLocationListener
)

intervalByMilliSecond

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.


Cancel Continuous Location

To stop receiving continuous location updates, call removeLiveLocationListener.

Java

mapsiLocation.removeLiveLocationListener(
mapsiLocationListener
);

Kotlin

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

MapsiNetworkConfig is an optional configuration that allows you to customize network-related behavior of Mapsi Location.

The default configuration is:

Kotlin

val default =MapsiNetworkConfig(
defaultDenoiseMethod =null,
denoiseMethods = emptyList(),
denoisingRequestTimeOutByMilliSecond =2000
)

The configuration contains three main properties:

PropertyDescription
defaultDenoiseMethodThe default denoise method used by the SDK
denoiseMethodsThe list of available denoise methods
denoisingRequestTimeOutByMilliSecondMaximum time to wait for the denoise API request

The default timeout for a denoising request is 2000 milliseconds.


Denoise Methods

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.

Kotlin

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.


Changing Denoise Method

You can change the active denoise method at runtime.

Java

mapsiLocation.updateDenoiseMethod(
secondDenoiseMethod
);

Kotlin

mapsiLocation.updateDenoiseMethod(
denoiseMethod = secondDenoiseMethod
)

This allows the application to switch between different denoise strategies without recreating the Mapsi Location instance.


Integration Summary

There are several ways to integrate Mapsi Location depending on your requirements.

ModeBackend RequiredAPI Key in AppCustom Network Layer
RawNoNoNo
Denoised / DefaultTapsi servicesYesNo
Denoised / CustomYour backendNoYes

Recommended Integration

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.


Complete Basic Flow

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

Important Notes

  • 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.
  • MapsiNetworkConfig can be used to customize denoising behavior.
  • Multiple denoise methods can be configured and switched at runtime.

Support

If you have any questions or encounter issues while integrating Mapsi Location, please contact the Tapsi technical team.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Highlight search terms from Google/DuckDuckGo/Bing referrer\n(function() {\n var ref = document.referrer;\n var terms = [];\n \n if (ref.includes('google.com') || ref.includes('duckduckgo.com') || ref.includes('bing.com')) {\n var url = new URL(ref);\n var q = url.searchParams.get('q') || url.searchParams.get('p');\n if (q) {\n terms = q.split(/\\s+/).filter(function(t) { return t.length > 2; });\n }\n }\n \n if (terms.length === 0) return;\n \n var style = document.createElement('style');\n style.textContent = '.userscript-highlight { background: #fbbf24; color: #1a1a2e; padding: 1px 3px; border-radius: 2px; }';\n document.head.appendChild(style);\n \n function highlight(node) {\n if (node.nodeType === 3) { // text node\n var text = node.textContent;\n var found = false;\n terms.forEach(function(term) {\n var regex = new RegExp('(' + term.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\') + ')', 'gi');\n if (regex.test(text)) {\n found = true;\n var frag = document.createDocumentFragment();\n var parts = text.split(regex);\n parts.forEach(function(part, i) {\n if (i % 2 === 0) {\n frag.appendChild(document.createTextNode(part));\n } else {\n var span = document.createElement('span');\n span.className = 'userscript-highlight';\n span.textContent = part;\n frag.appendChild(span);\n }\n });\n node.parentNode.replaceChild(frag, node);\n }\n });\n } else if (node.nodeType === 1 && node.childNodes) { // element\n var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT'];\n if (!skipTags.includes(node.tagName)) {\n Array.from(node.childNodes).forEach(highlight);\n }\n }\n }\n \n highlight(document.body);\n \n // Re-highlight on dynamic content\n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1 || node.nodeType === 3) highlight(node);\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Highlight Search Terms"); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Repository files navigation

Mapsi Location SDK

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.


Table of Contents


Overview

Mapsi Location provides two different approaches for obtaining the user's location:

  1. Raw — Uses the location provided directly by the Android device.
  2. 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.


Location Modes

Raw

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.

Advantages

  • Simple integration
  • No backend configuration required
  • No API key required

Limitations

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.


Denoised

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:

  1. Default
  2. Custom

Sample Project

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.


Requirements

Before using Mapsi Location, make sure the following requirements are satisfied.

1. Location Permission

The application must have the required Android location permission.

2. Location Services

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.


Installation

Add the Mapsi Location dependency to your Android application.

Gradle

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


Initialization

First, create an instance of MapsiLocation.

Java

MapsiLocationmapsiLocation = newMapsiLocation();

Kotlin

val mapsiLocation =MapsiLocation()

Next, create an ApplicationInitializer using the Android Application instance.

Java

ApplicationInitializerapplicationInitializer =
newApplicationInitializer(getApplication());

Kotlin

val applicationInitializer =ApplicationInitializer(application)

The ApplicationInitializer is required when creating the Mapsi Location configuration.


Raw Mode

To use Raw mode, create a MapsiLocationConfig.Raw configuration and start Mapsi Location.

Java

MapsiLocationConfigmapsiLocationConfig =
newMapsiLocationConfig.Raw(
applicationInitializer,
newApplicationInfo("test")
);
mapsiLocation.start(mapsiLocationConfig);

Kotlin

val mapsiLocationConfig =MapsiLocationConfig.Raw(
applicationInitializer = applicationInitializer,
applicationInfo =ApplicationInfo("test")
)
mapsiLocation.start(mapsiLocationConfig)

ApplicationInfo

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

Denoised mode supports two different integration approaches:


Denoised Default

The Default integration requires an API key from Tapsi services.

Service Configuration

The Default integration requires the URLs for the authentication and location services.

Java

ServiceConfig.FullfullServiceConfig = newServiceConfig.Full(
newUrlConfig(
"auth url",
HttpRequestMethod.Post.INSTANCE
),
newUrlConfig(
"geo locate url",
HttpRequestMethod.Post.INSTANCE
)
);

Kotlin

val fullServiceConfig =ServiceConfig.Full(
authConfig =UrlConfig(
"auth url",
HttpRequestMethod.Post
),
getLocationConfig =UrlConfig(
"geo locate url",
HttpRequestMethod.Post
)
)

Then create the MapsiLocationConfig.Denoised.Default configuration.

Java

MapsiLocationConfigmapsiLocationConfig =
newMapsiLocationConfig.Denoised.Default(
API_KEY,
fullServiceConfig,
MapsiNetworkConfig.Companion.getDefault(),
applicationInitializer,
newApplicationInfo("test")
);
mapsiLocation.start(mapsiLocationConfig);

Kotlin

val mapsiLocationConfig:MapsiLocationConfig=MapsiLocationConfig.Denoised.Default(
apiKey =API_KEY,
fullServiceConfig = fullServiceConfig,
mapsiNetworkConfig =MapsiNetworkConfig.default,
applicationInitializer = applicationInitializer,
applicationInfo =ApplicationInfo("test")
)
mapsiLocation.start(mapsiLocationConfig)

Configuration Parameters

The Default configuration contains:

ParameterDescription
apiKeyAPI key provided by Tapsi services
fullServiceConfigConfiguration of authentication and location endpoints
mapsiNetworkConfigOptional network-related configuration
applicationInitializerApplication initializer
applicationInfoOptional identifier used by the SDK for storing required data

The authentication and location URLs must be provided through ServiceConfig.Full.


Denoised Custom

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.

Service Configuration

For Custom mode, you need to provide the URL of your application's location endpoint.

Java

ServiceConfig.DerivativederivativeServiceConfig =
newServiceConfig.Derivative(
newUrlConfig(
"your server url",
HttpRequestMethod.Post.INSTANCE
)
);

Kotlin

val derivativeServiceConfig =ServiceConfig.Derivative(
UrlConfig(
"your server url",
HttpRequestMethod.Post
)
)

NetworkProvider

The library uses NetworkProvider to communicate with your application's backend.

Java

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.
}
);

Kotlin

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.


Starting Custom Mode

Java

MapsiLocationConfigmapsiLocationConfig =
newMapsiLocationConfig.Denoised.Custom(
derivativeServiceConfig,
networkProvider,
MapsiNetworkConfig.Companion.getDefault(),
applicationInitializer,
newApplicationInfo("test")
);
mapsiLocation.start(mapsiLocationConfig);

Kotlin

val mapsiLocationConfig:MapsiLocationConfig=MapsiLocationConfig.Denoised.Custom(
derivativeServiceConfig = derivativeServiceConfig,
networkProvider = networkProvider,
mapsiNetworkConfig =MapsiNetworkConfig.default,
applicationInitializer = applicationInitializer,
applicationInfo =ApplicationInfo("test")
)
mapsiLocation.start(mapsiLocationConfig)

ResponseData

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.

Java

newResponseData(
200,
Map.of(),
jsonBody
);

Kotlin

ResponseData(
code =200,
headers =mapOf(),
body = jsonBody
)

Getting Location

After Mapsi Location has been initialized and started, there are two ways to request a location:

  1. Single Location
  2. Continuous Location

Single Location

Use getLocation when you need to obtain a location once.

Java

MapsiLocationListenermapsiLocationListener = location -> {
// Location received here
};
mapsiLocation.getLocation(
2000,
mapsiLocationListener
);

Kotlin

val mapsiLocationListener:MapsiLocationListener=object:MapsiLocationListener {
overridefunonLocationReceived(location:Location?) {
// Location received here
}
}
mapsiLocation.getLocation(
timeoutByMilliSecond =2000,
mapsiLocationListener = mapsiLocationListener
)

Timeout

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.


Cancel Single Location Request

If you need to cancel a single location request, use removeGetLocationListener.

Java

mapsiLocation.removeGetLocationListener(
mapsiLocationListener
);

Kotlin

mapsiLocation.removeGetLocationListener(
mapsiLocationListener = mapsiLocationListener
)

Important: You must pass the exact same MapsiLocationListener instance that was provided to getLocation.


Continuous Location

Use getLiveLocation when you need to continuously receive location updates.

Java

MapsiLocationListenermapsiLocationListener = location -> {
// Location received here
};
mapsiLocation.getLiveLocation(
2000,
mapsiLocationListener
);

Kotlin

val mapsiLocationListener:MapsiLocationListener=object:MapsiLocationListener {
overridefunonLocationReceived(location:Location?) {
// Location received here
}
}
mapsiLocation.getLiveLocation(
intervalByMilliSecond =2000,
mapsiLocationListener = mapsiLocationListener
)

intervalByMilliSecond

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.


Cancel Continuous Location

To stop receiving continuous location updates, call removeLiveLocationListener.

Java

mapsiLocation.removeLiveLocationListener(
mapsiLocationListener
);

Kotlin

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

MapsiNetworkConfig is an optional configuration that allows you to customize network-related behavior of Mapsi Location.

The default configuration is:

Kotlin

val default =MapsiNetworkConfig(
defaultDenoiseMethod =null,
denoiseMethods = emptyList(),
denoisingRequestTimeOutByMilliSecond =2000
)

The configuration contains three main properties:

PropertyDescription
defaultDenoiseMethodThe default denoise method used by the SDK
denoiseMethodsThe list of available denoise methods
denoisingRequestTimeOutByMilliSecondMaximum time to wait for the denoise API request

The default timeout for a denoising request is 2000 milliseconds.


Denoise Methods

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.

Kotlin

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.


Changing Denoise Method

You can change the active denoise method at runtime.

Java

mapsiLocation.updateDenoiseMethod(
secondDenoiseMethod
);

Kotlin

mapsiLocation.updateDenoiseMethod(
denoiseMethod = secondDenoiseMethod
)

This allows the application to switch between different denoise strategies without recreating the Mapsi Location instance.


Integration Summary

There are several ways to integrate Mapsi Location depending on your requirements.

ModeBackend RequiredAPI Key in AppCustom Network Layer
RawNoNoNo
Denoised / DefaultTapsi servicesYesNo
Denoised / CustomYour backendNoYes

Recommended Integration

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.


Complete Basic Flow

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

Important Notes

  • 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.
  • MapsiNetworkConfig can be used to customize denoising behavior.
  • Multiple denoise methods can be configured and switched at runtime.

Support

If you have any questions or encounter issues while integrating Mapsi Location, please contact the Tapsi technical team.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Strip utm_, fbclid, gclid, etc. from all links on page\n(function() {\n var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content',\n 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid',\n 'ref', 'ref_src', 'source', 'medium', 'campaign'];\n \n function cleanUrl(url) {\n try {\n var u = new URL(url, window.location.origin);\n var changed = false;\n trackingParams.forEach(function(p) {\n if (u.searchParams.has(p)) {\n u.searchParams.delete(p);\n changed = true;\n }\n });\n return changed ? u.toString() : url;\n } catch (e) {\n return url;\n }\n }\n \n function cleanLinks() {\n document.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n \n cleanLinks();\n \n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1) {\n if (node.tagName === 'A') cleanLinks();\n node.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Remove Tracking Parameters from Links"); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + '
Skip to content

Repository files navigation

Mapsi Location SDK

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.


Table of Contents


Overview

Mapsi Location provides two different approaches for obtaining the user's location:

  1. Raw — Uses the location provided directly by the Android device.
  2. 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.


Location Modes

Raw

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.

Advantages

  • Simple integration
  • No backend configuration required
  • No API key required

Limitations

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.


Denoised

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:

  1. Default
  2. Custom

Sample Project

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.


Requirements

Before using Mapsi Location, make sure the following requirements are satisfied.

1. Location Permission

The application must have the required Android location permission.

2. Location Services

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.


Installation

Add the Mapsi Location dependency to your Android application.

Gradle

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


Initialization

First, create an instance of MapsiLocation.

Java

MapsiLocationmapsiLocation = newMapsiLocation();

Kotlin

val mapsiLocation =MapsiLocation()

Next, create an ApplicationInitializer using the Android Application instance.

Java

ApplicationInitializerapplicationInitializer =
newApplicationInitializer(getApplication());

Kotlin

val applicationInitializer =ApplicationInitializer(application)

The ApplicationInitializer is required when creating the Mapsi Location configuration.


Raw Mode

To use Raw mode, create a MapsiLocationConfig.Raw configuration and start Mapsi Location.

Java

MapsiLocationConfigmapsiLocationConfig =
newMapsiLocationConfig.Raw(
applicationInitializer,
newApplicationInfo("test")
);
mapsiLocation.start(mapsiLocationConfig);

Kotlin

val mapsiLocationConfig =MapsiLocationConfig.Raw(
applicationInitializer = applicationInitializer,
applicationInfo =ApplicationInfo("test")
)
mapsiLocation.start(mapsiLocationConfig)

ApplicationInfo

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

Denoised mode supports two different integration approaches:


Denoised Default

The Default integration requires an API key from Tapsi services.

Service Configuration

The Default integration requires the URLs for the authentication and location services.

Java

ServiceConfig.FullfullServiceConfig = newServiceConfig.Full(
newUrlConfig(
"auth url",
HttpRequestMethod.Post.INSTANCE
),
newUrlConfig(
"geo locate url",
HttpRequestMethod.Post.INSTANCE
)
);

Kotlin

val fullServiceConfig =ServiceConfig.Full(
authConfig =UrlConfig(
"auth url",
HttpRequestMethod.Post
),
getLocationConfig =UrlConfig(
"geo locate url",
HttpRequestMethod.Post
)
)

Then create the MapsiLocationConfig.Denoised.Default configuration.

Java

MapsiLocationConfigmapsiLocationConfig =
newMapsiLocationConfig.Denoised.Default(
API_KEY,
fullServiceConfig,
MapsiNetworkConfig.Companion.getDefault(),
applicationInitializer,
newApplicationInfo("test")
);
mapsiLocation.start(mapsiLocationConfig);

Kotlin

val mapsiLocationConfig:MapsiLocationConfig=MapsiLocationConfig.Denoised.Default(
apiKey =API_KEY,
fullServiceConfig = fullServiceConfig,
mapsiNetworkConfig =MapsiNetworkConfig.default,
applicationInitializer = applicationInitializer,
applicationInfo =ApplicationInfo("test")
)
mapsiLocation.start(mapsiLocationConfig)

Configuration Parameters

The Default configuration contains:

ParameterDescription
apiKeyAPI key provided by Tapsi services
fullServiceConfigConfiguration of authentication and location endpoints
mapsiNetworkConfigOptional network-related configuration
applicationInitializerApplication initializer
applicationInfoOptional identifier used by the SDK for storing required data

The authentication and location URLs must be provided through ServiceConfig.Full.


Denoised Custom

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.

Service Configuration

For Custom mode, you need to provide the URL of your application's location endpoint.

Java

ServiceConfig.DerivativederivativeServiceConfig =
newServiceConfig.Derivative(
newUrlConfig(
"your server url",
HttpRequestMethod.Post.INSTANCE
)
);

Kotlin

val derivativeServiceConfig =ServiceConfig.Derivative(
UrlConfig(
"your server url",
HttpRequestMethod.Post
)
)

NetworkProvider

The library uses NetworkProvider to communicate with your application's backend.

Java

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.
}
);

Kotlin

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.


Starting Custom Mode

Java

MapsiLocationConfigmapsiLocationConfig =
newMapsiLocationConfig.Denoised.Custom(
derivativeServiceConfig,
networkProvider,
MapsiNetworkConfig.Companion.getDefault(),
applicationInitializer,
newApplicationInfo("test")
);
mapsiLocation.start(mapsiLocationConfig);

Kotlin

val mapsiLocationConfig:MapsiLocationConfig=MapsiLocationConfig.Denoised.Custom(
derivativeServiceConfig = derivativeServiceConfig,
networkProvider = networkProvider,
mapsiNetworkConfig =MapsiNetworkConfig.default,
applicationInitializer = applicationInitializer,
applicationInfo =ApplicationInfo("test")
)
mapsiLocation.start(mapsiLocationConfig)

ResponseData

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.

Java

newResponseData(
200,
Map.of(),
jsonBody
);

Kotlin

ResponseData(
code =200,
headers =mapOf(),
body = jsonBody
)

Getting Location

After Mapsi Location has been initialized and started, there are two ways to request a location:

  1. Single Location
  2. Continuous Location

Single Location

Use getLocation when you need to obtain a location once.

Java

MapsiLocationListenermapsiLocationListener = location -> {
// Location received here
};
mapsiLocation.getLocation(
2000,
mapsiLocationListener
);

Kotlin

val mapsiLocationListener:MapsiLocationListener=object:MapsiLocationListener {
overridefunonLocationReceived(location:Location?) {
// Location received here
}
}
mapsiLocation.getLocation(
timeoutByMilliSecond =2000,
mapsiLocationListener = mapsiLocationListener
)

Timeout

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.


Cancel Single Location Request

If you need to cancel a single location request, use removeGetLocationListener.

Java

mapsiLocation.removeGetLocationListener(
mapsiLocationListener
);

Kotlin

mapsiLocation.removeGetLocationListener(
mapsiLocationListener = mapsiLocationListener
)

Important: You must pass the exact same MapsiLocationListener instance that was provided to getLocation.


Continuous Location

Use getLiveLocation when you need to continuously receive location updates.

Java

MapsiLocationListenermapsiLocationListener = location -> {
// Location received here
};
mapsiLocation.getLiveLocation(
2000,
mapsiLocationListener
);

Kotlin

val mapsiLocationListener:MapsiLocationListener=object:MapsiLocationListener {
overridefunonLocationReceived(location:Location?) {
// Location received here
}
}
mapsiLocation.getLiveLocation(
intervalByMilliSecond =2000,
mapsiLocationListener = mapsiLocationListener
)

intervalByMilliSecond

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.


Cancel Continuous Location

To stop receiving continuous location updates, call removeLiveLocationListener.

Java

mapsiLocation.removeLiveLocationListener(
mapsiLocationListener
);

Kotlin

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

MapsiNetworkConfig is an optional configuration that allows you to customize network-related behavior of Mapsi Location.

The default configuration is:

Kotlin

val default =MapsiNetworkConfig(
defaultDenoiseMethod =null,
denoiseMethods = emptyList(),
denoisingRequestTimeOutByMilliSecond =2000
)

The configuration contains three main properties:

PropertyDescription
defaultDenoiseMethodThe default denoise method used by the SDK
denoiseMethodsThe list of available denoise methods
denoisingRequestTimeOutByMilliSecondMaximum time to wait for the denoise API request

The default timeout for a denoising request is 2000 milliseconds.


Denoise Methods

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.

Kotlin

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.


Changing Denoise Method

You can change the active denoise method at runtime.

Java

mapsiLocation.updateDenoiseMethod(
secondDenoiseMethod
);

Kotlin

mapsiLocation.updateDenoiseMethod(
denoiseMethod = secondDenoiseMethod
)

This allows the application to switch between different denoise strategies without recreating the Mapsi Location instance.


Integration Summary

There are several ways to integrate Mapsi Location depending on your requirements.

ModeBackend RequiredAPI Key in AppCustom Network Layer
RawNoNoNo
Denoised / DefaultTapsi servicesYesNo
Denoised / CustomYour backendNoYes

Recommended Integration

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.


Complete Basic Flow

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

Important Notes

  • 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.
  • MapsiNetworkConfig can be used to customize denoising behavior.
  • Multiple denoise methods can be configured and switched at runtime.

Support

If you have any questions or encounter issues while integrating Mapsi Location, please contact the Tapsi technical team.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Auto-enable theater mode on YouTube\n(function() {\n function tryTheater() {\n var btn = document.querySelector('button[aria-label=\"Theater mode\"], ytd-player #player button[title=\"Theater mode\"]');\n if (btn && !btn.classList.contains('activated')) {\n btn.click();\n }\n }\n \n // Try immediately\n tryTheater();\n \n // Try after navigation (SPA)\n var lastUrl = location.href;\n setInterval(function() {\n if (location.href !== lastUrl) {\n lastUrl = location.href;\n setTimeout(tryTheater, 500);\n }\n }, 1000);\n \n // Also try on player load\n var observer = new MutationObserver(tryTheater);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "YouTube Theater Mode Default"); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Repository files navigation

Mapsi Location SDK

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.


Table of Contents


Overview

Mapsi Location provides two different approaches for obtaining the user's location:

  1. Raw — Uses the location provided directly by the Android device.
  2. 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.


Location Modes

Raw

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.

Advantages

  • Simple integration
  • No backend configuration required
  • No API key required

Limitations

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.


Denoised

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:

  1. Default
  2. Custom

Sample Project

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.


Requirements

Before using Mapsi Location, make sure the following requirements are satisfied.

1. Location Permission

The application must have the required Android location permission.

2. Location Services

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.


Installation

Add the Mapsi Location dependency to your Android application.

Gradle

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


Initialization

First, create an instance of MapsiLocation.

Java

MapsiLocationmapsiLocation = newMapsiLocation();

Kotlin

val mapsiLocation =MapsiLocation()

Next, create an ApplicationInitializer using the Android Application instance.

Java

ApplicationInitializerapplicationInitializer =
newApplicationInitializer(getApplication());

Kotlin

val applicationInitializer =ApplicationInitializer(application)

The ApplicationInitializer is required when creating the Mapsi Location configuration.


Raw Mode

To use Raw mode, create a MapsiLocationConfig.Raw configuration and start Mapsi Location.

Java

MapsiLocationConfigmapsiLocationConfig =
newMapsiLocationConfig.Raw(
applicationInitializer,
newApplicationInfo("test")
);
mapsiLocation.start(mapsiLocationConfig);

Kotlin

val mapsiLocationConfig =MapsiLocationConfig.Raw(
applicationInitializer = applicationInitializer,
applicationInfo =ApplicationInfo("test")
)
mapsiLocation.start(mapsiLocationConfig)

ApplicationInfo

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

Denoised mode supports two different integration approaches:


Denoised Default

The Default integration requires an API key from Tapsi services.

Service Configuration

The Default integration requires the URLs for the authentication and location services.

Java

ServiceConfig.FullfullServiceConfig = newServiceConfig.Full(
newUrlConfig(
"auth url",
HttpRequestMethod.Post.INSTANCE
),
newUrlConfig(
"geo locate url",
HttpRequestMethod.Post.INSTANCE
)
);

Kotlin

val fullServiceConfig =ServiceConfig.Full(
authConfig =UrlConfig(
"auth url",
HttpRequestMethod.Post
),
getLocationConfig =UrlConfig(
"geo locate url",
HttpRequestMethod.Post
)
)

Then create the MapsiLocationConfig.Denoised.Default configuration.

Java

MapsiLocationConfigmapsiLocationConfig =
newMapsiLocationConfig.Denoised.Default(
API_KEY,
fullServiceConfig,
MapsiNetworkConfig.Companion.getDefault(),
applicationInitializer,
newApplicationInfo("test")
);
mapsiLocation.start(mapsiLocationConfig);

Kotlin

val mapsiLocationConfig:MapsiLocationConfig=MapsiLocationConfig.Denoised.Default(
apiKey =API_KEY,
fullServiceConfig = fullServiceConfig,
mapsiNetworkConfig =MapsiNetworkConfig.default,
applicationInitializer = applicationInitializer,
applicationInfo =ApplicationInfo("test")
)
mapsiLocation.start(mapsiLocationConfig)

Configuration Parameters

The Default configuration contains:

ParameterDescription
apiKeyAPI key provided by Tapsi services
fullServiceConfigConfiguration of authentication and location endpoints
mapsiNetworkConfigOptional network-related configuration
applicationInitializerApplication initializer
applicationInfoOptional identifier used by the SDK for storing required data

The authentication and location URLs must be provided through ServiceConfig.Full.


Denoised Custom

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.

Service Configuration

For Custom mode, you need to provide the URL of your application's location endpoint.

Java

ServiceConfig.DerivativederivativeServiceConfig =
newServiceConfig.Derivative(
newUrlConfig(
"your server url",
HttpRequestMethod.Post.INSTANCE
)
);

Kotlin

val derivativeServiceConfig =ServiceConfig.Derivative(
UrlConfig(
"your server url",
HttpRequestMethod.Post
)
)

NetworkProvider

The library uses NetworkProvider to communicate with your application's backend.

Java

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.
}
);

Kotlin

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.


Starting Custom Mode

Java

MapsiLocationConfigmapsiLocationConfig =
newMapsiLocationConfig.Denoised.Custom(
derivativeServiceConfig,
networkProvider,
MapsiNetworkConfig.Companion.getDefault(),
applicationInitializer,
newApplicationInfo("test")
);
mapsiLocation.start(mapsiLocationConfig);

Kotlin

val mapsiLocationConfig:MapsiLocationConfig=MapsiLocationConfig.Denoised.Custom(
derivativeServiceConfig = derivativeServiceConfig,
networkProvider = networkProvider,
mapsiNetworkConfig =MapsiNetworkConfig.default,
applicationInitializer = applicationInitializer,
applicationInfo =ApplicationInfo("test")
)
mapsiLocation.start(mapsiLocationConfig)

ResponseData

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.

Java

newResponseData(
200,
Map.of(),
jsonBody
);

Kotlin

ResponseData(
code =200,
headers =mapOf(),
body = jsonBody
)

Getting Location

After Mapsi Location has been initialized and started, there are two ways to request a location:

  1. Single Location
  2. Continuous Location

Single Location

Use getLocation when you need to obtain a location once.

Java

MapsiLocationListenermapsiLocationListener = location -> {
// Location received here
};
mapsiLocation.getLocation(
2000,
mapsiLocationListener
);

Kotlin

val mapsiLocationListener:MapsiLocationListener=object:MapsiLocationListener {
overridefunonLocationReceived(location:Location?) {
// Location received here
}
}
mapsiLocation.getLocation(
timeoutByMilliSecond =2000,
mapsiLocationListener = mapsiLocationListener
)

Timeout

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.


Cancel Single Location Request

If you need to cancel a single location request, use removeGetLocationListener.

Java

mapsiLocation.removeGetLocationListener(
mapsiLocationListener
);

Kotlin

mapsiLocation.removeGetLocationListener(
mapsiLocationListener = mapsiLocationListener
)

Important: You must pass the exact same MapsiLocationListener instance that was provided to getLocation.


Continuous Location

Use getLiveLocation when you need to continuously receive location updates.

Java

MapsiLocationListenermapsiLocationListener = location -> {
// Location received here
};
mapsiLocation.getLiveLocation(
2000,
mapsiLocationListener
);

Kotlin

val mapsiLocationListener:MapsiLocationListener=object:MapsiLocationListener {
overridefunonLocationReceived(location:Location?) {
// Location received here
}
}
mapsiLocation.getLiveLocation(
intervalByMilliSecond =2000,
mapsiLocationListener = mapsiLocationListener
)

intervalByMilliSecond

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.


Cancel Continuous Location

To stop receiving continuous location updates, call removeLiveLocationListener.

Java

mapsiLocation.removeLiveLocationListener(
mapsiLocationListener
);

Kotlin

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

MapsiNetworkConfig is an optional configuration that allows you to customize network-related behavior of Mapsi Location.

The default configuration is:

Kotlin

val default =MapsiNetworkConfig(
defaultDenoiseMethod =null,
denoiseMethods = emptyList(),
denoisingRequestTimeOutByMilliSecond =2000
)

The configuration contains three main properties:

PropertyDescription
defaultDenoiseMethodThe default denoise method used by the SDK
denoiseMethodsThe list of available denoise methods
denoisingRequestTimeOutByMilliSecondMaximum time to wait for the denoise API request

The default timeout for a denoising request is 2000 milliseconds.


Denoise Methods

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.

Kotlin

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.


Changing Denoise Method

You can change the active denoise method at runtime.

Java

mapsiLocation.updateDenoiseMethod(
secondDenoiseMethod
);

Kotlin

mapsiLocation.updateDenoiseMethod(
denoiseMethod = secondDenoiseMethod
)

This allows the application to switch between different denoise strategies without recreating the Mapsi Location instance.


Integration Summary

There are several ways to integrate Mapsi Location depending on your requirements.

ModeBackend RequiredAPI Key in AppCustom Network Layer
RawNoNoNo
Denoised / DefaultTapsi servicesYesNo
Denoised / CustomYour backendNoYes

Recommended Integration

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.


Complete Basic Flow

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

Important Notes

  • 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.
  • MapsiNetworkConfig can be used to customize denoising behavior.
  • Multiple denoise methods can be configured and switched at runtime.

Support

If you have any questions or encounter issues while integrating Mapsi Location, please contact the Tapsi technical team.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Remove or un-stick sticky/fixed headers that block content\n(function() {\n function unstick() {\n document.querySelectorAll('header, nav, [role=\"banner\"], .header, .navbar, .sticky, .fixed-top, [style*=\"position: fixed\"], [style*=\"position:sticky\"]').forEach(function(el) {\n if (el.style.position === 'fixed' || el.style.position === 'sticky' || \n getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') {\n el.style.position = 'static';\n el.style.top = 'auto';\n el.style.zIndex = 'auto';\n }\n });\n }\n \n unstick();\n \n var observer = new MutationObserver(unstick);\n observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] });\n})();", "Kill Sticky Headers"); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Repository files navigation

Mapsi Location SDK

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.


Table of Contents


Overview

Mapsi Location provides two different approaches for obtaining the user's location:

  1. Raw — Uses the location provided directly by the Android device.
  2. 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.


Location Modes

Raw

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.

Advantages

  • Simple integration
  • No backend configuration required
  • No API key required

Limitations

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.


Denoised

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:

  1. Default
  2. Custom

Sample Project

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.


Requirements

Before using Mapsi Location, make sure the following requirements are satisfied.

1. Location Permission

The application must have the required Android location permission.

2. Location Services

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.


Installation

Add the Mapsi Location dependency to your Android application.

Gradle

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


Initialization

First, create an instance of MapsiLocation.

Java

MapsiLocationmapsiLocation = newMapsiLocation();

Kotlin

val mapsiLocation =MapsiLocation()

Next, create an ApplicationInitializer using the Android Application instance.

Java

ApplicationInitializerapplicationInitializer =
newApplicationInitializer(getApplication());

Kotlin

val applicationInitializer =ApplicationInitializer(application)

The ApplicationInitializer is required when creating the Mapsi Location configuration.


Raw Mode

To use Raw mode, create a MapsiLocationConfig.Raw configuration and start Mapsi Location.

Java

MapsiLocationConfigmapsiLocationConfig =
newMapsiLocationConfig.Raw(
applicationInitializer,
newApplicationInfo("test")
);
mapsiLocation.start(mapsiLocationConfig);

Kotlin

val mapsiLocationConfig =MapsiLocationConfig.Raw(
applicationInitializer = applicationInitializer,
applicationInfo =ApplicationInfo("test")
)
mapsiLocation.start(mapsiLocationConfig)

ApplicationInfo

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

Denoised mode supports two different integration approaches:


Denoised Default

The Default integration requires an API key from Tapsi services.

Service Configuration

The Default integration requires the URLs for the authentication and location services.

Java

ServiceConfig.FullfullServiceConfig = newServiceConfig.Full(
newUrlConfig(
"auth url",
HttpRequestMethod.Post.INSTANCE
),
newUrlConfig(
"geo locate url",
HttpRequestMethod.Post.INSTANCE
)
);

Kotlin

val fullServiceConfig =ServiceConfig.Full(
authConfig =UrlConfig(
"auth url",
HttpRequestMethod.Post
),
getLocationConfig =UrlConfig(
"geo locate url",
HttpRequestMethod.Post
)
)

Then create the MapsiLocationConfig.Denoised.Default configuration.

Java

MapsiLocationConfigmapsiLocationConfig =
newMapsiLocationConfig.Denoised.Default(
API_KEY,
fullServiceConfig,
MapsiNetworkConfig.Companion.getDefault(),
applicationInitializer,
newApplicationInfo("test")
);
mapsiLocation.start(mapsiLocationConfig);

Kotlin

val mapsiLocationConfig:MapsiLocationConfig=MapsiLocationConfig.Denoised.Default(
apiKey =API_KEY,
fullServiceConfig = fullServiceConfig,
mapsiNetworkConfig =MapsiNetworkConfig.default,
applicationInitializer = applicationInitializer,
applicationInfo =ApplicationInfo("test")
)
mapsiLocation.start(mapsiLocationConfig)

Configuration Parameters

The Default configuration contains:

ParameterDescription
apiKeyAPI key provided by Tapsi services
fullServiceConfigConfiguration of authentication and location endpoints
mapsiNetworkConfigOptional network-related configuration
applicationInitializerApplication initializer
applicationInfoOptional identifier used by the SDK for storing required data

The authentication and location URLs must be provided through ServiceConfig.Full.


Denoised Custom

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.

Service Configuration

For Custom mode, you need to provide the URL of your application's location endpoint.

Java

ServiceConfig.DerivativederivativeServiceConfig =
newServiceConfig.Derivative(
newUrlConfig(
"your server url",
HttpRequestMethod.Post.INSTANCE
)
);

Kotlin

val derivativeServiceConfig =ServiceConfig.Derivative(
UrlConfig(
"your server url",
HttpRequestMethod.Post
)
)

NetworkProvider

The library uses NetworkProvider to communicate with your application's backend.

Java

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.
}
);

Kotlin

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.


Starting Custom Mode

Java

MapsiLocationConfigmapsiLocationConfig =
newMapsiLocationConfig.Denoised.Custom(
derivativeServiceConfig,
networkProvider,
MapsiNetworkConfig.Companion.getDefault(),
applicationInitializer,
newApplicationInfo("test")
);
mapsiLocation.start(mapsiLocationConfig);

Kotlin

val mapsiLocationConfig:MapsiLocationConfig=MapsiLocationConfig.Denoised.Custom(
derivativeServiceConfig = derivativeServiceConfig,
networkProvider = networkProvider,
mapsiNetworkConfig =MapsiNetworkConfig.default,
applicationInitializer = applicationInitializer,
applicationInfo =ApplicationInfo("test")
)
mapsiLocation.start(mapsiLocationConfig)

ResponseData

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.

Java

newResponseData(
200,
Map.of(),
jsonBody
);

Kotlin

ResponseData(
code =200,
headers =mapOf(),
body = jsonBody
)

Getting Location

After Mapsi Location has been initialized and started, there are two ways to request a location:

  1. Single Location
  2. Continuous Location

Single Location

Use getLocation when you need to obtain a location once.

Java

MapsiLocationListenermapsiLocationListener = location -> {
// Location received here
};
mapsiLocation.getLocation(
2000,
mapsiLocationListener
);

Kotlin

val mapsiLocationListener:MapsiLocationListener=object:MapsiLocationListener {
overridefunonLocationReceived(location:Location?) {
// Location received here
}
}
mapsiLocation.getLocation(
timeoutByMilliSecond =2000,
mapsiLocationListener = mapsiLocationListener
)

Timeout

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.


Cancel Single Location Request

If you need to cancel a single location request, use removeGetLocationListener.

Java

mapsiLocation.removeGetLocationListener(
mapsiLocationListener
);

Kotlin

mapsiLocation.removeGetLocationListener(
mapsiLocationListener = mapsiLocationListener
)

Important: You must pass the exact same MapsiLocationListener instance that was provided to getLocation.


Continuous Location

Use getLiveLocation when you need to continuously receive location updates.

Java

MapsiLocationListenermapsiLocationListener = location -> {
// Location received here
};
mapsiLocation.getLiveLocation(
2000,
mapsiLocationListener
);

Kotlin

val mapsiLocationListener:MapsiLocationListener=object:MapsiLocationListener {
overridefunonLocationReceived(location:Location?) {
// Location received here
}
}
mapsiLocation.getLiveLocation(
intervalByMilliSecond =2000,
mapsiLocationListener = mapsiLocationListener
)

intervalByMilliSecond

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.


Cancel Continuous Location

To stop receiving continuous location updates, call removeLiveLocationListener.

Java

mapsiLocation.removeLiveLocationListener(
mapsiLocationListener
);

Kotlin

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

MapsiNetworkConfig is an optional configuration that allows you to customize network-related behavior of Mapsi Location.

The default configuration is:

Kotlin

val default =MapsiNetworkConfig(
defaultDenoiseMethod =null,
denoiseMethods = emptyList(),
denoisingRequestTimeOutByMilliSecond =2000
)

The configuration contains three main properties:

PropertyDescription
defaultDenoiseMethodThe default denoise method used by the SDK
denoiseMethodsThe list of available denoise methods
denoisingRequestTimeOutByMilliSecondMaximum time to wait for the denoise API request

The default timeout for a denoising request is 2000 milliseconds.


Denoise Methods

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.

Kotlin

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.


Changing Denoise Method

You can change the active denoise method at runtime.

Java

mapsiLocation.updateDenoiseMethod(
secondDenoiseMethod
);

Kotlin

mapsiLocation.updateDenoiseMethod(
denoiseMethod = secondDenoiseMethod
)

This allows the application to switch between different denoise strategies without recreating the Mapsi Location instance.


Integration Summary

There are several ways to integrate Mapsi Location depending on your requirements.

ModeBackend RequiredAPI Key in AppCustom Network Layer
RawNoNoNo
Denoised / DefaultTapsi servicesYesNo
Denoised / CustomYour backendNoYes

Recommended Integration

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.


Complete Basic Flow

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

Important Notes

  • 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.
  • MapsiNetworkConfig can be used to customize denoising behavior.
  • Multiple denoise methods can be configured and switched at runtime.

Support

If you have any questions or encounter issues while integrating Mapsi Location, please contact the Tapsi technical team.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Universal Dark Mode - works on any site\n(function() {\n var enabled = true;\n \n function applyDarkMode() {\n if (!enabled) return;\n \n // Create style element if it doesn't exist\n var style = document.getElementById('universal-dark-mode-style');\n if (!style) {\n style = document.createElement('style');\n style.id = 'universal-dark-mode-style';\n document.head.appendChild(style);\n }\n \n // Dark mode CSS - inverts colors but preserves images/video\n style.textContent = '\n /* Invert everything except media */\n html {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #1a1a2e !important;\n }\n \n /* Restore images, videos, iframes, canvas */\n img, video, iframe, canvas, svg, picture, [style*=\"background-image\"] {\n filter: invert(1) hue-rotate(180deg) !important;\n }\n \n /* Preserve specific elements that should not be inverted */\n .no-dark-mode, .no-dark-mode *,\n [data-theme=\"light\"], [data-theme=\"light\"],\n .ace_editor, .ace_editor *,\n .CodeMirror, .CodeMirror *,\n .monaco-editor, .monaco-editor *,\n .markdown-body pre, .markdown-body pre *,\n .highlight, .highlight *,\n pre code, pre code * {\n filter: none !important;\n }\n \n /* Fix common UI elements */\n .modal, .popup, .dropdown-menu, .tooltip, .popover {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #2d2d44 !important;\n border-color: #444 !important;\n }\n \n /* Scrollbars */\n ::-webkit-scrollbar { background: #1a1a2e !important; }\n ::-webkit-scrollbar-thumb { background: #444 !important; }\n ::-webkit-scrollbar-thumb:hover { background: #555 !important; }\n \n /* Selection */\n ::selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ::-moz-selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ';\n }\n \n function removeDarkMode() {\n var style = document.getElementById('universal-dark-mode-style');\n if (style) style.remove();\n }\n \n // Toggle with Alt+Shift+D\n document.addEventListener('keydown', function(e) {\n if (e.altKey && e.shiftKey && e.key === 'D') {\n e.preventDefault();\n enabled = !enabled;\n if (enabled) {\n applyDarkMode();\n console.log('[Universal Dark Mode] Enabled');\n } else {\n removeDarkMode();\n console.log('[Universal Dark Mode] Disabled');\n }\n }\n });\n \n // Apply on load\n applyDarkMode();\n \n // Re-apply on dynamic content\n var observer = new MutationObserver(function(mutations) {\n if (enabled && !document.getElementById('universal-dark-mode-style')) {\n applyDarkMode();\n }\n });\n observer.observe(document.head, { childList: true });\n \n console.log('[Universal Dark Mode] Loaded - Press Alt+Shift+D to toggle');\n})();", "Universal Dark Mode"); } } catch(__e) { console.warn('[Userscript:Universal Dark Mode]', __e); } })(); })();
Skip to content

Repository files navigation

Mapsi Location SDK

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.


Table of Contents


Overview

Mapsi Location provides two different approaches for obtaining the user's location:

  1. Raw — Uses the location provided directly by the Android device.
  2. 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.


Location Modes

Raw

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.

Advantages

  • Simple integration
  • No backend configuration required
  • No API key required

Limitations

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.


Denoised

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:

  1. Default
  2. Custom

Sample Project

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.


Requirements

Before using Mapsi Location, make sure the following requirements are satisfied.

1. Location Permission

The application must have the required Android location permission.

2. Location Services

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.


Installation

Add the Mapsi Location dependency to your Android application.

Gradle

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


Initialization

First, create an instance of MapsiLocation.

Java

MapsiLocationmapsiLocation = newMapsiLocation();

Kotlin

val mapsiLocation =MapsiLocation()

Next, create an ApplicationInitializer using the Android Application instance.

Java

ApplicationInitializerapplicationInitializer =
newApplicationInitializer(getApplication());

Kotlin

val applicationInitializer =ApplicationInitializer(application)

The ApplicationInitializer is required when creating the Mapsi Location configuration.


Raw Mode

To use Raw mode, create a MapsiLocationConfig.Raw configuration and start Mapsi Location.

Java

MapsiLocationConfigmapsiLocationConfig =
newMapsiLocationConfig.Raw(
applicationInitializer,
newApplicationInfo("test")
);
mapsiLocation.start(mapsiLocationConfig);

Kotlin

val mapsiLocationConfig =MapsiLocationConfig.Raw(
applicationInitializer = applicationInitializer,
applicationInfo =ApplicationInfo("test")
)
mapsiLocation.start(mapsiLocationConfig)

ApplicationInfo

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

Denoised mode supports two different integration approaches:


Denoised Default

The Default integration requires an API key from Tapsi services.

Service Configuration

The Default integration requires the URLs for the authentication and location services.

Java

ServiceConfig.FullfullServiceConfig = newServiceConfig.Full(
newUrlConfig(
"auth url",
HttpRequestMethod.Post.INSTANCE
),
newUrlConfig(
"geo locate url",
HttpRequestMethod.Post.INSTANCE
)
);

Kotlin

val fullServiceConfig =ServiceConfig.Full(
authConfig =UrlConfig(
"auth url",
HttpRequestMethod.Post
),
getLocationConfig =UrlConfig(
"geo locate url",
HttpRequestMethod.Post
)
)

Then create the MapsiLocationConfig.Denoised.Default configuration.

Java

MapsiLocationConfigmapsiLocationConfig =
newMapsiLocationConfig.Denoised.Default(
API_KEY,
fullServiceConfig,
MapsiNetworkConfig.Companion.getDefault(),
applicationInitializer,
newApplicationInfo("test")
);
mapsiLocation.start(mapsiLocationConfig);

Kotlin

val mapsiLocationConfig:MapsiLocationConfig=MapsiLocationConfig.Denoised.Default(
apiKey =API_KEY,
fullServiceConfig = fullServiceConfig,
mapsiNetworkConfig =MapsiNetworkConfig.default,
applicationInitializer = applicationInitializer,
applicationInfo =ApplicationInfo("test")
)
mapsiLocation.start(mapsiLocationConfig)

Configuration Parameters

The Default configuration contains:

ParameterDescription
apiKeyAPI key provided by Tapsi services
fullServiceConfigConfiguration of authentication and location endpoints
mapsiNetworkConfigOptional network-related configuration
applicationInitializerApplication initializer
applicationInfoOptional identifier used by the SDK for storing required data

The authentication and location URLs must be provided through ServiceConfig.Full.


Denoised Custom

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.

Service Configuration

For Custom mode, you need to provide the URL of your application's location endpoint.

Java

ServiceConfig.DerivativederivativeServiceConfig =
newServiceConfig.Derivative(
newUrlConfig(
"your server url",
HttpRequestMethod.Post.INSTANCE
)
);

Kotlin

val derivativeServiceConfig =ServiceConfig.Derivative(
UrlConfig(
"your server url",
HttpRequestMethod.Post
)
)

NetworkProvider

The library uses NetworkProvider to communicate with your application's backend.

Java

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.
}
);

Kotlin

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.


Starting Custom Mode

Java

MapsiLocationConfigmapsiLocationConfig =
newMapsiLocationConfig.Denoised.Custom(
derivativeServiceConfig,
networkProvider,
MapsiNetworkConfig.Companion.getDefault(),
applicationInitializer,
newApplicationInfo("test")
);
mapsiLocation.start(mapsiLocationConfig);

Kotlin

val mapsiLocationConfig:MapsiLocationConfig=MapsiLocationConfig.Denoised.Custom(
derivativeServiceConfig = derivativeServiceConfig,
networkProvider = networkProvider,
mapsiNetworkConfig =MapsiNetworkConfig.default,
applicationInitializer = applicationInitializer,
applicationInfo =ApplicationInfo("test")
)
mapsiLocation.start(mapsiLocationConfig)

ResponseData

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.

Java

newResponseData(
200,
Map.of(),
jsonBody
);

Kotlin

ResponseData(
code =200,
headers =mapOf(),
body = jsonBody
)

Getting Location

After Mapsi Location has been initialized and started, there are two ways to request a location:

  1. Single Location
  2. Continuous Location

Single Location

Use getLocation when you need to obtain a location once.

Java

MapsiLocationListenermapsiLocationListener = location -> {
// Location received here
};
mapsiLocation.getLocation(
2000,
mapsiLocationListener
);

Kotlin

val mapsiLocationListener:MapsiLocationListener=object:MapsiLocationListener {
overridefunonLocationReceived(location:Location?) {
// Location received here
}
}
mapsiLocation.getLocation(
timeoutByMilliSecond =2000,
mapsiLocationListener = mapsiLocationListener
)

Timeout

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.


Cancel Single Location Request

If you need to cancel a single location request, use removeGetLocationListener.

Java

mapsiLocation.removeGetLocationListener(
mapsiLocationListener
);

Kotlin

mapsiLocation.removeGetLocationListener(
mapsiLocationListener = mapsiLocationListener
)

Important: You must pass the exact same MapsiLocationListener instance that was provided to getLocation.


Continuous Location

Use getLiveLocation when you need to continuously receive location updates.

Java

MapsiLocationListenermapsiLocationListener = location -> {
// Location received here
};
mapsiLocation.getLiveLocation(
2000,
mapsiLocationListener
);

Kotlin

val mapsiLocationListener:MapsiLocationListener=object:MapsiLocationListener {
overridefunonLocationReceived(location:Location?) {
// Location received here
}
}
mapsiLocation.getLiveLocation(
intervalByMilliSecond =2000,
mapsiLocationListener = mapsiLocationListener
)

intervalByMilliSecond

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.


Cancel Continuous Location

To stop receiving continuous location updates, call removeLiveLocationListener.

Java

mapsiLocation.removeLiveLocationListener(
mapsiLocationListener
);

Kotlin

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

MapsiNetworkConfig is an optional configuration that allows you to customize network-related behavior of Mapsi Location.

The default configuration is:

Kotlin

val default =MapsiNetworkConfig(
defaultDenoiseMethod =null,
denoiseMethods = emptyList(),
denoisingRequestTimeOutByMilliSecond =2000
)

The configuration contains three main properties:

PropertyDescription
defaultDenoiseMethodThe default denoise method used by the SDK
denoiseMethodsThe list of available denoise methods
denoisingRequestTimeOutByMilliSecondMaximum time to wait for the denoise API request

The default timeout for a denoising request is 2000 milliseconds.


Denoise Methods

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.

Kotlin

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.


Changing Denoise Method

You can change the active denoise method at runtime.

Java

mapsiLocation.updateDenoiseMethod(
secondDenoiseMethod
);

Kotlin

mapsiLocation.updateDenoiseMethod(
denoiseMethod = secondDenoiseMethod
)

This allows the application to switch between different denoise strategies without recreating the Mapsi Location instance.


Integration Summary

There are several ways to integrate Mapsi Location depending on your requirements.

ModeBackend RequiredAPI Key in AppCustom Network Layer
RawNoNoNo
Denoised / DefaultTapsi servicesYesNo
Denoised / CustomYour backendNoYes

Recommended Integration

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.


Complete Basic Flow

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

Important Notes

  • 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.
  • MapsiNetworkConfig can be used to customize denoising behavior.
  • Multiple denoise methods can be configured and switched at runtime.

Support

If you have any questions or encounter issues while integrating Mapsi Location, please contact the Tapsi technical team.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages