Options
To dictate & restrict what the map can and 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
By default, the map's north is up. Set the initialRotation in degrees to change this if necessary.
To set the geographical location the map should show, choose exactly one of the following options:
The map places the given coordinates at the centre (initialCenter), and shows the specified zoom level (initialZoom).
The four corners of the map are defined with 1 of 3 possible fitting methods, through initialCameraFit.
When the map is not initially rotated, all 3 work the same. When rotated, Circumscribed coordinates is usually the best choice.
A bounding box is specified, and the map shows the entire area plus any surrounding area necessary (if the map is rotated): CameraFit.bounds.
LatLngBounds can be constructed with two corners, or automatically constructed from a list of coordinates using the .fromPoints constructor.

A bounding box is specified, and the map shows only areas which fit inside it: CameraFit.insideBounds.
LatLngBounds can be constructed with two corners, or automatically constructed from a list of coordinates using the .fromPoints constructor.

A list of coordinates is specified, and the map shows the entire area plus any surrounding area necessary (if the map is rotated): CameraFit.coordinates.
Because it is not a bounding box (north-aligned rectangle) being specified unlike the other 2 methods, a rotated map can achieve a tighter fit around the specified coordinates.
CameraFit also takes a number of other useful parameters, such as padding defined in screen-space logical pixels, and more to ensure the map tiles are at their best visual resolution initially. For example:
But how to actually choose the initial position for the map? We've built a guide to help with that:
Generating An Initial PositionPermanent Rules
One part of MapOptions responsibilities is to define the restrictions and limitations of the map and what users can/cannot do with it.
Some of the options are described elsewhere in this documentation, in context. In addition, the API docs show all the available options, and below is a partial list of options:
cameraConstraintcamera bounds inside bounds:
CameraConstraint.boundscamera center inside bounds:
CameraConstraint.centercamera bounds not exceeding specified parallels:
CameraConstraint.containLatitude(defaults to 90th parallel north and south)unconstrained (default):
CameraConstraint.unconstrained
maxZoomandminZoomSets a hard limit on the maximum and minimum amounts that the map can be zoomedinteractionOptionsConfigures the gestures that the user can use to interact with the map - for example, disable rotation or configure cursor/keyboard rotation
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.
Custom CRS
FM does have some support for using alternative CRSs.
Custom CRSsKeep Alive
If the map is built lazily, for example in a PageView, loading and unloading the map will cause it to reset.
To prevent this, set MapOptions.keepAlive to true, which will activate an internal AutomaticKeepAliveClientMixin.
Last updated
Was this helpful?