{"id":1415,"date":"2015-09-24T23:15:27","date_gmt":"2015-09-24T23:15:27","guid":{"rendered":"http:\/\/www.phpmind.com\/blog\/?p=1415"},"modified":"2015-09-24T23:31:23","modified_gmt":"2015-09-24T23:31:23","slug":"cesiumjs-how-to-set-default-imagelayer","status":"publish","type":"post","link":"https:\/\/www.phpmind.com\/blog\/2015\/09\/cesiumjs-how-to-set-default-imagelayer\/","title":{"rendered":"Cesiumjs &#8211; How to set default imagery provider."},"content":{"rendered":"<p><a href=\"http:\/\/www.phpmind.com\/blog\/wp-content\/uploads\/2015\/09\/phpmind-cesiumjs-set-default-image-layer.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.phpmind.com\/blog\/wp-content\/uploads\/2015\/09\/phpmind-cesiumjs-set-default-image-layer.png\" alt=\"phpmind-cesiumjs-set-default-image-layer\" width=\"733\" height=\"528\" class=\"aligncenter size-full wp-image-1416\" srcset=\"https:\/\/www.phpmind.com\/blog\/wp-content\/uploads\/2015\/09\/phpmind-cesiumjs-set-default-image-layer.png 733w, https:\/\/www.phpmind.com\/blog\/wp-content\/uploads\/2015\/09\/phpmind-cesiumjs-set-default-image-layer-300x216.png 300w, https:\/\/www.phpmind.com\/blog\/wp-content\/uploads\/2015\/09\/phpmind-cesiumjs-set-default-image-layer-624x449.png 624w\" sizes=\"auto, (max-width: 733px) 100vw, 733px\" \/><\/a><\/p>\n<p>If you want to use the BaseLayerPicker, then you need to specify what imagery and terrain seletions are available.  It&#8217;s more code bu just as straight forward.  Here&#8217;s a full example that adds two possible terrains and 2 possible imagery providers.  It makes the second one active by default by setting the selectedXXX properties, otherwise the first index would be active instead.<\/p>\n<pre>\r\n\r\nvar providerViewModels = [];\r\nproviderViewModels.push(new Cesium.ProviderViewModel({\r\n    name : 'Bing Maps Aerial',\r\n    iconUrl : Cesium.buildModuleUrl('Widgets\/Images\/ImageryProviders\/bingAerial.png'),\r\n    tooltip : 'Bing Maps aerial imagery \\nhttp:\/\/www.bing.com\/maps',\r\n    creationFunction : function() {\r\n        return new Cesium.BingMapsImageryProvider({\r\n            url : '\/\/dev.virtualearth.net',\r\n            mapStyle : Cesium.BingMapsStyle.AERIAL\r\n        });\r\n    }\r\n}));\r\n\r\nproviderViewModels.push(new Cesium.ProviderViewModel({\r\n    name : 'Bing Maps Aerial with Labels',\r\n    iconUrl : Cesium.buildModuleUrl('Widgets\/Images\/ImageryProviders\/bingAerialLabels.png'),\r\n    tooltip : 'Bing Maps aerial imagery with label overlays \\nhttp:\/\/www.bing.com\/maps',\r\n    creationFunction : function() {\r\n        return new Cesium.BingMapsImageryProvider({\r\n            url : '\/\/dev.virtualearth.net',\r\n            mapStyle : Cesium.BingMapsStyle.AERIAL_WITH_LABELS\r\n        });\r\n    }\r\n}));\r\n\r\nvar terrainViewModels = [];\r\nterrainViewModels.push(new Cesium.ProviderViewModel({\r\n    name : 'WGS84 Ellipsoid',\r\n    iconUrl : Cesium.buildModuleUrl('Widgets\/Images\/TerrainProviders\/Ellipsoid.png'),\r\n    tooltip : 'WGS84 standard ellipsoid, also known as EPSG:4326',\r\n    creationFunction : function() {\r\n        return new Cesium.EllipsoidTerrainProvider();\r\n    }\r\n}));\r\n\r\n\r\nterrainViewModels.push(new Cesium.ProviderViewModel({\r\n    name : 'STK World Terrain meshes',\r\n    iconUrl : Cesium.buildModuleUrl('Widgets\/Images\/TerrainProviders\/STK.png'),\r\n    tooltip : 'High-resolution, mesh-based terrain for the entire globe. Free for use on the Internet. Closed-network options are available.\\nhttp:\/\/www.agi.com',\r\n    creationFunction : function() {\r\n        return new Cesium.CesiumTerrainProvider({\r\n            url : '\/\/assets.agi.com\/stk-terrain\/world',\r\n            requestWaterMask : true,\r\n            requestVertexNormals : true\r\n        });\r\n    }\r\n}));\r\n\r\nvar viewer = new Cesium.Viewer('cesiumContainer', {\r\n    imageryProviderViewModels : providerViewModels,\r\n    selectedImageryProviderViewModel : providerViewModels[1],\r\n    terrainProviderViewModels : terrainViewModels,\r\n    selectedTerrainProviderViewModel : terrainViewModels[1]\r\n});\r\n\r\n\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>If you want to use the BaseLayerPicker, then you need to specify what imagery and terrain seletions are available. It&#8217;s more code bu just as straight forward. Here&#8217;s a full example that adds two possible terrains and 2 possible imagery providers. It makes the second one active by default by setting the selectedXXX properties, otherwise [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_exactmetrics_skip_tracking":false,"_exactmetrics_sitenote_active":false,"_exactmetrics_sitenote_note":"","_exactmetrics_sitenote_category":0,"footnotes":""},"categories":[53,27],"tags":[],"class_list":["post-1415","post","type-post","status-publish","format-standard","hentry","category-cesiumjs","category-javascript"],"_links":{"self":[{"href":"https:\/\/www.phpmind.com\/blog\/wp-json\/wp\/v2\/posts\/1415","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.phpmind.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.phpmind.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.phpmind.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.phpmind.com\/blog\/wp-json\/wp\/v2\/comments?post=1415"}],"version-history":[{"count":3,"href":"https:\/\/www.phpmind.com\/blog\/wp-json\/wp\/v2\/posts\/1415\/revisions"}],"predecessor-version":[{"id":1419,"href":"https:\/\/www.phpmind.com\/blog\/wp-json\/wp\/v2\/posts\/1415\/revisions\/1419"}],"wp:attachment":[{"href":"https:\/\/www.phpmind.com\/blog\/wp-json\/wp\/v2\/media?parent=1415"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.phpmind.com\/blog\/wp-json\/wp\/v2\/categories?post=1415"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.phpmind.com\/blog\/wp-json\/wp\/v2\/tags?post=1415"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}