diff --git a/js/models/message_handler.js b/js/models/message_handler.js index dc38e4b9..74f29f6b 100644 --- a/js/models/message_handler.js +++ b/js/models/message_handler.js @@ -32,36 +32,25 @@ export default class MessageHandler { handleAddOverlay(msg) { const infos = msg["infos"]; const options = convertOptionNamesToCamelCase(msg["options"] || {}); - // Define default color for graphic overlay - const overlay_color = options["color"] || options["fillColor"] || "red"; - const overlay = A.graphicOverlay({ color: overlay_color }); + const overlay = A.graphicOverlay(options); this.aladin.addOverlay(overlay); switch (msg["region_type"]) { case "stcs": - overlay.add(A.footprintsFromSTCS(infos.stcs, options)); + overlay.addFootprints(A.footprintsFromSTCS(infos.stcs)); break; case "circle": - overlay.add(A.circle(infos.ra, infos.dec, infos.radius, options)); + overlay.add(A.circle(infos.ra, infos.dec, infos.radius)); break; case "ellipse": overlay.add( - A.ellipse( - infos.ra, - infos.dec, - infos.a, - infos.b, - infos.theta, - options, - ), + A.ellipse(infos.ra, infos.dec, infos.a, infos.b, infos.theta), ); break; case "line": - overlay.add( - A.line(infos.ra1, infos.dec1, infos.ra2, infos.dec2, options), - ); + overlay.add(A.line(infos.ra1, infos.dec1, infos.ra2, infos.dec2)); break; case "polygon": - overlay.add(A.polygon(infos.vertices, options)); + overlay.add(A.polygon(infos.vertices)); break; } } diff --git a/src/ipyaladin/aladin.py b/src/ipyaladin/aladin.py index dbfb73f3..c380287f 100644 --- a/src/ipyaladin/aladin.py +++ b/src/ipyaladin/aladin.py @@ -395,20 +395,14 @@ def add_overlay( # Visual mapping to Aladin Lite overlay options if isinstance(region, Region): - # Check if overlay options are empty - if overlay_options and region.visual: - warnings.warn( - "region visuals will be used instead of provided overlay_options", - stacklevel=2, - ) - if region.visual: - overlay_options = dict(region.visual) - if "linewidth" in overlay_options: - overlay_options["line_width"] = overlay_options.pop("linewidth") - if "color" in overlay_options: - overlay_options["fill_color"] = overlay_options.pop("color") - if "edgecolor" in overlay_options: - overlay_options["color"] = overlay_options.pop("edgecolor") + visual = dict(region.visual) + if "linewidth" in visual: + visual["line_width"] = visual.pop("linewidth") + if "facecolor" in visual: + visual["fill_color"] = visual.pop("facecolor") + if "edgecolor" in visual: + visual["color"] = visual.pop("edgecolor") + overlay_options = {**overlay_options, **region.visual} # Define behavior for each region type region_infos = RegionInfos(region)