function AddMarkersByAjax(map, json) { var markerOverlays = eval('(' + json + ')'); if (markerOverlays && markerOverlays.length != 0) { for (var i = 0; i < markerOverlays.length; i++) { var layer = map.getLayer(markerOverlays[i].id); if (layer) { RemoveMarkerPopups(layer); var markersCount = layer.markers.length; for (var j = 0; j < markersCount; j++) { var removeMarker = layer.markers[0]; layer.removeMarker(removeMarker); removeMarker.destroy(); } var hasCtx = false; var rootPath = layer.rootPath; if (markerOverlays[i].markers && markerOverlays[i].markers.length != 0) { for (var j = 0; j < markerOverlays[i].markers.length; j++) { var markerJson = markerOverlays[i].markers[j]; var markerCreator = new Marker(markerJson, rootPath); markerCreator.overlayId = layer.id; markerCreator.mapUid = map.uniqueId; markerCreator.mapCid = map.clientId; markerCreator.currentZoom = map.getZoom(); if (markerJson.contextMenu && markerJson.contextMenu != 'undefined' && markerJson.contextMenu.items.length != 0) { markerCreator.setContextMenu(markerJson); hasCtx = true; } var marker = markerCreator.element; if (markerJson.popup && markerJson.popup != 'undefined' && markerJson.popup.html && markerJson.popup.html != '') { marker.popupJson = markerJson.popup; marker.popupDelay = markerJson.popupdelay; marker.initializePopup(map); marker.events.register('mouseover', marker, function(evt) { this.showPopup(); }); marker.events.register('mouseout', marker, function(evt) { this.hidePopup(); }); } marker = GetHookedClickEventMarker(marker, layer); layer.addMarker(marker); if (hasCtx) { layer.div.oncontextmenu = function() { return false; }; } else { layer.div.oncontextmenu = null; } } } } } } }