What is wrapped¶
The wrapper targets the lite build of MapKit (4.42.0-lite). Everything the lite SDK
exposes on both Android and iOS is available from common code; this page is a map of where to look.
The official docs describe the full SDK
yandex.ru/dev/mapkit documents the full build. A type documented there is not necessarily in the lite artifact — the "Not wrapped" section below lists what that removes.
Map and map objects¶
ru.sulgik.mapkit.map mirrors com.yandex.mapkit.map: Map, MapWindow, CameraPosition,
VisibleRegion, CameraBounds, the MapObject hierarchy (PlacemarkMapObject,
PolylineMapObject, PolygonMapObject, CircleMapObject, MapObjectCollection,
RootMapObjectCollection, ClusterizedPlacemarkCollection) and every listener MapKit calls back on.
A placemark can be driven either through the shortcut methods (setIcon, setText,
setScaleFunction) or through the presentation objects — useIcon(), useCompositeIcon(),
useModel(), useAnimation() and text return Icon, CompositeIcon, Model,
PlacemarkAnimation and PlacemarkText.
Animated icons and polygon patterns take an AnimatedImageProvider, which is built either from raw
data (fromByteArray, fromFile) or frame by frame with AnimatedImage and Frame.
Base map objects¶
A tap on a POI, a building or a toponym arrives as a layers.GeoObjectTapEvent carrying a
GeoObject. Its metadata is read through the typed accessors selectionMetadata,
inspectionMetadata and tags — MapKit stores it in a dictionary keyed by native classes, which
has no common representation, so the wrapper exposes the entries instead of the container.
uriMetadata and personalizedPoiMetadata read the remaining metadata kinds the lite SDK
attaches. Map.selectGeoObject takes the selection metadata back.
Map.setMapLoadedListener reports MapLoadStatistics once the visible tiles are rendered.
Layers and tiles¶
Map.addTileLayer creates a custom tile layer: the TileDataSourceBuilder handed to it takes a
tiles.UrlProvider or a tiles.TileProvider, a geometry.geo.Projection, the ZoomRange list and
the TileFormat. The resulting layers.Layer gives access to its DataSourceLayer, which manages
visibility, JSON styles and the LayerLoadedListener / DataSourceListener subscriptions.
Map.addMapObjectLayer does the same for a collection of map objects.
Traffic, storage and offline maps¶
MapKit.createTrafficLayer returns a traffic.TrafficLayer with its TrafficListener and
TrafficLevel. MapKit.storageManager computes and caps the space MapKit occupies;
MapKit.offlineCacheManager downloads regions, reports their RegionState and progress, and moves
the cache to another folder.
→ Layers and tiles, Offline maps and storage
Geolocation¶
Besides LocationManager and LocationListener, the wrapper covers the simulation side:
MapKit.createLocationSimulator replays a Polyline with SimulationSettings and
LocationSettings, and MapKit.createDummyLocationManager pushes positions in by hand.
lastKnownLocation() returns the last position MapKit received.
MapKit derives LocationSimulator from LocationManager. Kotlin cannot express that inheritance
across the two platforms, so LocationSimulator.asLocationManager() returns the same object seen as
a LocationManager, which is where subscribeForLocationUpdates, requestSingleUpdate,
unsubscribe, suspend and resume live. The simulator is created suspended and
startSimulation does not resume it, so call resume() on the view to make isActive true and let
the simulated locations reach the subscribers:
val simulator = mapKit.createLocationSimulator(route)
simulator.asLocationManager().resume()
simulator.startSimulation(settings)
The result is a plain LocationManager, so it can also be passed to MapKit.setLocationManager()
or turned into a LocationViewSource with toLocationViewSource().
MapKit derives DummyLocationManager from LocationManager in the same way, so
DummyLocationManager.asLocationManager() opens the same five members for a manager whose positions
the application pushes in with setLocation:
val dummy = mapKit.createDummyLocationManager()
dummy.asLocationManager().subscribeForLocationUpdates(settings, locationListener.asWeakRef())
dummy.setLocation(location, DummyLocationQuality.HIGH)
Runtime¶
runtime.Error and its subtypes (LocalError, DiskFullError, NetworkError, RemoteError, …)
type the failures the listeners report. runtime.logging.Logging subscribes to the MapKit log
stream, and runtime.i18n.I18nManager formats distances, durations, speeds and data sizes for the
current locale.
→ Runtime
Compose¶
yandex-mapkit-kmp-compose renders the map objects (Placemark, Polyline, Polygon, Circle,
Clustering), groups them with MapObjectCollection or puts them on a layer of their own with
MapObjectLayer, and adds the map-wide layers — TrafficLayer and TileLayer. MapConfig covers
Map and MapWindow; MapListeners covers the map events.
Whatever a parameter cannot express lives on the state object: every MapObjectState animates
visibility with setVisible(visible, animation), PlacemarkState reaches useIcon(),
useCompositeIcon(), useModel(), useAnimation(), text and setScaleFunction(),
PolylineState selects and hides subpolylines and colours segments through the palette,
PolygonState sets an animated pattern, and MapObjectCollectionState reaches the shared
PlacemarksStyler and traverse. Anything still missing is one MapEffect away.
Not wrapped¶
- Full-build API. Search, routing, panoramas, road events and the personalization API
(
MapKit.setAccount,MapKit.createOffscreenMapWindow) do not exist in the lite build. BaseDataSourceBuilderandmapkit.images. The types exist in the lite build but nothing hands one out —Map.addTileLayerbuilds aTileDataSourceBuilderinstead.ViewProvider. MapKit can render a nativeView/UIViewinto an icon. There is no common shape for it; the Compose module covers the same ground withimageProvider { }.ImageProvider.id/isCacheable. They exist on Android only — iOS MapKit takes a plainUIImage— so they stay parameters of the Android factories.
Anything on this list is still reachable through toNative() from a platform source set.