2GIS SDK Integration in Mobile App
2GIS SDK (DGis Mobile SDK) — reasonable choice when needing detailed building, office, floor and organization data in Russian cities. 2GIS maps work offline out of the box — user can download region and navigate without internet. This sets it apart from Google Maps and Yandex in scenarios with unstable connectivity.
SDK Connection
API key issued via dev.2gis.ru. SDK available for Android and iOS, Flutter wrapper exists but officially supported less.
Android (build.gradle):
repositories {
maven { url = uri("https://artifactory.2gis.dev/sdk-maven-release") }
}
dependencies {
implementation("ru.dgis.sdk:sdk-map:1.3.0")
// or sdk-full for search and routes
}
iOS (Swift Package Manager):
// Package.swift
.package(url: "https://github.com/2gis/mobile-sdk-full-swift-package", from: "1.3.0")
Android: Initialization and Basic Map
import ru.dgis.sdk.DGis
class App : Application() {
lateinit var sdkContext: ru.dgis.sdk.Context
override fun onCreate() {
super.onCreate()
sdkContext = DGis.initialize(
appContext = this,
apiKey = ApiKeys(directory = "YOUR_DIRECTORY_KEY", map = "YOUR_MAP_KEY")
)
}
}
2GIS requires two different keys: directory — for org search and reference, map — for map display. Mixing or using one key for both — common mistake on first integration.
class MapFragment : Fragment() {
private val mapObjectManager by lazy {
MapObjectManager(mapView.map)
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
val mapView: MapView = view.findViewById(R.id.mapView)
// Initial position
mapView.map.move(
CameraPosition(
point = GeoPoint(54.9885, 82.9207), // Novosibirsk
zoom = Zoom(13f)
)
)
}
}
Organization Search
2GIS directory — main SDK advantage. Search by name, category, address within visible area:
val searchManager = SearchManager.createSmartSearchManager(sdkContext)
val searchQuery = QueryBuilder("coffee shop")
.setSearchArea(mapView.map.visibleArea)
.build()
val searchTask = searchManager.search(searchQuery, object : SearchListener {
override fun onSearchCompleted(searchResult: SearchResult) {
for (item in searchResult.items) {
item.markerPosition?.let { pos ->
val marker = DgisMapObject.createMarker(
options = MarkerOptions(
position = pos,
icon = imageFromResource(R.drawable.ic_coffee)
)
)
mapObjectManager.addObject(marker)
}
}
}
override fun onSearchError(error: SearchError) {}
})
Search results contain rich data: name, address, category, rating, working hours, contacts — all from 2GIS reference without extra requests.
Offline Maps
Region download — via RegionManager:
val regionManager = sdkContext.getRegionManager()
regionManager.regions.onEach { regions ->
val novosibirsk = regions.find { it.name.contains("Novosibirsk") }
novosibirsk?.let { region ->
regionManager.downloadRegion(region.id)
}
}.launchIn(lifecycleScope)
After download, map, search and routes work offline. Region size for major city — 200-800 MB. Warn user before download via Wi-Fi.
Routes
val routeSearchManager = RouteSearchManager(sdkContext)
val routeSearchOptions = RouteSearchOptions(
startPoint = RouteSearchPoint(GeoPoint(54.9885, 82.9207)),
finishPoint = RouteSearchPoint(GeoPoint(54.9782, 82.8971)),
transportOptions = RouteSearchTransportOptions.Car
)
routeSearchManager.findRoute(routeSearchOptions, object : RouteSearchListener {
override fun onRoutesFound(routes: List<TrafficRoute>, routeSearchOptions: RouteSearchOptions) {
routes.firstOrNull()?.let { route ->
val routeMapObject = RouteMapObject(route)
mapObjectManager.addObject(routeMapObject)
}
}
override fun onError(error: SearchError) {}
})
Features and Limitations
2GIS SDK heavier than Google Maps: full version adds ~50-60 MB to APK. For apps with strict size requirements use only sdk-map without reference. Map style customization limited compared to Mapbox — can't fully recolor all layers via JSON-style.
Timeline
1–3 days. Map with markers — 1 day. Organization search + routes — 2–3 days. Cost calculated individually.







