all files / maps/layers/ marker.js

94.77% Statements 290/306
87.12% Branches 318/365
95.83% Functions 23/24
95.08% Lines 290/305
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514   284× 284× 284× 284×   290×   308× 308× 308× 308× 308× 308× 308× 308× 308× 308×     307×         308× 308× 308× 308× 308×     307×       307×           308× 308× 308× 308× 248×       308× 381× 381× 381× 380× 1728× 1728×                         1728× 1728× 1728× 1728×     1728×     1728× 1728× 1722×   1722× 1722× 414×   1722× 1722× 1722× 458× 458× 458× 458×   1264× 1254× 1254× 1254×     1728× 1728× 1728× 1728×   1728× 1728× 1728×       1728× 1728× 256× 255×   256×   45× 45× 45×   45×   15× 15× 15×       30×   45×     1728×       1728× 344× 68×   344× 342×   41× 41×     344×                       152× 148× 19× 19× 19× 19× 19× 19× 19× 19× 19× 19× 19×     19× 19× 19× 19× 19× 33× 33× 32× 130×   130×   130× 126×   126×   126×   126×   126×   126× 18×   126× 69×   126× 44×               19×   19× 19× 19× 19× 19× 19×         19× 19× 18× 18× 12×                                         19×       129× 129×       129×                                                                                       62× 62× 49×   13× 13×     13×               13×           13×   117× 117× 117× 117× 117× 117× 117× 117× 84× 84× 84× 84× 84×   84× 84× 84× 84× 109× 26×       84× 15× 15×   15× 15× 15× 15× 93× 93× 93×   15× 15×           84×     33×   103× 103×   95× 95× 32×   63×     63×       63×   103× 103× 101×                   495× 495× 615×     495×   285× 321× 321×     3452×   280× 280× 280× 280× 280×        
define(["require", "exports", "../index", "../index", "@syncfusion/ej2-base", "../utils/helper", "../utils/helper"], function (require, exports, index_1, index_2, ej2_base_1, helper_1, helper_2) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    var Marker = (function () {
        function Marker(maps) {
            this.maps = maps;
            this.sameMarkerData = [];
            this.initialMarkerCluster = [];
            this.zoomedMarkerCluster = [];
        }
        Marker.prototype.getMapsInstance = function () {
            return this.maps;
        };
        Marker.prototype.markerRender = function (maps, layerElement, layerIndex, factor, type) {
            var _this = this;
            var templateFn;
            var markerCount = 0;
            var nullCount = 0;
            var isMarkerTemplateNewCreation = false;
            var markerTemplateCount = 0;
            maps.translateType = 'marker';
            var currentLayer = maps.layersCollection[layerIndex];
            var markerElement = layerElement.querySelectorAll('#' + maps.element.id + '_Markers_Group');
            if (markerElement.length > 0) {
                this.markerSVGObject = markerElement[0];
                this.markerSVGObject.innerHTML = '';
                isMarkerTemplateNewCreation = true;
            }
            else {
                this.markerSVGObject = maps.renderer.createGroup({
                    id: maps.element.id + '_Markers_Group',
                    class: 'GroupElement'
                });
            }
            this.markerSVGObject.style.pointerEvents = 'auto';
            var secondaryElement = helper_2.getElementByID(maps.element.id + '_Secondary_Element');
            var markerTemplateElement = secondaryElement.querySelectorAll('#' + maps.element.id + '_LayerIndex_' + layerIndex + '_Markers_Template_Group');
            var markerTemplateEle;
            if (markerTemplateElement && markerTemplateElement.length > 0 && markerTemplateElement[0].childElementCount > 0) {
                markerTemplateEle = helper_2.getElementByID(maps.element.id + '_LayerIndex_' + layerIndex + '_Markers_Template_Group');
                markerTemplateEle.innerHTML = '';
                isMarkerTemplateNewCreation = true;
            }
            else {
                markerTemplateEle = ej2_base_1.createElement('div', {
                    id: maps.element.id + '_LayerIndex_' + layerIndex + '_Markers_Template_Group',
                    className: maps.element.id + '_template'
                });
                markerTemplateEle.style.cssText = 'overflow: hidden; position: absolute;pointer-events: none;' +
                    'top:' + maps.mapAreaRect.y + 'px;' +
                    'left:' + maps.mapAreaRect.x + 'px;' +
                    'height:' + maps.mapAreaRect.height + 'px;' +
                    'width:' + maps.mapAreaRect.width + 'px;';
            }
            var allowInnerClusterSetting = this.allowInnerClusterSetting(currentLayer);
            var allowAnimation = (currentLayer.animationDuration !== 0 || ej2_base_1.animationMode === 'Enable') || ej2_base_1.isNullOrUndefined(maps.zoomModule);
            var translatePoint;
            if (!maps.isTileMap) {
                translatePoint = !ej2_base_1.isNullOrUndefined(maps.zoomModule) && maps.zoomSettings.zoomFactor > 1 ?
                    helper_1.getZoomTranslate(maps, currentLayer, allowAnimation) :
                    helper_1.getTranslate(maps, currentLayer, allowAnimation);
            }
            Array.prototype.forEach.call(currentLayer.markerSettings, function (markerSettings, markerIndex) {
                var markerData = markerSettings.dataSource;
                markerCount = 0;
                if (!ej2_base_1.isNullOrUndefined(markerSettings.dataSource)) {
                    Array.prototype.forEach.call(markerData, function (data, dataIndex) {
                        maps.markerNullCount = markerIndex > 0 && dataIndex === 0 ? 0 : maps.markerNullCount;
                        var eventArgs = {
                            cancel: false, name: index_1.markerRendering, fill: markerSettings.fill,
                            height: (!ej2_base_1.isNullOrUndefined(markerSettings.heightValuePath) &&
                                !ej2_base_1.isNullOrUndefined(data[markerSettings.heightValuePath]) ?
                                data[markerSettings.heightValuePath] : markerSettings.height),
                            width: (!ej2_base_1.isNullOrUndefined(markerSettings.widthValuePath) &&
                                !ej2_base_1.isNullOrUndefined(data[markerSettings.widthValuePath]) ?
                                data[markerSettings.widthValuePath] : markerSettings.width),
                            imageUrl: markerSettings.imageUrl, shape: markerSettings.shape,
                            template: markerSettings.template, data: data, maps: maps, marker: markerSettings,
                            border: markerSettings.border, colorValuePath: markerSettings.colorValuePath,
                            shapeValuePath: markerSettings.shapeValuePath, imageUrlValuePath: markerSettings.imageUrlValuePath
                        };
                        maps.trigger('markerRendering', eventArgs, function (MarkerArgs) {
                            eventArgs = helper_2.markerColorChoose(eventArgs, data);
                            eventArgs = helper_2.markerShapeChoose(eventArgs, data);
                            var lng = (!ej2_base_1.isNullOrUndefined(markerSettings.longitudeValuePath)) ?
                                Number(helper_2.getValueFromObject(data, markerSettings.longitudeValuePath)) : !ej2_base_1.isNullOrUndefined(data['longitude']) ?
                                parseFloat(data['longitude']) : !ej2_base_1.isNullOrUndefined(data['Longitude']) ? parseFloat(data['Longitude']) : null;
                            var lat = (!ej2_base_1.isNullOrUndefined(markerSettings.latitudeValuePath)) ?
                                Number(helper_2.getValueFromObject(data, markerSettings.latitudeValuePath)) : !ej2_base_1.isNullOrUndefined(data['latitude']) ?
                                parseFloat(data['latitude']) : !ej2_base_1.isNullOrUndefined(data['Latitude']) ? parseFloat(data['Latitude']) : null;
                            var offset = markerSettings.offset;
                            if (!eventArgs.cancel && markerSettings.visible && !ej2_base_1.isNullOrUndefined(lng) && !ej2_base_1.isNullOrUndefined(lat)) {
                                var markerID = maps.element.id + '_LayerIndex_' + layerIndex + '_MarkerIndex_'
                                    + markerIndex + '_dataIndex_' + dataIndex;
                                var location_1 = (maps.isTileMap) ? index_1.convertTileLatLongToPoint(new index_1.MapLocation(lng, lat), factor, maps.tileTranslatePoint, true) : helper_1.convertGeoToPoint(lat, lng, factor, currentLayer, maps);
                                if (maps.isTileMap) {
                                    translatePoint = (currentLayer.type === 'SubLayer' && ej2_base_1.isNullOrUndefined(maps.zoomModule)) ? location_1 = index_1.convertTileLatLongToPoint(new index_1.MapLocation(lng, lat), maps.tileZoomLevel, maps.tileTranslatePoint, true) : new Object();
                                }
                                var scale = type === 'AddMarker' ? maps.scale : translatePoint['scale'];
                                var transPoint = type === 'AddMarker' ? maps.translatePoint : translatePoint['location'];
                                if (eventArgs.template && (!isNaN(location_1.x) && !isNaN(location_1.y))) {
                                    isMarkerTemplateNewCreation = false;
                                    markerTemplateCount++;
                                    helper_1.markerTemplate(eventArgs, templateFn, markerID, data, markerIndex, markerTemplateEle, location_1, transPoint, scale, offset, maps);
                                    maps.renderReactTemplates();
                                }
                                else if (!eventArgs.template && (!isNaN(location_1.x) && !isNaN(location_1.y))) {
                                    isMarkerTemplateNewCreation = true;
                                    markerCount++;
                                    helper_1.marker(eventArgs, markerSettings, markerData, dataIndex, location_1, transPoint, markerID, offset, scale, maps, _this.markerSVGObject);
                                }
                            }
                            nullCount += (!isNaN(lat) && !isNaN(lng)) ? 0 : 1;
                            markerTemplateCount += (eventArgs.cancel) ? 1 : 0;
                            markerCount += (eventArgs.cancel) ? 1 : 0;
                            maps.markerNullCount = (ej2_base_1.isNullOrUndefined(lng) || ej2_base_1.isNullOrUndefined(lat)) ?
                                maps.markerNullCount + 1 : maps.markerNullCount;
                            var markerDataLength = markerData.length - maps.markerNullCount;
                            var isMarkersClustered = false;
                            var markerGroup = (markerSettings.clusterSettings.allowClustering ||
                                (currentLayer.markerClusterSettings.allowClustering && currentLayer.markerSettings.length > 1))
                                ? _this.markerSVGObject.querySelectorAll("[id*='LayerIndex_" + layerIndex + "_MarkerIndex_" + markerIndex + "']:not([id*='_Group'])")
                                : _this.markerSVGObject.childNodes;
                            var templateCount = _this.markerSVGObject.childNodes === markerGroup ? markerTemplateCount : 0;
                            if (markerGroup.length === (markerDataLength - templateCount - nullCount) && (type !== 'Template')) {
                                if (markerElement.length === 0) {
                                    layerElement.appendChild(_this.markerSVGObject);
                                }
                                if (markerSettings.clusterSettings.allowClustering || !allowInnerClusterSetting &&
                                    currentLayer.markerClusterSettings.allowClustering) {
                                    Eif (markerElement.length === 0) {
                                        maps.svgObject.appendChild(_this.markerSVGObject);
                                        maps.element.appendChild(maps.svgObject);
                                    }
                                    if ((currentLayer.urlTemplate.indexOf('openstreetmap') !== -1 && ej2_base_1.isNullOrUndefined(currentLayer.shapeData))
                                        && maps.zoomSettings.enable) {
                                        isMarkersClustered = helper_1.clusterTemplate(currentLayer, _this.markerSVGObject, maps, layerIndex, markerIndex, _this.markerSVGObject, layerElement, true, false, null, allowInnerClusterSetting);
                                        Eif (markerElement.length === 0) {
                                            layerElement.appendChild(_this.markerSVGObject);
                                        }
                                    }
                                    else {
                                        isMarkersClustered = helper_1.clusterTemplate(currentLayer, _this.markerSVGObject, maps, layerIndex, markerIndex, _this.markerSVGObject, layerElement, true, false, translatePoint, allowInnerClusterSetting);
                                    }
                                    maps.renderReactTemplates();
                                }
                            }
                            var markerTemplateGroup = (markerSettings.clusterSettings.allowClustering ||
                                (currentLayer.markerClusterSettings.allowClustering && currentLayer.markerSettings.length > 1))
                                ? markerTemplateEle.querySelectorAll("[id*='LayerIndex_" + layerIndex + "_MarkerIndex_" + markerIndex + "']:not([id*='_Group'])")
                                : markerTemplateEle.childNodes;
                            if (markerTemplateGroup.length === (markerDataLength - markerCount - nullCount) && helper_2.getElementByID(maps.element.id + '_Secondary_Element')) {
                                if (!isMarkerTemplateNewCreation) {
                                    helper_2.getElementByID(maps.element.id + '_Secondary_Element').appendChild(markerTemplateEle);
                                }
                                if (maps.checkInitialRender) {
                                    if ((markerSettings.clusterSettings.allowClustering || !allowInnerClusterSetting &&
                                        currentLayer.markerClusterSettings.allowClustering) && !isMarkersClustered) {
                                        helper_1.clusterTemplate(currentLayer, markerTemplateEle, maps, layerIndex, markerIndex, _this.markerSVGObject, layerElement, false, false, translatePoint, allowInnerClusterSetting);
                                        maps.renderReactTemplates();
                                    }
                                }
                                Iif (currentLayer.markerClusterSettings.allowClustering && markerElement.length > 0) {
                                    var layerCollectionEle = helper_2.getElementByID(maps.element.id + '_Layer_Collections');
                                    layerCollectionEle.appendChild(layerElement);
                                }
                            }
                        });
                    });
                }
            });
        };
        Marker.prototype.calculateIndividualLayerMarkerZoomLevel = function (mapWidth, mapHeight, maxZoomFact) {
            var latZoom;
            var lngZoom;
            var height = Math.abs(this.maps.baseMapBounds.latitude.max - this.maps.baseMapBounds.latitude.min);
            var width = Math.abs(this.maps.baseMapBounds.longitude.max - this.maps.baseMapBounds.longitude.min);
            latZoom = Math.floor(Math.log(mapHeight / height));
            latZoom = (latZoom > maxZoomFact) ? maxZoomFact : latZoom;
            lngZoom = Math.floor(Math.log(mapWidth / width));
            lngZoom = (lngZoom > maxZoomFact) ? maxZoomFact : lngZoom;
            var result = Math.min(latZoom, lngZoom);
            var scaleFactor = Math.min(result, maxZoomFact - 1);
            Eif (!this.maps.isTileMap) {
                helper_2.compareZoomFactor(scaleFactor, this.maps);
            }
            return scaleFactor;
        };
        Marker.prototype.calculateZoomCenterPositionAndFactor = function (layersCollection) {
            if (!ej2_base_1.isNullOrUndefined(this.maps)) {
                if (this.maps.zoomSettings.shouldZoomInitially && this.maps.markerModule) {
                    var minLong_1;
                    var maxLat_1;
                    var minLat_1;
                    var maxLong_1;
                    var zoomLevel = void 0;
                    var centerLat = void 0;
                    var centerLong = void 0;
                    var maxZoomFact = this.maps.zoomSettings.maxZoom;
                    var mapWidth = this.maps.mapAreaRect.width;
                    var mapHeight = this.maps.mapAreaRect.height;
                    this.maps.markerZoomedState = this.maps.markerZoomedState ? this.maps.markerZoomedState :
                        ej2_base_1.isNullOrUndefined(this.maps.markerZoomFactor) ? !this.maps.markerZoomedState :
                            this.maps.markerZoomFactor > 1 ? this.maps.markerZoomedState : !this.maps.markerZoomedState;
                    this.maps.defaultState = this.maps.markerZoomedState ? !this.maps.markerZoomedState : this.maps.defaultState;
                    Array.prototype.forEach.call(layersCollection, function (currentLayer) {
                        var isMarker = currentLayer.markerSettings.length !== 0;
                        Eif (isMarker) {
                            Array.prototype.forEach.call(currentLayer.markerSettings, function (markerSetting) {
                                var markerData = markerSetting.dataSource;
                                if (!ej2_base_1.isNullOrUndefined(markerData) && markerData.length > 0) {
                                    Array.prototype.forEach.call(markerData, function (data, dataIndex) {
                                        var latitude = !ej2_base_1.isNullOrUndefined(data['latitude']) ? parseFloat(data['latitude']) :
                                            !ej2_base_1.isNullOrUndefined(data['Latitude']) ? parseFloat(data['Latitude']) : null;
                                        var longitude = !ej2_base_1.isNullOrUndefined(data['longitude']) ? parseFloat(data['longitude']) :
                                            !ej2_base_1.isNullOrUndefined(data['Longitude']) ? parseFloat(data['Longitude']) : null;
                                        if (!ej2_base_1.isNullOrUndefined(latitude) && !ej2_base_1.isNullOrUndefined(longitude)) {
                                            minLong_1 = ej2_base_1.isNullOrUndefined(minLong_1) && dataIndex === 0 ?
                                                longitude : minLong_1;
                                            maxLat_1 = ej2_base_1.isNullOrUndefined(maxLat_1) && dataIndex === 0 ?
                                                latitude : maxLat_1;
                                            minLat_1 = ej2_base_1.isNullOrUndefined(minLat_1) && dataIndex === 0 ?
                                                latitude : minLat_1;
                                            maxLong_1 = ej2_base_1.isNullOrUndefined(maxLong_1) && dataIndex === 0 ?
                                                longitude : maxLong_1;
                                            if (minLong_1 > longitude) {
                                                minLong_1 = longitude;
                                            }
                                            if (minLat_1 > latitude) {
                                                minLat_1 = latitude;
                                            }
                                            if (maxLong_1 < longitude) {
                                                maxLong_1 = longitude;
                                            }
                                            if (maxLat_1 < latitude) {
                                                maxLat_1 = latitude;
                                            }
                                        }
                                    });
                                }
                            });
                        }
                    });
                    Eif (!ej2_base_1.isNullOrUndefined(minLat_1) && !ej2_base_1.isNullOrUndefined(minLong_1) &&
                        !ej2_base_1.isNullOrUndefined(maxLong_1) && !ej2_base_1.isNullOrUndefined(maxLat_1)) {
                        centerLat = (minLat_1 + maxLat_1) / 2;
                        centerLong = (minLong_1 + maxLong_1) / 2;
                        this.maps.markerCenterLatitude = centerLat;
                        this.maps.markerCenterLongitude = centerLong;
                        Eif (ej2_base_1.isNullOrUndefined(this.maps.markerZoomCenterPoint) || this.maps.markerZoomedState) {
                            this.maps.markerZoomCenterPoint = {
                                latitude: centerLat,
                                longitude: centerLong
                            };
                        }
                        var markerFactor = void 0;
                        if (this.maps.isTileMap || this.maps.baseMapRectBounds['min']['x'] === 0) {
                            zoomLevel = helper_2.calculateZoomLevel(minLat_1, maxLat_1, minLong_1, maxLong_1, mapWidth, mapHeight, this.maps, false);
                            if (this.maps.isTileMap) {
                                markerFactor = ej2_base_1.isNullOrUndefined(this.maps.markerZoomFactor) ?
                                    zoomLevel : ej2_base_1.isNullOrUndefined(this.maps.mapScaleValue) ?
                                    zoomLevel : this.maps.mapScaleValue > 1 && this.maps.markerZoomFactor !== 1 ?
                                    this.maps.mapScaleValue : zoomLevel;
                            }
                            else {
                                markerFactor = ej2_base_1.isNullOrUndefined(this.maps.mapScaleValue) ? zoomLevel :
                                    (Math.floor(this.maps.scale) !== 1 &&
                                        this.maps.mapScaleValue !== zoomLevel)
                                        &&
                                            (ej2_base_1.isNullOrUndefined(this.maps.shouldZoomCurrentFactor))
                                        ? this.maps.mapScaleValue : zoomLevel;
                                Iif (((markerFactor === this.maps.mapScaleValue &&
                                    (this.maps.markerZoomFactor === 1 || this.maps.mapScaleValue === 1))
                                    && (!this.maps.enablePersistence))) {
                                    markerFactor = zoomLevel;
                                }
                            }
                        }
                        else {
                            zoomLevel = this.calculateIndividualLayerMarkerZoomLevel(mapWidth, mapHeight, maxZoomFact);
                            markerFactor = ej2_base_1.isNullOrUndefined(this.maps.mapScaleValue) ? zoomLevel :
                                (this.maps.mapScaleValue !== zoomLevel)
                                    ? this.maps.mapScaleValue : zoomLevel;
                        }
                        this.maps.markerZoomFactor = markerFactor;
                    }
                }
                else {
                    this.maps.markerZoomedState = false;
                    if (this.maps.markerZoomFactor > 1) {
                        this.maps.markerCenterLatitude = null;
                        this.maps.markerCenterLongitude = null;
                        this.maps.markerZoomFactor = 1;
                        Iif (!this.maps.enablePersistence) {
                            this.maps.mapScaleValue = 1;
                        }
                    }
                    if (this.maps.isTileMap && !this.maps.enablePersistence
                        && this.maps.mapScaleValue <= 1) {
                        this.maps.tileZoomLevel = this.maps.mapScaleValue === 0 ? (this.maps.isZoomByPosition ? this.maps.tileZoomLevel : 1)
                            : this.maps.mapScaleValue;
                        Iif (this.maps.mapScaleValue === 1 && this.maps.markerZoomFactor === 1 &&
                            !ej2_base_1.isNullOrUndefined(this.maps.tileTranslatePoint)) {
                            this.maps.tileTranslatePoint.x = 0;
                            this.maps.tileTranslatePoint.y = 0;
                        }
                    }
                }
            }
        };
        Marker.prototype.markerClick = function (e) {
            var target = e.target.id;
            Iif (target.indexOf(this.maps.element.id) === -1) {
                var ancestor = e.target.closest('.' + this.maps.element.id + '_marker_template_element');
                if (!ej2_base_1.isNullOrUndefined(ancestor) && ancestor.id.indexOf('_MarkerIndex_') > -1) {
                    target = ancestor.id;
                }
            }
            Iif (target.indexOf('_LayerIndex_') === -1 || target.indexOf('_cluster_') > 0) {
                return;
            }
            var options = this.getMarker(target);
            if (ej2_base_1.isNullOrUndefined(options)) {
                return;
            }
            if (options.marker.enableDrag) {
                document.getElementById(this.maps.element.id + '_svg').style.cursor = 'grabbing';
            }
            var eventArgs = {
                cancel: false, name: index_2.markerClick, data: options.data, maps: this.maps,
                marker: options.marker, target: target, x: e.clientX, y: e.clientY,
                latitude: options.data['latitude'] || options.data['Latitude'],
                longitude: options.data['longitude'] || options.data['Longitude'],
                value: options.data['name']
            };
            this.maps.trigger(index_2.markerClick, eventArgs);
            if (options.marker.enableDrag) {
                var isCluster = false;
                var layerIndex = parseInt(target.split('_LayerIndex_')[1].split('_')[0], 10);
                var markerIndex = parseInt(target.split('_MarkerIndex_')[1].split('_')[0], 10);
                var dataIndex_1 = parseInt(target.split('_dataIndex_')[1].split('_')[0], 10);
                var marker_1 = this.maps.layers[layerIndex].markerSettings[markerIndex];
                Iif (this.sameMarkerData.length > 0) {
                    isCluster = (this.sameMarkerData[0].data.filter(function (el) { return (el['index'] === dataIndex_1); })).length > 0 &&
                        this.sameMarkerData[0].layerIndex === layerIndex && this.sameMarkerData[0].markerIndex === markerIndex;
                }
                Eif (!isCluster) {
                    var dragEventArgs = {
                        name: index_1.markerDragStart, x: e.clientX, y: e.clientY,
                        latitude: options.data['latitude'] || options.data['Latitude'],
                        longitude: options.data['longitude'] || options.data['Longitude'],
                        layerIndex: layerIndex, markerIndex: markerIndex, dataIndex: dataIndex_1
                    };
                    this.maps.trigger(index_1.markerDragStart, dragEventArgs);
                    this.maps.markerDragArgument = {
                        targetId: target, x: e.clientX, y: e.clientY,
                        latitude: options.data['latitude'] || options.data['Latitude'],
                        longitude: options.data['longitude'] || options.data['Longitude'],
                        shape: ej2_base_1.isNullOrUndefined(marker_1.shapeValuePath) ? marker_1.shape
                            : marker_1.dataSource[dataIndex_1][marker_1.shapeValuePath],
                        layerIndex: layerIndex, markerIndex: markerIndex, dataIndex: dataIndex_1
                    };
                }
            }
        };
        Marker.prototype.markerClusterClick = function (e) {
            var target = e.target.id;
            if (target.indexOf('_LayerIndex_') === -1 || target.indexOf('_cluster_') === -1) {
                return;
            }
            var options = this.getMarker(target);
            Iif (ej2_base_1.isNullOrUndefined(options)) {
                return;
            }
            if ((options.clusterCollection.length > 0 && this.maps.markerClusterExpand)) {
                Iif (helper_2.getElement(this.maps.element.id + '_mapsTooltip') &&
                    this.maps.mapsTooltipModule.tooltipTargetID.indexOf('_MarkerIndex_') > -1) {
                    helper_2.removeElement(this.maps.element.id + '_mapsTooltip');
                }
                if (this.sameMarkerData.length > 0 && !this.maps.markerClusterExpandCheck) {
                    this.maps.markerClusterExpandCheck = true;
                    helper_2.mergeSeparateCluster(this.sameMarkerData, this.maps);
                }
                else {
                    this.sameMarkerData = options.clusterCollection;
                    this.maps.markerClusterExpandCheck = false;
                    helper_2.clusterSeparate(this.sameMarkerData, this.maps, this.markerSVGObject, true);
                }
            }
            var eventArgs = {
                cancel: false, name: index_2.markerClusterClick, data: options, maps: this.maps,
                target: target, x: e.clientX, y: e.clientY,
                latitude: options.data['latitude'] || options.data['Latitude'], longitude: options.data['longitude'] || options.data['Longitude'],
                markerClusterCollection: options['markCollection']
            };
            this.maps.trigger(index_2.markerClusterClick, eventArgs);
        };
        Marker.prototype.getMarker = function (target) {
            var id = target.split('_LayerIndex_');
            var index = parseInt(id[1].split('_')[0], 10);
            var layer = this.maps.layers[index];
            var data;
            var markCollection = [];
            var clusterCollection = [];
            var marker;
            if (target.indexOf('_MarkerIndex_') > -1) {
                var markerIndex = parseInt(id[1].split('_MarkerIndex_')[1].split('_')[0], 10);
                var dataIndex = parseInt(id[1].split('_dataIndex_')[1].split('_')[0], 10);
                marker = layer.markerSettings[markerIndex];
                var allowInnerClusterSetting = this.allowInnerClusterSetting(layer);
                this.maps.markerClusterExpand = !allowInnerClusterSetting && layer.markerClusterSettings.allowClustering ?
                    layer.markerClusterSettings.allowClusterExpand : marker.clusterSettings.allowClusterExpand;
                Eif (!isNaN(markerIndex)) {
                    data = marker.dataSource[dataIndex];
                    var collection_1 = [];
                    if (!marker.template && (target.indexOf('_cluster_') > -1) && this.maps.markerClusterExpand) {
                        Array.prototype.forEach.call(marker.dataSource, function (location, index) {
                            if (location['latitude'] === data['latitude'] && location['longitude'] === data['longitude']) {
                                collection_1.push({ data: data, index: index });
                            }
                        });
                    }
                    if ((target.indexOf('_cluster_') > -1)) {
                        var isClusterSame = false;
                        var cluster = !allowInnerClusterSetting && layer.markerClusterSettings.allowClustering ?
                            layer.markerClusterSettings : layer.markerSettings[markerIndex].clusterSettings;
                        var clusterElement = document.getElementById(target.indexOf('_datalabel_') > -1 ? cluster.shape === 'Balloon' ? target.split('_datalabel_')[0] + '_Group' : target.split('_datalabel_')[0] : cluster.shape === 'Balloon' ? target + '_Group' : target);
                        var indexes = cluster.shape === 'Balloon' ? clusterElement.children[0].textContent.split(',').map(Number) : clusterElement.textContent.split(',').map(Number);
                        collection_1 = [];
                        for (var _i = 0, indexes_1 = indexes; _i < indexes_1.length; _i++) {
                            var i = indexes_1[_i];
                            collection_1.push({ data: marker.dataSource[i], index: i });
                            markCollection.push(marker.dataSource[i]);
                        }
                        isClusterSame = false;
                        clusterCollection.push({
                            data: collection_1, layerIndex: index, markerIndex: markerIndex, dataIndex: dataIndex,
                            targetClusterIndex: +(target.split('_cluster_')[1].indexOf('_datalabel_') > -1 ? target.split('_cluster_')[1].split('_datalabel_')[0] : target.split('_cluster_')[1]),
                            isClusterSame: isClusterSame
                        });
                    }
                    return { marker: marker, data: data, clusterCollection: clusterCollection, markCollection: markCollection };
                }
            }
            return null;
        };
        Marker.prototype.markerMove = function (e) {
            var targetId = e.target.id;
            if (targetId.indexOf('_LayerIndex_') === -1 || targetId.indexOf('_cluster_') > 0) {
                return;
            }
            var options = this.getMarker(targetId);
            if (ej2_base_1.isNullOrUndefined(options)) {
                return;
            }
            if (options.marker.enableDrag) {
                document.getElementById(this.maps.element.id + '_svg').style.cursor = ej2_base_1.isNullOrUndefined(this.maps.markerDragArgument) ?
                    'pointer' : 'grabbing';
            }
            var eventArgs = {
                cancel: false, name: index_2.markerMouseMove, data: options.data,
                maps: this.maps, target: targetId, x: e.clientX, y: e.clientY
            };
            this.maps.trigger(index_2.markerMouseMove, eventArgs);
        };
        Marker.prototype.markerClusterMouseMove = function (e) {
            var targetId = e.target.id;
            if (targetId.indexOf('_LayerIndex_') === -1 || targetId.indexOf('_cluster_') === -1) {
                return;
            }
            var options = this.getMarker(targetId);
            Iif (this.maps.markerClusterExpand) {
                e.target.style.cursor = 'pointer';
            }
            Iif (ej2_base_1.isNullOrUndefined(options)) {
                return;
            }
            var eventArgs = {
                cancel: false, name: index_2.markerClusterMouseMove, data: options.data, maps: this.maps,
                target: targetId, x: e.clientX, y: e.clientY
            };
            this.maps.trigger(index_2.markerClusterMouseMove, eventArgs);
        };
        Marker.prototype.allowInnerClusterSetting = function (layer) {
            var allowInnerClusterSetting = false;
            for (var markerIndex = 0; markerIndex < layer.markerSettings.length; markerIndex++) {
                if (layer.markerSettings[markerIndex].clusterSettings.allowClustering) {
                    allowInnerClusterSetting = true;
                    break;
                }
            }
            return allowInnerClusterSetting;
        };
        Marker.prototype.initializeMarkerClusterList = function () {
            for (var i = 0; i < this.maps.layers.length; i++) {
                this.initialMarkerCluster[i] = [];
                this.zoomedMarkerCluster[i] = [];
            }
        };
        Marker.prototype.getModuleName = function () {
            return 'Marker';
        };
        Marker.prototype.destroy = function () {
            this.maps = null;
            this.markerSVGObject = null;
            this.sameMarkerData = [];
            this.initialMarkerCluster = [];
            this.zoomedMarkerCluster = [];
        };
        return Marker;
    }());
    exports.Marker = Marker;
});