StreetMap Premium for ArcGIS Runtime provides enriched street data, which powers a high-quality cartographic maps and high-quality search, geocoding, and route analysis. StreetMap Premium maps are consistent across all regions of the world and can be taken offline for disconnected use; they can simultaneously fulfill the need for an address locator, street network dataset, and basemap in your app.
StreetMap Premium delivers data as a mobile map package (an .mmpk
file) for your app to access locally. This format allows the data to be accessed offline (without a network connection, in other words) and therefore doesn't consume data from your user's data plan. This is the same high-quality data used by ArcGIS Online services, including the Geocoding service, Routing service, and Basemap styles service. Instead of spending your time putting together such datasets yourself, you can focus on developing apps that provide advanced searching, geocoding, and routing analysis offline.
StreetMap Premium data is organized into regions that are licensed as extensions and are downloaded individually (North America, Latin America, Europe, the Middle East, Africa, and Asia Pacific), allowing your apps to provide a consistent user experience across the globe. Within these regions, maps are available at the sub-region, country, or state/province level. You can even use ArcGIS Pro to clip the data to a custom area of interest.
How to add StreetMap Premium data
Follow these general steps to use StreetMap Premium in your app.
-
Download the StreetMap Premium Greater Los Angeles mobile map package that is provided for development and testing. When you're ready to deploy your app, you'll need to download the required StreetMap Premium packages from My Esri and license StreetMap Premium for each extension (region) your app uses.
-
Provide the data (mobile map package) for your app. You can provide package(s) with your app or allow the user to download them as needed. Once the package (
*.mmpk
) is available on the client, you can open it to retrieve data, maps, and locators. Using the contents of the package, you can:- Display StreetMap Premium data in your app.
- Locate addresses and places using a StreetMap Premium locator task.
- Solve routes using the transportation network dataset provided in the StreetMap Premium map package.
License StreetMap Premium
Each StreetMap Premium region is licensed as an extension. A StreetMap Premium extension license works with all license levels: Lite, Basic, Standard, and Advanced. Unlike other extension licenses, this license does not unlock API capabilities, but rather licenses the use of StreetMap Premium data within one of the available regions. For each region you license, you receive a license string to use in your app. These licenses are good for one year, so you must provide a mechanism to notify your users and update the license string for your app when (or before) the license expires.
The following code licenses your app and several StreetMap Premium extensions when the app initializes. To update these license strings when they expire, you will need to update and recompile the app code.
// ArcGIS Maps license string
val arcgisLicenseString = "runtimelite,1000,rudxxxxxxxxx,28-feb-2023,xxxxxxxxxxxxxxxxxxxx"
val arcgisLicenseKey = LicenseKey.create(arcgisLicenseString) as LicenseKey
// Extension license strings for various StreetMap Premium areas
val smpNorthAmericaString = "runtimesmpna,1000,rudxxxxxxxxx,13-mar-2023,xxxxxxxxxxxxxxxxxxxx"
val smpLatinAmericaString = "runtimesmpla,1000,rudxxxxxxxxx,13-mar-2023,xxxxxxxxxxxxxxxxxxxx"
val smpEuropeString = "runtimesmpe,1000,rudxxxxxxxxx,16-dec-2023,xxxxxxxxxxxxxxxxxxxx"
val smpNorthAmericaKey = LicenseKey.create(smpNorthAmericaString) as LicenseKey
val smpLatinAmericaKey = LicenseKey.create(smpLatinAmericaString) as LicenseKey
val smpEuropeKey = LicenseKey.create(smpEuropeString) as LicenseKey
// Add StreetMap Premium license strings to an array
val extensionKeyList = listOf(smpNorthAmericaKey, smpLatinAmericaKey, smpEuropeKey)
// Set the license for ArcGIS Runtime and the three extensions (areas)
ArcGISEnvironment.setLicense(arcgisLicenseKey, extensionKeyList)
You could also read license strings on startup from a text file included with the app and set the licenses. This would allow the user to update license strings in a separate file and would eliminate the need for you to update and recompile the app code.
// Code here to read a file that has one runtime license string and some extension license strings ...
// Store ArcGIS Maps SDK license string
var runtimeLicenseKey: LicenseKey? = null
// Loop through license strings from file.
for (license: String in licenseStringsReadFromFile) {
Log.i(localClassName, "SNIPS: license: $license")
// Check if it is a Runtime license string.
if (license.startsWith("runtimelite") ||
license.startsWith("runtimebasic") ||
license.startsWith("runtimestandard") ||
license.startsWith("runtimeadvanced")
) {
// Store license string
runtimeLicenseKey = LicenseKey.create(license) ?: return showError("Failed to create runtime license key from file.")
} else if (license.contains("smp")) {
val licenseKey = LicenseKey.create(license) ?: return showError("Failed to create an extension key from file.")
extensionKeyList.add(licenseKey)
}
}
if (runtimeLicenseKey == null) return showError("Failed to set runtimeLicenseKey with a license key.")
// Set license using license string and any extension licenses.
ArcGISEnvironment.setLicense(runtimeLicenseKey, extensionKeyList)
As the licenses in your app near expiration, you might want to notify the user that new licensing information will be required soon.
The following code loops through all extension licenses for the app and notifies the user if a license is within 10 days of expiring.
// Get the current licensing information.
val license: License = ArcGISEnvironment.license
// Get all extension licenses.
val extensionLicenses: List<ExtensionLicense> = license.extensions
// Loop through extension licenses and see when each expires.
extensionLicenses.forEach { extensionLicense ->
// Get license name and data of expiration.
val licenseName: String = extensionLicense.name
val date: Instant = extensionLicense.expiry
// Get number of days till license expires.
val timeLeft: Long = date.toEpochMilli() - System.currentTimeMillis()
val millisecondsADay = 1000 * 60 * 60 * 24
val daysLeft = timeLeft / millisecondsADay
// Warn user of days left on license if under 10 days.
if (daysLeft <= 10) {
Log.i(localClassName, "WARNING: Days left till $licenseName expires: $daysLeft")
}
else {
Log.i(localClassName, "More than 10 days until $licenseName expires.")
}
}
Display StreetMap Premium data
Inside each StreetMap Premium mobile map package, you'll find two maps: Navigation Day and StreetMap Day. Each of these maps display the same data and use similar symbology for the layers. They also use scale dependent rendering to improve display performance and readability. The Navigation Day map, however, displays streets with a wider symbol and with more and larger labels, as illustrated in the following image. You can choose the map that best suits the use case, device, screen size, and so on for your app.
The following example opens a StreetMap Premium mobile map package file and displays the Navigation Day map in the app's map view.
// Open a StreetMap Premium mobile map package.
val mobileMapPackage = MobileMapPackage(pathToSMPIndianammpk)
lifecycleScope.launch {
mobileMapPackage.load().onSuccess {
// Get the first map, which is the navigation map.
val navigationMap: ArcGISMap = mobileMapPackage.maps.first()
// Display the map by assigning it to the mutable map property used by the MapView composable.
map = navigationMap
}
}
Locate addresses and places
In addition to street data and maps, each StreetMap Premium mobile map package contains a locator task. Use the locator task to geocode addresses, intersections, or places of interest within the area covered by the package.
The following example opens a StreetMap Premium mobile map package file, gets the associated LocatorTask
, and uses it to find a location.
val locatorTask = mobileMapPackage.locatorTask
?: return@launch showError("Failed to get locator task from mobile map package.")
val geocodeResultList = locatorTask.geocode("Indianapolis Motor Speedway").getOrElse { error ->
return@launch showError("No geocode results returned." + error.message)
}
val sortedGeocodeResultList = geocodeResultList.sortedByDescending { geocodeResult ->
geocodeResult.score
}
val highestScoreGeocodeResult = sortedGeocodeResultList.first()
Solve routes
Maps in a StreetMap Premium package have an associated transportation network dataset. You can use this dataset to solve routes between two or more locations in the street network. The maps must be loaded before you can access the transportation dataset it contains.
// Get the (first and only) street network data set from one of the maps in the package.
val streetNetwork: TransportationNetworkDataset =
mobileMapPackage.maps.first().transportationNetworks.first()
// Create a new route task that uses the street network.
val routeTask = RouteTask(streetNetwork)
// Then get the default parameters from the route task and solve the route.
// ...