Skip to content

feat: Auto-fit map to all pins & show user's current location#104

Open
devin-ai-integration[bot] wants to merge 1 commit into
developfrom
devin/1782177662-map-autofit-user-location
Open

feat: Auto-fit map to all pins & show user's current location#104
devin-ai-integration[bot] wants to merge 1 commit into
developfrom
devin/1782177662-map-autofit-user-location

Conversation

@devin-ai-integration

Copy link
Copy Markdown
Contributor

Summary

Two improvements to the inline map embed rendered by show_places_on_map:

1. Auto-fit with proper padding — The previous showAnnotations call fired before constraints were activated, so the map often had zero frame and couldn't compute a correct region. Now:

  • Region computation is deferred to the next run-loop pass (after Auto Layout resolves).
  • A manual bounding-box calculation replaces showAnnotations: computes min/max lat/lon across all pins, enforces a minimum span (~500 m) so a single pin doesn't zoom to street-level, then applies setRegion + setVisibleMapRect(edgePadding: 30pt) so markers aren't clipped by the rounded corners.

2. User location blue dotmapView.showsUserLocation = true is set when rendering the map. On iOS the didUpdate userLocation delegate re-fits the region once (one-shot via didFitUserLocation flag) to include both all pins and the user's position. The existing viewFor annotation: guard (guard annotation is MapPlaceAnnotation else { return nil }) ensures the user location renders as the standard blue pulsing dot.

Both iOS (MessagingCell) and macOS (MapBubbleView) receive the same treatment.

Link to Devin session: https://app.devin.ai/sessions/644363360037438eafa49e39e472287e

- Replace bare showAnnotations with manual region computation that
  handles edge cases (single pin, tight clusters, wide spreads) and
  applies 30pt edge insets so pins aren't clipped by rounded corners.
- Defer the fit to the next run-loop pass so the map has valid frame
  geometry from activated constraints before computing the region.
- Enable showsUserLocation to display the blue dot on the map.
- On iOS, re-fit the map once user location becomes available so the
  viewport includes both all pins and the user's position.
- Apply matching improvements to the macOS MapBubbleView.

Co-Authored-By: bot_apk <apk@cognition.ai>
@devin-ai-integration

Copy link
Copy Markdown
Contributor Author
Original prompt from API User

#``# Task: Improve map embed — auto-fit all pins & show user location

The Loop iOS app has an inline map embed feature rendered by the show_places_on_map tool. This tool takes an array of places (each with name, latitude, longitude, optional address) and renders them as pins on a map embed in the chat.

#``#``# Two improvements needed:

1. Auto-zoom / auto-fit to show all pins
Currently when a map is rendered with multiple pins, the viewport does not automatically adjust to fit all the pins in view. The map should auto-zoom and auto-center so that ALL pins are visible within the viewport with appropriate padding/margin. Use standard MapKit showAnnotations or equivalent region-fitting logic.

2. Show the user's current location on the map
In addition to the user-provided place pins, the map should also display the user's current device location (as a blue dot or a distinct "You are here" pin). This requires requesting/using Core Location to get the user's coordinates and adding them as an annotation or enabling showsUserLocation on the map view.

#``#``# Context:

  • The source code is in the GitHub repo theashbhat/LoopHarness.
  • Look for the map embed / map rendering code — likely in a view or component that handles the show_places_on_map tool result.
  • The map is rendered inline in chat as an embed/card.
  • This is a SwiftUI/UIKit iOS app (likely SwiftUI with MapKit or a WKWebView-based map).
  • Ensure the auto-fit logic handles edge cases: single pin, pins very close together, pins spread across a large area.

#``#``# Requirements:

  • Implement both improvements.
  • Open a pull request against the main branch.
  • Add ashbhat as a reviewer on the PR.
  • Keep the PR focused on these two changes only.

@devin-ai-integration

Copy link
Copy Markdown
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

@vercel

vercel Bot commented Jun 23, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
loop-harness Ready Ready Preview, Comment Jun 23, 2026 1:23am

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.

0 participants