fix: cannot load marker cluster image
MODIFY
www/Map.js
www/Map.js
-
-
var utils = require('cordova/utils'),
cordova_exec = require('cordova/exec'),
common = require('./Common'),
@@ -1332,7 +1330,7 @@ Map.prototype.addMarker = function(markerOptions, callback) {
markerOptions = common.markerOptionsFilter(markerOptions);
//------------------------------------
- // Generate a makrer instance at once.
+// Generate a marKer instance at once.
//------------------------------------
markerOptions.icon = markerOptions.icon || {};
var link;
@@ -1471,7 +1469,8 @@ Map.prototype.addMarkerCluster = function(markerClusterOptions, callback) {
}, markerCluster.hashCode]);
return markerCluster;
-};
+}
+;
/*****************************************************************************
* Callbacks from the native side

MODIFY
www/MarkerCluster.js
www/MarkerCluster.js
-
/* eslint no-useless-escape: off */
var utils = require('cordova/utils'),
@@ -102,6 +101,27 @@ var MarkerCluster = function (map, markerClusterOptions, _exec) {
if (!icons[i]) {
continue;
}
+ var link;
+ if (typeof icons[i] === 'string') {
+ if (icons[i].indexOf('://') === -1 &&
+ icons[i].indexOf('.') === 0) {
+
+ link = document.createElement('a');
+ link.href = icons[i];
+ icons[i] = link.protocol + '//' + link.host + link.pathname + link.search;
+ link = undefined;
+ }
+ } else if (typeof icons[i].url === 'string') {
+ if (icons[i].url.indexOf('://') === -1 &&
+ icons[i].url.indexOf('.') === 0) {
+
+ link = document.createElement('a');
+ link.href = icons[i].url;
+ icons[i].url = link.protocol + '//' + link.host + link.pathname + link.search;
+ link = undefined;
+ }
+
+ }
if (icons[i].anchor &&
typeof icons[i].anchor === 'object' &&
'x' in icons[i].anchor &&
@@ -136,6 +156,27 @@ var MarkerCluster = function (map, markerClusterOptions, _exec) {
geocell: geocell
};
+ if (typeof markerOptions.icon === 'string') {
+ if (markerOptions.icon.indexOf('://') === -1 &&
+ markerOptions.icon.indexOf('.') === 0) {
+
+ link = document.createElement('a');
+ link.href = markerOptions.icon;
+ markerOptions.icon = link.protocol + '//' + link.host + link.pathname + link.search;
+ link = undefined;
+ }
+ } else if (typeof markerOptions.icon === 'object' && typeof markerOptions.icon.url === 'string') {
+ if (markerOptions.icon.url.indexOf('://') === -1 &&
+ markerOptions.icon.url.indexOf('.') === 0) {
+
+ link = document.createElement('a');
+ link.href = markerOptions.icon.url;
+ markerOptions.icon.url = link.protocol + '//' + link.host + link.pathname + link.search;
+ link = undefined;
+ }
+ }
+
+
var marker = self._createMarker(markerOptions);
var markerId = marker.__pgmId.replace(/^.+-/, '');
Object.defineProperty(marker, '__cid', {
@@ -151,6 +192,7 @@ var MarkerCluster = function (map, markerClusterOptions, _exec) {
});
return marker;
};
+
self.addMarkers = function (markers) {
var results = [];
if (utils.isArray(markers) || Array.isArray(markers)) {

fix: cannot load marker cluster image