Skip to content

feat: add <ScriptGoogleMapsOverlayView> component#658

Closed
harlan-zw wants to merge 2 commits intomainfrom
feat/overlay-view-component
Closed

feat: add <ScriptGoogleMapsOverlayView> component#658
harlan-zw wants to merge 2 commits intomainfrom
feat/overlay-view-component

Conversation

@harlan-zw
Copy link
Collaborator

🔗 Linked issue

Closes #657

❓ Type of change

  • 📖 Documentation
  • 🐞 Bug fix
  • 👌 Enhancement
  • ✨ New feature
  • 🧹 Chore
  • ⚠️ Breaking change

📚 Description

InfoWindow forces a predefined HTML structure and styling. This adds <ScriptGoogleMapsOverlayView>, which renders arbitrary Vue slot content at a map lat/lng position with full styling control.

Features:

  • Anchor-based positioning: anchor prop controls alignment (e.g. bottom-center, center) via CSS transforms, no layout measurement needed
  • Map interaction blocking: blockMapInteraction (default true) prevents clicks/drags from propagating to the map
  • No flash: content starts hidden, revealed after first draw() positions it
  • Reactive: repositions on prop changes, Vue slot reactivity preserved via hidden-container + appendChild pattern (same as InfoWindow)
  • Configurable pane, zIndex, and pixel offset
  • Playground demo and docs added

Renders arbitrary Vue slot content at a map lat/lng position with full
styling control, solving the limitation of InfoWindow's predefined HTML
structure. Includes anchor-based positioning, map interaction blocking,
and flash prevention.

Closes #657
@vercel
Copy link
Contributor

vercel bot commented Mar 19, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
scripts-playground Ready Ready Preview, Comment Mar 19, 2026 3:45pm

@coderabbitai
Copy link

coderabbitai bot commented Mar 19, 2026

📝 Walkthrough

Walkthrough

This pull request introduces ScriptGoogleMapsOverlayView, a new Vue component for rendering custom content on Google Maps using the native OverlayView API. The change includes the component implementation with props for positioning, anchoring, offsets, pane selection, z-index, and map interaction blocking. Documentation was added describing the component, its props, and usage examples. A playground example demonstrates the component with a toggle control. A test snapshot was updated to reflect bundled asset changes.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

The change introduces heterogeneous modifications across documentation, implementation, and examples. The component implementation contains non-trivial logic for OverlayView abstraction, lat/lng-to-pixel coordinate conversion, anchor-based CSS transforms, prop watching, and overlay remounting. These require careful verification of correctness, prop handling, and edge cases. Documentation completeness and playground example clarity also need assessment.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: adding a new Vue component <ScriptGoogleMapsOverlayView>. It is concise, clear, and follows conventional commits format.
Description check ✅ Passed The description includes linked issue reference, appropriate type selection, and detailed feature list explaining the component's functionality and design decisions.
Linked Issues check ✅ Passed The PR successfully implements the custom overlay component requested in issue #657, providing arbitrary Vue content rendering at map coordinates with full styling control and interaction management.
Out of Scope Changes check ✅ Passed All changes are directly related to the new component feature: the main component implementation, playground demo, documentation, and a test snapshot update for bundled assets.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

Important

Merge conflicts detected (Beta)

  • Resolve merge conflict in branch feat/overlay-view-component
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/overlay-view-component
📝 Coding Plan
  • Generate coding plan for human review comments

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
src/runtime/components/GoogleMaps/ScriptGoogleMapsOverlayView.vue (1)

99-117: Consider extracting the remount logic.

The remount pattern is duplicated for pane and blockMapInteraction watchers. This is a minor readability nit.

♻️ Optional: extract remount helper
+function remountOverlay() {
+  if (overlay.value) {
+    const map = overlay.value.getMap()
+    overlay.value.setMap(null)
+    if (map)
+      overlay.value.setMap(map as google.maps.Map)
+  }
+}
+
 // Pane change requires remount (setMap cycles onRemove + onAdd + draw)
-watch(() => props.pane, () => {
-  if (overlay.value) {
-    const map = overlay.value.getMap()
-    overlay.value.setMap(null)
-    if (map)
-      overlay.value.setMap(map as google.maps.Map)
-  }
-})
+watch(() => props.pane, remountOverlay)
 
 // blockMapInteraction change requires remount to re-apply preventMapHitsAndGesturesFrom
-watch(() => props.blockMapInteraction, () => {
-  if (overlay.value) {
-    const map = overlay.value.getMap()
-    overlay.value.setMap(null)
-    if (map)
-      overlay.value.setMap(map as google.maps.Map)
-  }
-})
+watch(() => props.blockMapInteraction, remountOverlay)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/runtime/components/GoogleMaps/ScriptGoogleMapsOverlayView.vue` around
lines 99 - 117, Duplicate remount logic exists in the two watchers for
props.pane and props.blockMapInteraction; extract that into a single helper
function (e.g., remountOverlay or doRemount) that checks overlay.value, saves
const map = overlay.value.getMap(), calls overlay.value.setMap(null), then if
map re-attaches with overlay.value.setMap(map as google.maps.Map); replace both
watcher bodies to call this helper to remove duplication and improve readability
while keeping existing behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@src/runtime/components/GoogleMaps/ScriptGoogleMapsOverlayView.vue`:
- Around line 99-117: Duplicate remount logic exists in the two watchers for
props.pane and props.blockMapInteraction; extract that into a single helper
function (e.g., remountOverlay or doRemount) that checks overlay.value, saves
const map = overlay.value.getMap(), calls overlay.value.setMap(null), then if
map re-attaches with overlay.value.setMap(map as google.maps.Map); replace both
watcher bodies to call this helper to remove duplication and improve readability
while keeping existing behavior.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 97d42e34-5104-4f43-98bc-983c6bb22912

📥 Commits

Reviewing files that changed from the base of the PR and between fb54985 and 55e75bf.

📒 Files selected for processing (4)
  • docs/content/scripts/google-maps.md
  • playground/pages/third-parties/google-maps/sfcs.vue
  • src/runtime/components/GoogleMaps/ScriptGoogleMapsOverlayView.vue
  • test/e2e/base.test.ts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

<ScriptGoogleMapsOverlayView> component

1 participant