I am using a drop down for the user to choose a bing basemap in web map. I'd like to also include a USGS WMS in the list of choices, but am unsure how to do it. This is the current code for populating the list of bing base layers:
var baseStyles = [ 'Road', 'AerialWithLabels', ]; var baseLayers = []; var i, ii; for (i = 0, ii = baseStyles.length; i < ii; ++i) { baseLayers.push(new ol.layer.Tile({ visible: false, preload: Infinity, source: new ol.source.BingMaps({ key: 'Ak-dzM4wZjSqTlzveKz5u0d4IQ4bRzVI309GxmkgSVr1ewS6iPSrOvOKhA-CJlm3', imagerySet: baseStyles // use maxZoom 19 to see stretched tiles instead of the BingMaps // "no photos at this zoom level" tiles // maxZoom: 19 }) })); } And here is the code for adding the USGS WMS:
var USGSimagery = new ol.layer.Tile({ source: new ol.source.TileWMS(({ url: 'http://raster.nationalmap.gov/arcgis/services/Orthoimagery/USGS_EROS_Ortho_SCALE/ImageServer/WMSServer', params: { 'LAYERS': 0 } })) }); In my map I am adding one other vector layer besides the base layers:
var map = new ol.Map({ layers: baseLayers.concat(layerVector),//new ol.layer.Tile({source: new ol.source.OSM()}), layerVector], loadTilesWhileInteracting: true, target: document.getElementById('map'), view: view }); I can add the USGSImagery WMS to the map the same as layerVector and it shows up, but I want it to be added to my list of base layers instead so I can choose whether or not it displays. I'm not sure how to do this, can anyone help?
أكثر...
var baseStyles = [ 'Road', 'AerialWithLabels', ]; var baseLayers = []; var i, ii; for (i = 0, ii = baseStyles.length; i < ii; ++i) { baseLayers.push(new ol.layer.Tile({ visible: false, preload: Infinity, source: new ol.source.BingMaps({ key: 'Ak-dzM4wZjSqTlzveKz5u0d4IQ4bRzVI309GxmkgSVr1ewS6iPSrOvOKhA-CJlm3', imagerySet: baseStyles // use maxZoom 19 to see stretched tiles instead of the BingMaps // "no photos at this zoom level" tiles // maxZoom: 19 }) })); } And here is the code for adding the USGS WMS:
var USGSimagery = new ol.layer.Tile({ source: new ol.source.TileWMS(({ url: 'http://raster.nationalmap.gov/arcgis/services/Orthoimagery/USGS_EROS_Ortho_SCALE/ImageServer/WMSServer', params: { 'LAYERS': 0 } })) }); In my map I am adding one other vector layer besides the base layers:
var map = new ol.Map({ layers: baseLayers.concat(layerVector),//new ol.layer.Tile({source: new ol.source.OSM()}), layerVector], loadTilesWhileInteracting: true, target: document.getElementById('map'), view: view }); I can add the USGSImagery WMS to the map the same as layerVector and it shows up, but I want it to be added to my list of base layers instead so I can choose whether or not it displays. I'm not sure how to do this, can anyone help?
أكثر...