New URL Templates for Bing Maps Tiles

2917
1
Jump to solution
01-22-2014 01:34 PM
GordonBooth
New Contributor III
Yesterday there was a change made by the Bing Maps team for imagery requests and also for requesting tiles using SSL. The following forum post also explains the changes that were made:

http://social.msdn.microsoft.com/Forums/en-US/home?forum=bingmapsservices&announcementId=1e0a8543-83...

This was an unannounced change and before they rolled back the change the Bing map imagery was essentially unavailable.
Going forward, Bing Maps Enterprise Support recommend I contact Esri. 

Are you aware of this change and are you working on a fix?
Thanks for your help.
0 Kudos
1 Solution

Accepted Solutions
GordonBooth
New Contributor III
Esri suggested using setRequestPreCallback to work around this issue if Microsoft rolls out the update again without notice.  setRequestPreCallback allows you modify the request before its made so you can update url parameters.

You???ll want to add the following code:
//add setRequest             esri.setRequestPreCallback(myCallbackFunction);   function myCallbackFunction(ioArgs) {                                 console.log(ioArgs.url);                 //check to make sure the url is going to Microsoft                 if (ioArgs.url.indexOf("virtualearth") > -1) {                   //if so, add a new parameter called uriScheme and set the value equal to 'https'                   ioArgs.content.uriScheme = "https";                     // don't forget to return ioArgs.                                    }                 return ioArgs;             }


Here???s some working code:
<!DOCTYPE html> <html> <head>          <!--The viewport meta tag is used to improve the presentation and behavior of the samples        on iOS devices-->          <title>VE Tile Layer</title>     <link rel="stylesheet" href="https://js.arcgis.com/3.2/js/dojo/dijit/themes/claro/claro.css">     <link rel="stylesheet" href="https://js.arcgis.com/3.2/js/esri/css/esri.css">      <script>dojoConfig = { parseOnLoad: true }</script>     <script src="https://js.arcgis.com/3.2/"></script>     <script>         dojo.require("esri.map");         dojo.require("esri.virtualearth.VETiledLayer");         dojo.require("dijit.form.Button");          var veTileLayer;          function init() {             var map = new esri.Map("map");              //add setRequest             esri.setRequestPreCallback(myCallbackFunction);              //Creates the Virtual Earth layer to add to the map             veTileLayer = new esri.virtualearth.VETiledLayer({                 bingMapsKey: 'Your Bing Map Key goes here',                   mapStyle: esri.virtualearth.VETiledLayer.MAP_STYLE_AERIAL                              });              function myCallbackFunction(ioArgs) {                                 console.log(ioArgs.url);                 //check to make sure the url is going to Microsoft                 if (ioArgs.url.indexOf("virtualearth") > -1) {                   //if so, add a new parameter called uriScheme and set the value equal to 'https'                   ioArgs.content.uriScheme = "https";                     // don't forget to return ioArgs.                                    }                 return ioArgs;             }              map.addLayer(veTileLayer);          }         dojo.ready(init);     </script>  </head> <body class="claro">     <div style="position: relative;">         <div id="map" style="width: 1024px; height: 512px; border: 1px solid #000;">             <div style="position: absolute; left: 650px; top: 10px; z-Index: 999;">                 <button data-dojo-type="dijit.form.Button" onclick="veTileLayer.setMapStyle(esri.virtualearth.VETiledLayer.MAP_STYLE_AERIAL);">Aerial</button>                 <button data-dojo-type="dijit.form.Button" onclick="veTileLayer.setMapStyle(esri.virtualearth.VETiledLayer.MAP_STYLE_AERIAL_WITH_LABELS)">Aerial with labels</button>                 <button data-dojo-type="dijit.form.Button" onclick="veTileLayer.setMapStyle(esri.virtualearth.VETiledLayer.MAP_STYLE_ROAD)">Roads</button>             </div>         </div>     </div> </body> </html>


Check it out ??? use Net in Firebug or some other browser dev tool and notice the map tile url???s begin with https.
[ATTACH=CONFIG]32080[/ATTACH]

View solution in original post

0 Kudos
1 Reply
GordonBooth
New Contributor III
Esri suggested using setRequestPreCallback to work around this issue if Microsoft rolls out the update again without notice.  setRequestPreCallback allows you modify the request before its made so you can update url parameters.

You???ll want to add the following code:
//add setRequest             esri.setRequestPreCallback(myCallbackFunction);   function myCallbackFunction(ioArgs) {                                 console.log(ioArgs.url);                 //check to make sure the url is going to Microsoft                 if (ioArgs.url.indexOf("virtualearth") > -1) {                   //if so, add a new parameter called uriScheme and set the value equal to 'https'                   ioArgs.content.uriScheme = "https";                     // don't forget to return ioArgs.                                    }                 return ioArgs;             }


Here???s some working code:
<!DOCTYPE html> <html> <head>          <!--The viewport meta tag is used to improve the presentation and behavior of the samples        on iOS devices-->          <title>VE Tile Layer</title>     <link rel="stylesheet" href="https://js.arcgis.com/3.2/js/dojo/dijit/themes/claro/claro.css">     <link rel="stylesheet" href="https://js.arcgis.com/3.2/js/esri/css/esri.css">      <script>dojoConfig = { parseOnLoad: true }</script>     <script src="https://js.arcgis.com/3.2/"></script>     <script>         dojo.require("esri.map");         dojo.require("esri.virtualearth.VETiledLayer");         dojo.require("dijit.form.Button");          var veTileLayer;          function init() {             var map = new esri.Map("map");              //add setRequest             esri.setRequestPreCallback(myCallbackFunction);              //Creates the Virtual Earth layer to add to the map             veTileLayer = new esri.virtualearth.VETiledLayer({                 bingMapsKey: 'Your Bing Map Key goes here',                   mapStyle: esri.virtualearth.VETiledLayer.MAP_STYLE_AERIAL                              });              function myCallbackFunction(ioArgs) {                                 console.log(ioArgs.url);                 //check to make sure the url is going to Microsoft                 if (ioArgs.url.indexOf("virtualearth") > -1) {                   //if so, add a new parameter called uriScheme and set the value equal to 'https'                   ioArgs.content.uriScheme = "https";                     // don't forget to return ioArgs.                                    }                 return ioArgs;             }              map.addLayer(veTileLayer);          }         dojo.ready(init);     </script>  </head> <body class="claro">     <div style="position: relative;">         <div id="map" style="width: 1024px; height: 512px; border: 1px solid #000;">             <div style="position: absolute; left: 650px; top: 10px; z-Index: 999;">                 <button data-dojo-type="dijit.form.Button" onclick="veTileLayer.setMapStyle(esri.virtualearth.VETiledLayer.MAP_STYLE_AERIAL);">Aerial</button>                 <button data-dojo-type="dijit.form.Button" onclick="veTileLayer.setMapStyle(esri.virtualearth.VETiledLayer.MAP_STYLE_AERIAL_WITH_LABELS)">Aerial with labels</button>                 <button data-dojo-type="dijit.form.Button" onclick="veTileLayer.setMapStyle(esri.virtualearth.VETiledLayer.MAP_STYLE_ROAD)">Roads</button>             </div>         </div>     </div> </body> </html>


Check it out ??? use Net in Firebug or some other browser dev tool and notice the map tile url???s begin with https.
[ATTACH=CONFIG]32080[/ATTACH]
0 Kudos