init method
Starts the JS Maps SDK into the target _div with rawOptions.
(Also initializes the geometry/traffic layers.)
The first part of this method starts the rendering of a gmaps.Map inside
of the target _div, with configuration from rawOptions. It then stores
the created GMap in the _googleMap attribute.
Not everything is rendered with the initial rawOptions configuration,
geometry and traffic layers (and possibly others in the future) have their
own configuration and are rendered on top of a GMap instance later. This
happens in the second half of this method.
This method is eagerly called from the
GoogleMapsPlugin.buildViewWithConfiguration method so the internal
GoogleMapsController of a Web Map initializes as soon as possible.
Check _attachMapEvents to see how this controller notifies the
plugin of it being fully ready (through the onTilesloaded.first event).
Failure to call this method would result in the GMap not rendering at all, and most of the public methods on this class no-op'ing.
Implementation
void init() {
gmaps.MapOptions options = _configurationAndStyleToGmapsOptions(
_lastMapConfiguration,
_lastStyles,
);
// Initial position can only to be set here!
options = _applyInitialPosition(_initialCameraPosition, options);
// Fully disable 45 degree imagery if desired
if (options.rotateControl == false) {
options.tilt = 0;
}
// Create the map...
final gmaps.Map map = _createMap(_div, options);
_googleMap = map;
_attachMapEvents(map);
_attachGeometryControllers(map);
_initClustering(_clusterManagers);
// Now attach the geometry, traffic and any other layers...
_renderInitialGeometry();
_setTrafficLayer(map, _lastMapConfiguration.trafficEnabled ?? false);
}