[fusion-commits] r3038 - in sandbox/cms_refactor: layers/Generic lib

svn_fusion at osgeo.org svn_fusion at osgeo.org
Thu Jul 26 08:02:28 PDT 2018


Author: jng
Date: 2018-07-26 08:02:28 -0700 (Thu, 26 Jul 2018)
New Revision: 3038

Modified:
   sandbox/cms_refactor/layers/Generic/Generic.js
   sandbox/cms_refactor/lib/fusion.js
Log:
- Remove (long shut down) yahoo maps support
- Don't emit script tags for Bing/OSM/Stamen. Bing support is already serviced by the built-in OpenLayers.Layer.Bing. OSM/Stamen is already serviced by passing the specific URLs against the built-in OpenLayers.Layer.OSM and OpenLayers.Layer.XYZ types. I've left the refactored design open-ended enough that should one want to host their own OSM tile server, they just need to provide their own list of templated XYZ URLs for their OSM tile server. Similarly, if they want to use non-watermarked CycleMap and TransportMap tiles (eg. http://www.thunderforest.com/docs/apikeys/) the mechanism is in place for one to provide their own alternative templated XYZ URLs

Modified: sandbox/cms_refactor/layers/Generic/Generic.js
===================================================================
--- sandbox/cms_refactor/layers/Generic/Generic.js	2018-07-26 14:24:56 UTC (rev 3037)
+++ sandbox/cms_refactor/layers/Generic/Generic.js	2018-07-26 15:02:28 UTC (rev 3038)
@@ -153,23 +153,6 @@
                 type: this.mapTag.layerOptions.type
              });
              break;
-         case 'Yahoo':
-            switch (this.mapTag.layerOptions.type) {   //Yahoo is similar to google
-              case 'YAHOO_MAP_SAT':              //defined by YMap, not a string
-              case 'YAHOO_SAT':
-                this.mapTag.layerOptions.type = YAHOO_MAP_SAT;
-                break;
-              case 'YAHOO_MAP_HYB':
-              case 'YAHOO_HYB':
-                this.mapTag.layerOptions.type = YAHOO_MAP_HYB;
-                break;
-              case 'YAHOO_MAP_REG':
-              case "YAHOO_REG":
-              default:
-                this.mapTag.layerOptions.type = YAHOO_MAP_REG;
-                break;
-            }
-            break;
          case 'OpenStreetMap':
          case 'OSM':
             if (this.mapTag.layerOptions.type) {
@@ -180,7 +163,9 @@
             }
             break;
          case 'Stamen':
-            this.oLayerOL = new OpenLayers.Layer[this.layerType](this.mapTag.layerOptions.type);
+            var stt = this.mapTag.layerOptions.type;
+            var url = "http://tile.stamen.com/" + stt + "/${z}/${x}/${y}.png";
+            this.oLayerOL = new OpenLayers.Layer.XYZ("Stamen (" + stt + ")", url, this.mapTag.layerOptions);
             break;
          case 'XYZ':
             this.oLayerOL = new OpenLayers.Layer[this.layerType](
@@ -200,11 +185,46 @@
        
         if (!this.oLayerOL) {
             if(this.layerType == 'OpenStreetMap' || this.layerType == 'OSM') {
+                var layerOpts = this.mapTag.layerOptions;
+                var osmLayerType = this.mapTag.layerOptions.type;
+                var urls = this.mapTag.layerOptions.urls;
                 //Test OSM sub-type before falling back to OpenLayers.Layer.OSM
-                if (typeof(OpenLayers.Layer.OSM[this.mapTag.layerOptions.type]) != 'undefined') { 
-                    this.oLayerOL = new OpenLayers.Layer.OSM[this.mapTag.layerOptions.type](this.getMapName(), null, this.mapTag.layerOptions );
+                if (osmLayerType != "Mapnik") {
+                    switch (osmLayerType) {
+                        case "CycleMap":
+                            if (!urls) {
+                                urls = [
+                                    "http://a.tile.opencyclemap.org/cycle/${z}/${x}/${y}.png",
+                                    "http://b.tile.opencyclemap.org/cycle/${z}/${x}/${y}.png",
+                                    "http://c.tile.opencyclemap.org/cycle/${z}/${x}/${y}.png"
+                                ];
+                            }
+                            layerOpts = OpenLayers.Util.extend({
+                                numZoomLevels: 19,
+                                attribution: "© <a href='http://www.openstreetmap.org/copyright'>OpenStreetMap</a> contributors, Tiles courtesy of <a href='http://www.opencyclemap.org'>Andy Allan</a>",
+                                buffer: 0,
+                                transitionEffect: "resize"
+                            }, layerOpts);
+                            break;
+                        case "TransportMap":
+                            if (!urls) {
+                                urls = [
+                                    "http://a.tile2.opencyclemap.org/transport/${z}/${x}/${y}.png",
+                                    "http://b.tile2.opencyclemap.org/transport/${z}/${x}/${y}.png",
+                                    "http://c.tile2.opencyclemap.org/transport/${z}/${x}/${y}.png"
+                                ];
+                            }
+                            layerOpts = OpenLayers.Util.extend({
+                                numZoomLevels: 19,
+                                attribution: "© <a href='http://www.openstreetmap.org/copyright'>OpenStreetMap</a> contributors, Tiles courtesy of <a href='http://www.opencyclemap.org'>Andy Allan</a>",
+                                buffer: 0,
+                                transitionEffect: "resize"
+                            }, layerOpts);
+                            break;
+                    }
+                    this.oLayerOL = new OpenLayers.Layer.OSM("OpenStreetMap - " + osmLayerType, urls, layerOpts);
                 } else {
-                    this.oLayerOL = new OpenLayers.Layer.OSM(this.getMapName(), null, this.mapTag.layerOptions );
+                    this.oLayerOL = new OpenLayers.Layer.OSM(this.getMapName(), urls, layerOpts);
                 }
             }
             else {

Modified: sandbox/cms_refactor/lib/fusion.js
===================================================================
--- sandbox/cms_refactor/lib/fusion.js	2018-07-26 14:24:56 UTC (rev 3037)
+++ sandbox/cms_refactor/lib/fusion.js	2018-07-26 15:02:28 UTC (rev 3038)
@@ -415,17 +415,8 @@
                         var appDefXML = xhr.responseXML.documentElement; 
 
                         if (appDefXML) {
-                            var googleElement = appDefXML.getElementsByTagName("GoogleScript")[0]; 
-                            var yahooElement = appDefXML.getElementsByTagName("YahooScript")[0]; 
-                            var veElement = appDefXML.getElementsByTagName("VirtualEarthScript")[0];
-                            var osmElement = appDefXML.getElementsByTagName("OpenStreetMapScript")[0];
-                            var stamenElement = appDefXML.getElementsByTagName("StamenScript")[0];
-
+                            var googleElement = appDefXML.getElementsByTagName("GoogleScript")[0];
                             addElement(googleElement); 
-                            addElement(yahooElement); 
-                            addElement(veElement);
-                            addElement(osmElement);
-                            addElement(stamenElement);
 
                             var bingMapKeyElement = appDefXML.getElementsByTagName("BingMapKey")[0];
                             if (bingMapKeyElement) {



More information about the fusion-commits mailing list