UPDATE:
While answering a question over at the cmv github repository, it occurred to me that there is another solution that may get you closer to what you desire. The available basemaps are just an object within the esri.config.defaults.map
. You can add your own custom basemaps to that object and they are treated like the standard ESRI basemaps. The advantage of this approach is you can refer to the basemap id in the map constructor and thus that id can be saved in the user settings as you desired. Here's a full example:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no"/>
<title>Simple Map</title>
<link rel="stylesheet" href="http://js.arcgis.com/3.10/js/esri/css/esri.css">
<style>
html, body, #map {
height: 100%;
width: 100%;
margin: 0;
padding: 0;
}
body {
background-color: #FFF;
overflow: hidden;
font-family: "Trebuchet MS";
}
</style>
<script src="http://js.arcgis.com/3.10/"></script>
<script>
var map;
esriConfig.defaults.map.basemaps.terrain = {
baseMapLayers: [
{
url: "http://services.arcgisonline.com/arcgis/rest/services/World_Terrain_Base/MapServer"
},
{
url: "http://services.arcgisonline.com/ArcGIS/rest/services/Reference/World_Reference_Overlay/MapServer"
}
],
title: "Terrain Basemap"
};
require(["esri/map", "esri/config", "dojo/domReady!"], function(Map, esriConfig) {
map = new Map("map", {
basemap: "terrain",
center: [-122.45, 37.75], // longitude, latitude
zoom: 12
});
});
</script>
</head>
<body>
<div id="map"></div>
</body>
</html>