Avoid protocol relative URL to support apps using file protocol

This commit is contained in:
Tim Schaub
2014-03-24 14:57:43 -06:00
parent b613c9cde7
commit 9ce7d6ea45
5 changed files with 18 additions and 4 deletions

View File

@@ -54,6 +54,14 @@ ol.ENABLE_WEBGL = true;
ol.LEGACY_IE_SUPPORT = false;
/**
* The page is loaded using HTTPS.
* @const
* @type {boolean}
*/
ol.IS_HTTPS = goog.global.location.protocol === 'https:';
/**
* Whether the current browser is legacy IE
* @const

View File

@@ -37,8 +37,11 @@ ol.source.BingMaps = function(options) {
*/
this.culture_ = goog.isDef(options.culture) ? options.culture : 'en-us';
var protocol = ol.IS_HTTPS ? 'https:' : 'http:';
var uri = new goog.Uri(
'//dev.virtualearth.net/REST/v1/Imagery/Metadata/' + options.imagerySet);
protocol + '//dev.virtualearth.net/REST/v1/Imagery/Metadata/' +
options.imagerySet);
var jsonp = new goog.net.Jsonp(uri, 'jsonp');
jsonp.send({
'include': 'ImageryProviders',

View File

@@ -20,7 +20,8 @@ ol.source.MapQuest = function(opt_options) {
var layerConfig = ol.source.MapQuestConfig[options.layer];
var url = '//otile{1-4}-s.mqcdn.com/tiles/1.0.0/' +
var protocol = ol.IS_HTTPS ? 'https:' : 'http:';
var url = protocol + '//otile{1-4}-s.mqcdn.com/tiles/1.0.0/' +
options.layer + '/{z}/{x}/{y}.jpg';
goog.base(this, {

View File

@@ -25,8 +25,9 @@ ol.source.OSM = function(opt_options) {
var crossOrigin = goog.isDef(options.crossOrigin) ?
options.crossOrigin : 'anonymous';
var protocol = ol.IS_HTTPS ? 'https:' : 'http:';
var url = goog.isDef(options.url) ?
options.url : '//{a-c}.tile.openstreetmap.org/{z}/{x}/{y}.png';
options.url : protocol + '//{a-c}.tile.openstreetmap.org/{z}/{x}/{y}.png';
goog.base(this, {
attributions: attributions,

View File

@@ -93,8 +93,9 @@ ol.source.Stamen = function(options) {
goog.asserts.assert(options.layer in ol.source.StamenLayerConfig);
var layerConfig = ol.source.StamenLayerConfig[options.layer];
var protocol = ol.IS_HTTPS ? 'https:' : 'http:';
var url = goog.isDef(options.url) ? options.url :
'//{a-d}.tile.stamen.com/' + options.layer + '/{z}/{x}/{y}.' +
protocol + '//{a-d}.tile.stamen.com/' + options.layer + '/{z}/{x}/{y}.' +
layerConfig.extension;
goog.base(this, {