Skip to content

Conversation

@github-actions
Copy link
Contributor

@github-actions github-actions bot commented Dec 5, 2025

RD-1447

Objective

Add anchor and offset properties to MTMarker. Target: anchor and offset of marker is present in the class Constraints: anchor is MTAnchor and offset is double. * Task: anchor and offset properties to MTMarker.* Acceptance: toJS matches signature; linter MUST pass; build MUST pass; tests MUST pass;* Unit test is written to cover this new implementation **.

Description

Add Anchor and Offset properties to MTMarker class - Swift SDK.

Acceptance

Linted.

@sasaprodribaba
Copy link
Collaborator

@claude Review this PR and check if serialization is properly done.

@claude
Copy link

claude bot commented Dec 5, 2025

Claude finished @sasaprodribaba's task —— View job


Code Review Progress

Reviewing PR RD-1447 with focus on serialization implementation:

  • Read repository guidelines (CLAUDE.md) - No specific guidelines found
  • Review MTAnchor.swift implementation
  • Review MTMarker.swift changes (anchor and offset properties)
  • Check serialization logic in AddMarker.swift
  • Review AddMarkers.swift changes
  • Analyze test coverage in MTMarkerTests.swift
  • Provide comprehensive review feedback on serialization

Code Review Summary ✅

I've completed a thorough review of the PR focusing on serialization implementation. Overall, the implementation looks solid and well-implemented. Here are my findings:

✅ Strengths

1. MTAnchor Implementation (Sources/MapTilerSDK/Annotations/MTAnchor.swift)

  • Clean enum with proper String raw values for serialization
  • All anchor positions map correctly to CSS anchor values
  • Implements Sendable and Codable protocols appropriately

2. MTMarker Property Integration (Sources/MapTilerSDK/Annotations/MTMarker.swift)

  • Properties added with sensible defaults: anchor: MTAnchor = .center, offset: Double = 0.0
  • All initializers updated consistently to include both properties
  • DSL builder pattern properly includes new properties in addToMap()

3. Serialization ImplementationKey Focus Area

  • AddMarker.swift:24-25: Proper serialization of both properties:
    "anchor: '\(marker.anchor.rawValue)'",
    "offset: [\(marker.offset), \(marker.offset)]"
  • AddMarkers.swift:50-51, 86-87: Consistent serialization across both bulk operations
  • JavaScript output format matches MapTiler SDK requirements with correct syntax

4. Test Coverage (Tests/MapTilerSDKTests/MTMarkerTests.swift)

  • Comprehensive test suite covering all serialization scenarios:
    • Single marker serialization
    • Bulk markers with shared icon
    • Bulk markers with individual icons
  • Tests verify actual JavaScript output contains correct anchor and offset values

🔍 Technical Analysis

Serialization Format Validation:

  • Anchor serializes as: anchor: 'bottom-left'
  • Offset serializes as: offset: [8.0, 8.0] ✅ (applied to both X and Y axes)
  • Matches MapTiler SDK JavaScript API expectations

Type Safety:

  • MTAnchor enum prevents invalid anchor values
  • Double offset provides precise pixel positioning
  • No force unwrapping or unsafe operations in serialization code

📝 Minor Observations

  1. Offset Design: The current implementation applies the same offset value to both X and Y axes. This is consistent with the requirements but limits flexibility for asymmetric offsets.

  2. Default Values: Using .center anchor and 0.0 offset as defaults is appropriate for most use cases.

  3. Backward Compatibility: All existing initializers remain functional, maintaining API compatibility.

✅ Acceptance Criteria Met

  • ✅ Anchor property is MTAnchor type
  • ✅ Offset property is Double type
  • toJS() method includes both properties with correct signatures
  • ✅ Comprehensive unit tests cover the implementation
  • ✅ Code follows existing patterns and conventions

Verdict: APPROVED

The serialization implementation is correctly done and meets all requirements. The JavaScript output properly includes both anchor and offset properties in the expected format for the MapTiler SDK.


@sasaprodribaba sasaprodribaba merged commit 5cb15ac into main Dec 5, 2025
3 of 7 checks passed
@sasaprodribaba sasaprodribaba deleted the RD-1447 branch December 5, 2025 12:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants