-
Notifications
You must be signed in to change notification settings - Fork 14
Get map preview
Jiří M. aka Menion edited this page Sep 13, 2019
·
1 revision
Last update: API 0.9.5
It is common practice to "mirror" currently visible map and it's content on another device. Watches, another application etc. Locus Map offer tool to obtain currently visible map, but not only this. It is possible to obtain map for any own location, like when you write own map viewer.
-
created
MapPreviewParams
object with the necessary parameters. -
request map preview with defined parameters and known LocusVersion object.
// prepare parameters
val params = MapPreviewParams().apply {
locCenter = Location(52.35, 1.5)
zoom = 14
...
}
// get preview
val result = ActionMapTools.getMapPreview(ctx, lv, params)
if (result != null && result.isValid()) {
// valid result
} else {
// really unexpected problem
}
- Check if the preview is complete
Rendering of the map takes a while. So you may check if the returned map is complete with
numOfNotYetLoadedTiles
and in case of the negative result (missing tiles), it is suggested to request map again with a small delay (1-2 seconds should be enough).
if (result.numOfNotYetLoadedTiles > 0) {
// not complete
}
Parameters for MapPreviewParams class.
- locCenter - center location of the required map. This parameter is optional. If not set, then application picks the best available location. This means GPS location if GPS is enabled or last known. In the case of enabled guidance, the best location will be also snapped to the route if enabled by the user.
- offsetX - offset in X direction (in pixels)
- offsetY - offset in Y direction (in pixels)
- zoom - zoom level currently defined in OSM style where 0 means tile 2^8 px (whole world on the single tile) up to cca 18 (street level)
- widthPx - width of required map (in pixels)
- heightPx - height of required map (in pixels)
- densityDpi - density of the device that requested map
- rotate - flag if the rotation of the map required
- rotation - rotation angle for map (in degree)
- extraUser - flag if we want to draw users location & related content (distance, time circles, line to GPS, accuracy circle)
- extraShading - flag if shading is allowed. This does not enable shading itself, just allows to disable it for the generated map in cases, it is not wanted.
-
Basics
-
Non-API tools
-
Using API
-
Work with points
-
Work with tracks
-
Integration into Locus Map
-
Other/advanced features