initAutomotive method

  1. @override
Future<bool?> initAutomotive({
  1. required String styleUrl,
  2. required String vietMapAPIKey,
})
override

Initialize the map with the given style URL and VietMap API key.

Implementation

@override
Future<bool?> initAutomotive(
    {required String styleUrl, required String vietMapAPIKey}) async {
  final initDataJson = <String, dynamic>{
    'styleUrl': styleUrl,
    'vietMapAPIKey': vietMapAPIKey,
  };
  if (Platform.isIOS) {
    final rootTemplate = CPMapTemplate(
      hidesButtonsWithNavigationBar: true,
      styleUrl: styleUrl,
      mapButtons: [
        CPMapButton(
          onClickEvent: OnClickEvents.showPanningInterface,
        ),
        CPMapButton(
          onClickEvent: OnClickEvents.recenterMapView,
        ),
        CPMapButton(
          onClickEvent: OnClickEvents.zoomInMapView,
        ),
        CPMapButton(
          onClickEvent: OnClickEvents.zoomOutMapView,
        ),
      ],
      trailingNavigationBarButtons: [
        CPBarButton(
          onClickEvent: OnClickEvents.dismissPanningInterface,
          title: 'Close',
        ),
      ],
    );
    initDataJson['rootTemplate'] = rootTemplate.toJson();
  }

  final responseMessage = await methodChannel.invokeMethod<bool>(
    Events.initAutomotive,
    initDataJson,
  );
  return responseMessage;
}