Replace goog.Uri in kml format with URL()

This commit is contained in:
Peter Robins
2016-06-24 09:25:29 +00:00
parent 57af1a9b24
commit 810ed63b9f
5 changed files with 21 additions and 11 deletions

View File

@@ -5,7 +5,6 @@
goog.provide('ol.format.KML');
goog.require('goog.Uri');
goog.require('goog.asserts');
goog.require('goog.object');
goog.require('ol');
@@ -44,6 +43,9 @@ goog.require('ol.xml');
* @classdesc
* Feature format for reading and writing data in the KML format.
*
* Note that the KML format uses the URL() constructor. Older browsers such as IE
* which do not support this will need a URL polyfill to be loaded before use.
*
* @constructor
* @extends {ol.format.XMLFeature}
* @param {olx.format.KMLOptions=} opt_options Options.
@@ -487,7 +489,8 @@ ol.format.KML.readFlatCoordinates_ = function(node) {
ol.format.KML.readStyleUrl_ = function(node) {
var s = ol.xml.getAllTextContent(node, false).trim();
if (node.baseURI) {
return goog.Uri.resolve(node.baseURI, s).toString();
var url = new URL(s, node.baseURI);
return url.href;
} else {
return s;
}
@@ -501,11 +504,12 @@ ol.format.KML.readStyleUrl_ = function(node) {
* @return {string} URI.
*/
ol.format.KML.readURI_ = function(node) {
var s = ol.xml.getAllTextContent(node, false);
var s = ol.xml.getAllTextContent(node, false).trim();
if (node.baseURI) {
return goog.Uri.resolve(node.baseURI, s.trim()).toString();
var url = new URL(s, node.baseURI);
return url.href;
} else {
return s.trim();
return s;
}
};
@@ -1814,7 +1818,8 @@ ol.format.KML.prototype.readSharedStyle_ = function(node, objectStack) {
if (style) {
var styleUri;
if (node.baseURI) {
styleUri = goog.Uri.resolve(node.baseURI, '#' + id).toString();
var url = new URL('#' + id, node.baseURI);
styleUri = url.href;
} else {
styleUri = '#' + id;
}
@@ -1844,7 +1849,8 @@ ol.format.KML.prototype.readSharedStyleMap_ = function(node, objectStack) {
}
var styleUri;
if (node.baseURI) {
styleUri = goog.Uri.resolve(node.baseURI, '#' + id).toString();
var url = new URL('#' + id, node.baseURI);
styleUri = url.href;
} else {
styleUri = '#' + id;
}