skip to Main Content

I got a problem on showing maps on Android with Flutter here_sdk/Here Maps SDK. I’m running basic hello_map_app and already fill the credentials (access key id and access key secret) then failed to show the map when running to Android. But if I build and run for iOS, it can shows the map. Is there something that i missed?

Android

iOS

the code that I used

here-sdk-exampes/hello_map_app

/*
 * Copyright (C) 2019-2023 HERE Europe B.V.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * SPDX-License-Identifier: Apache-2.0
 * License-Filename: LICENSE
 */

import 'package:flutter/material.dart';
import 'package:here_sdk/core.dart';
import 'package:here_sdk/core.engine.dart';
import 'package:here_sdk/core.errors.dart';
import 'package:here_sdk/mapview.dart';

void main() async {
  // Usually, you need to initialize the HERE SDK only once during the lifetime of an application.
  _initializeHERESDK();

  runApp(MyApp());
}

void _initializeHERESDK() async {
  // Needs to be called before accessing SDKOptions to load necessary libraries.
  SdkContext.init(IsolateOrigin.main);

  // Set your credentials for the HERE SDK.
  String accessKeyId = "####"; // censored
  String accessKeySecret = "####"; // censored
  SDKOptions sdkOptions = SDKOptions.withAccessKeySecret(accessKeyId, accessKeySecret);

  try {
    await SDKNativeEngine.makeSharedInstance(sdkOptions);
  } on InstantiationException {
    throw Exception("Failed to initialize the HERE SDK.");
  }
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'HERE SDK for Flutter - Hello Map!',
      home: HereMap(onMapCreated: _onMapCreated),
    );
  }

  void _onMapCreated(HereMapController hereMapController) {
    hereMapController.mapScene.loadSceneForMapScheme(MapScheme.normalDay, (MapError? error) {
      if (error != null) {
        print('Map scene not loaded. MapError: ${error.toString()}');
        return;
      }

      const double distanceToEarthInMeters = 8000;
      MapMeasure mapMeasureZoom = MapMeasure(MapMeasureKind.distance, distanceToEarthInMeters);
      hereMapController.camera.lookAtPointWithMeasure(GeoCoordinates(52.530932, 13.384915), mapMeasureZoom);
    });
  }
}

I already fill the credentials both on main.dart, AndroidManifest.xml, and Info.plist, but still got the same result.

2

Answers


  1. Chosen as BEST ANSWER

    I solved the issue by changing by changing emulator OpenGL ES API level to Renderer maximum (up to OpenGL ES 3.1) thanks to this thread I setup up the hellomap example and am getting the following errors


  2. Make sure you are meeting the minimum requirements as listed here.

    In case you are unsure, run flutter doctor -v from command line and make sure your Flutter and Dart versions meet the requirements.

    Also, make sure your device is supported. This can be found under the same link above.

    Lastly, it can help to take a look into the logs.

    The example app code is a good way to test if your setup works. Try to run it as described in the quick start guide. Make sure to execute the code with the HERE SDK version it was built for.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search