Fix: (JS) map.addKmlOverlay() does not work if page url contains '#hash'
MODIFY
www/Map.js
www/Map.js
@@ -970,9 +970,6 @@ Map.prototype.setPadding = function(p1, p2, p3, p4) {
};
-//-------------
-// KML Layer
-//-------------
Map.prototype.addKmlOverlay = function(kmlOverlayOptions, callback) {
var self = this;
kmlOverlayOptions = kmlOverlayOptions || {};
@@ -980,6 +977,12 @@ Map.prototype.addKmlOverlay = function(kmlOverlayOptions, callback) {
kmlOverlayOptions.clickable = common.defaultTrueOption(kmlOverlayOptions.clickable);
kmlOverlayOptions.suppressInfoWindows = kmlOverlayOptions.suppressInfoWindows === true;
+ if (kmlOverlayOptions.url) {
+
+ var link = document.createElement("a");
+ link.href = kmlOverlayOptions.url;
+ kmlOverlayOptions.url = link.protocol+"//"+link.host+link.pathname;
+
var invisible_dot = self.get("invisible_dot");
if (!invisible_dot || invisible_dot._isRemoved) {
// Create an invisible marker for kmlOverlay
@@ -1016,8 +1019,15 @@ Map.prototype.addKmlOverlay = function(kmlOverlayOptions, callback) {
} else {
return new Promise(resolver);
}
-};
+ } else {
+ if (typeof callback === "function") {
+ throw new Error('KML file url is required.');
+ } else {
+ return Promise.reject('KML file url is required.');
+ }
+ }
+};
//-------------
// Ground overlay

Fix: (JS) map.addKmlOverlay() does not work if page url contains '#hash' #2396