Skip to content

AdvancedMarker: custom content, anchoring, and attribute forwarding - #50

Merged
acorncom merged 1 commit into
mainfrom
advanced-marker-content-anchor
Sep 8, 2026
Merged

acorncom merged 1 commit into
mainfrom
advanced-marker-content-anchor

Conversation

@acorncom

@acorncom acorncom commented Sep 8, 2026

Copy link
Copy Markdown
Owner

What this adds

AdvancedMarker can now render your own content and place it where you want. Three additions, all optional:

  • Content from a <:content> block. Put your own markup inside the marker and it becomes the marker's content.
  • Forwarded ...attributes. class, modifiers, and other attributes on <AdvancedMarker> land on the content wrapper.
  • Anchor offsets. @anchorLeft and @anchorTop shift the content with a CSS translate — for example, to center a dot on the point.

A pre-built @content element still works. If you pass both a @content element and a <:content> block, the block wins.

Why

Until now an advanced marker showed either the default pin or a DOM element you built yourself. If you wanted to write marker content as a template, you had to build the element by hand or keep a local wrapper component. These additions let you write the content as a normal block, style it the usual way, and anchor it where you need.

How to use it

Content from a block:

<AdvancedMarker @lat={{51.5074}} @lng={{-0.1278}}>
  <:content>
    <div class="my-pin">📍</div>
  </:content>
</AdvancedMarker>

Attributes and anchoring (here, centering the content on the point):

<AdvancedMarker
  @lat={{51.5074}}
  @lng={{-0.1278}}
  @anchorLeft="-50%"
  @anchorTop="-50%"
  class="my-pin"
>
  <:content>
    <MyIcon />
  </:content>
</AdvancedMarker>

A pre-built element (unchanged):

<AdvancedMarker @lat={{51.5074}} @lng={{-0.1278}} @content={{this.iconElement}} />

Does this break anything?

No. Every change is additive. Existing <AdvancedMarker /> calls behave exactly as before: the content wrapper renders only when you pass a <:content> block, and the new arguments do nothing unless you set them.

Info windows

There is no nested marker yield. Attach an info window by pointing its @target at the marker:

<AdvancedMarker @lat={{51.5074}} @lng={{-0.1278}} as |m|>
  <InfoWindow @target={{m.mapComponent}} @isOpen={{true}} @content="Hello!" />
</AdvancedMarker>

The upgrade guide now spells this out for anyone moving off the old <marker.infoWindow> yield, which the deprecated bridge does not cover.

Tests

test-app-basic/tests/integration/components/advanced-marker-test.gjs covers block content, forwarded attributes, the anchor transform, a pre-built @content element, and an info window attached to an advanced marker via @target. The existing classic-Marker @target test covers the other marker type.

Docs

  • docs-app/advanced-markers.md — sections on content, anchoring, and info windows
  • docs-app/upgrading.md — a note that the per-marker <marker.infoWindow> yield is gone; use @target

🤖 Generated with Claude Code

…rding

AdvancedMarker can take its DOM content from a <:content> block, forward ...attributes to that content wrapper, and shift the content with @anchorLeft/@anchorTop. A pre-built @content element still works, and a <:content> block takes precedence over it. Existing <AdvancedMarker /> usage is unchanged. Info windows attach with @target (no nested yield).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@acorncom
acorncom force-pushed the advanced-marker-content-anchor branch from dece831 to 519ca44 Compare September 8, 2026 14:06
@acorncom acorncom added the enhancement New feature or enhancement label Sep 8, 2026
@acorncom
acorncom merged commit 83e1977 into main Sep 8, 2026
4 of 5 checks passed
@github-actions github-actions Bot mentioned this pull request Sep 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant