Skip to content

Commit

Permalink
add QMS Bing Maps
Browse files Browse the repository at this point in the history
  • Loading branch information
mind84 committed Feb 5, 2024
1 parent 563355d commit 44fed52
Show file tree
Hide file tree
Showing 3 changed files with 989 additions and 2 deletions.
44 changes: 42 additions & 2 deletions assets/src/modules/config/BaseLayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -721,6 +721,29 @@ const defaultCompleteBaseLayersCfg = {

};

/**
* The QuickMapServices external layers object configuration
* It will be used to define base layers config based on the type of external layer
* @constant
* @type {object}
* @see https://plugins.qgis.org/plugins/quick_map_services/
* @private
*/
const QMSExternalLayer = {
"qms-bing-roads": {
"type": "bing",
"title": "Bing Streets",
"imagerySet": "RoadOnDemand",
"key": "",
},
"qms-bing-satellite": {
"type": "bing",
"title": "Bing Satellite",
"imagerySet": "Aerial",
"key": "",
},
}

/**
* Class representing a base layers config
* @class
Expand Down Expand Up @@ -787,8 +810,25 @@ export class BaseLayersConfig {
} else if ( layerTreeItem.layerConfig.externalWmsToggle ){
// The layer config has external access parameters
if (layerTreeItem.layerConfig.externalAccess.hasOwnProperty('type')) {
// layer could be converted to XYZ or WMTS background layers
extendedCfg[layerTreeItem.name] = structuredClone(layerTreeItem.layerConfig.externalAccess);
// search for QuickMapSevice plugin layers.
// The layers identification is based on the url property of the externalAccess object
const externalUrl = layerTreeItem.layerConfig.externalAccess.url;
if (externalUrl && externalUrl.includes('virtualearth.net') && options["bingKey"]) {
// Bing maps
// detect if the url is for roads or satellite
if (externalUrl.includes('dynamic')) {
// roads
extendedCfg[layerTreeItem.name] = structuredClone(QMSExternalLayer["qms-bing-roads"])
} else {
// fallback on satellite map
extendedCfg[layerTreeItem.name] = structuredClone(QMSExternalLayer["qms-bing-satellite"])
}
// add the apikey to the configuration
Object.assign(extendedCfg[layerTreeItem.name],{key:options["bingKey"]})
} else {
// layer could be converted to XYZ or WMTS background layers
extendedCfg[layerTreeItem.name] = structuredClone(layerTreeItem.layerConfig.externalAccess);
}
} else {
extendedCfg[layerTreeItem.name] = Object.assign(
structuredClone(layerTreeItem.layerConfig.externalAccess),
Expand Down
Loading

0 comments on commit 44fed52

Please sign in to comment.