Conversation
WalkthroughThe logic for setting the map's zoom and center after fitting bounds has been reordered. Now, the map sets the zoom level first if provided, then pans to the center if specified. A new variable Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant Map
participant Data
User->>Map: Provide (center, zoom, geojson, maxNativeZoom, maxZoom)
Map->>Map: Calculate maxNativeZoom = min(provided maxNativeZoom or maxZoom, maxZoom)
Map->>Map: Configure tile layer with maxNativeZoom
Map->>Map: If zoom provided, set zoom
Map->>Map: Else if no zoom, check geojson
alt geojson absent
Map->>Map: Set zoom to maxZoom
end
Map->>Map: If center provided, pan to center
alt center not provided
Map->>Map: If geojson absent, pan to initial point
end
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (2)
src/template.html (2)
126-133: Add missing semicolon & verify Handlebars truthiness in zoom block.The default zoom fallback on line 131 is missing a terminating semicolon, which breaks consistency with the surrounding statements:
- map.setZoom(maxZoom, {animate: false}) + map.setZoom(maxZoom, {animate: false});Also, confirm that the Handlebars
#if zoomand#if geojsonchecks behave as expected for all numeric zoom levels (e.g.,0vs.undefined).
135-142: Parse center coordinates as numbers before panning.Currently the template passes raw substring values (strings) into
L.latLng, which may lead to unexpected type coercion. Consider converting to numbers (and trimming whitespace) for robustness:- map.panTo(L.latLng('{{ center }}'.split(',')[1], '{{ center }}'.split(',')[0]), {animate: false}); + // split "lng,lat" into numeric [lng, lat] + const [lng, lat] = '{{ center }}'.split(',').map(s => parseFloat(s.trim())); + map.panTo(L.latLng(lat, lng), {animate: false});
When using geojson, first the map is panned to the provided center, and then it's zoomed in to the desired level.
Because of rounding errors, the center will be off.
By changing the order of operations (first zoom, then pan), the issue is fixed.
Summary by CodeRabbit