|
222 | 222 | });
|
223 | 223 | },
|
224 | 224 |
|
225 |
| - isMappedResource: function($el) { |
226 |
| - const data = $el.data(this.marker.mappedResourceData.settings); |
| 225 | + isMappedResource: function($el, data) { |
| 226 | + data = typeof data !== 'undefined' ? data : $el.data(this.marker.mappedResourceData.settings); |
227 | 227 | return $.isPlainObject(data) && typeof data.mapId === 'string' && data.mapId !== '';
|
228 | 228 | },
|
229 | 229 |
|
230 | 230 | refreshMappedResource: function ($el, settings) {
|
231 | 231 | const data = $el.data(this.marker.mappedResourceData.settings);
|
232 |
| - |
233 |
| - // mapId was no string and empty |
234 |
| - if (!$.isPlainObject(data) || typeof data.mapId !== 'string' || data.mapId === '') { |
235 |
| - return; |
| 232 | + if (this.isMappedResource($el, data)) { |
| 233 | + this._renderMappedResource($el, data.type, data.mapId, settings); |
236 | 234 | }
|
237 |
| - |
238 |
| - this._renderMappedResource($el, data.type, data.mapId, settings); |
239 | 235 | },
|
240 | 236 |
|
241 | 237 | _handleMappedResource: function ($el, callback) {
|
|
252 | 248 | // determine the type (if we do not have one)
|
253 | 249 | let type = $el.attr('data-type');
|
254 | 250 | if (typeof type !== 'string' || type.trim() === '') {
|
255 |
| - callback(new Error('missing type')); |
256 |
| - return; |
| 251 | + type = this.marker.mappedResourceAutoDetectionType; |
257 | 252 | }
|
258 | 253 |
|
259 | 254 | const render = function ($selectedEl, selectedType, foundMapId, cb) {
|
|
262 | 257 | if (typeof selectedType !== 'string' || selectedType.trim() === '') {
|
263 | 258 | cb(new Error('invalid type: ' + selectedType));
|
264 | 259 | } else {
|
265 |
| - _self._renderMappedResource($selectedEl, selectedType, foundMapId, null, cb); |
| 260 | + const data = $selectedEl.data(_self.marker.mappedResourceData.settings); |
| 261 | + const currentSettings = $.isPlainObject(data.settings) ? data.settings : {}; |
| 262 | + |
| 263 | + _self._renderMappedResource($selectedEl, selectedType, foundMapId, currentSettings, cb); |
266 | 264 | }
|
267 | 265 | };
|
268 | 266 |
|
|
528 | 526 | }
|
529 | 527 |
|
530 | 528 | const data = $resource.data(this.marker.mappedResourceData.settings);
|
531 |
| - if (!$.isPlainObject(data) || typeof data.mapId !== 'string') { |
| 529 | + if (!this.isMappedResource($resource, data)) { |
532 | 530 | return false;
|
533 | 531 | }
|
534 | 532 |
|
|
0 commit comments