Options
To dictate what the map can/should do, regardless of its contents, it needs some guidance!
It provides options that can be categorized into three main parts:
Initial positioning Defines the location of the map when it is first loaded
Permanent rules Defines restrictions that last throughout the map's lifetime
Event handling Defines methods that are called on specific map events
Initial Positioning
One part of MapOptions responsibilities is to define how the map should be positioned when first loaded. There's two ways to do this (that are incompatible):
center&zoomDefines the center coordinates of the map and a zoom levelboundsDefines an area with two/four coordinates that the viewport should fit to
It is possible to also set the map's rotation in degrees, if you don't want it North (0°) facing initially.
Permanent Rules
One part of MapOptions responsibilities is to define the restrictions and limitations of the map and what users can/cannot do with it.
You should check all the available options, but these are recommended for most maps:
maxZoom(andminZoom) Limits how far the map can be zoomed by the user, to avoid showing empty tilesmaxBoundsLimits how far the map can be moved by the user to a coordinate-based boundaryinteractiveFlags- seeInteractiveFlagfor available options Limits what methods the user can interact with the map through (for example, preventing rotation)keepAliveIfFlutterMapis located inside aPageView,ListViewor another complex lazy layout, set thistrueto prevent the map from resetting to the Initial Positioning on rebuild
Instead of maxZoom (or in addition to), consider setting maxNativeZoom per TileLayer instead, to allow tiles to scale (and lose quality) on the final zoom level, instead of setting a hard limit.
Event Handling
Event HandlingLast updated
Was this helpful?