0

I'm using HERE Maps SDK for Flutter, version 4.6.4 Explore edition.

My Problem

I'm trying to add a tap listener to the map. I'm following the official documentation

void _setTapGestureHandler() {
  _hereMapController.gestures.tapListener = TapListener((Point2D touchPoint) {
    var geoCoordinates = _toString(_hereMapController.viewToGeoCoordinates(touchPoint));
    print('Tap at: $geoCoordinates');
  });
}

And this is what I am getting

Error: The class 'TapListener' is abstract and can't be instantiated. _hereMapController.gestures.tapListener = TapListener((Point2D touchPoint) { ^^^^^^^^^^^

It could be that there is a fix in the next versions, but I need a solution for this version of SDK.

Gicu Mironica
  • 585
  • 8
  • 22
  • 1
    Indeed, as you expected it, the "fromLambda" constructor was removed from all related Dart classes with version 4.7.7.0 from the HERE SDK, so for previous versions you need to check the previous documentation. – Nusatad Nov 01 '21 at 08:49

2 Answers2

1

The shown code in your question is correct for HERE SDK versions greater or equal to 4.7.7.0. In the release notes the removal of the Lambda notation was announced.

The "fromLambda" constructor was removed from all Dart classes where it was used, for example Gestures, MapDownloader, SearchEngine and so on. Instead of creating a gesture listener like this: tapListener = TapListener.fromLambdas(lambda_onTap: (Point2D p) { ... }); the code can be simplified now to: tapListener = TapListener((Point2D p) { ... });.

When browsing the HERE SDK documentation, please check the version drop down list: enter image description here

The link from your post goes to a newer version.

Secondly, when looking for example apps, pick the ones that are made for the desired version, go to GitHub and select the Tag:

enter image description here

Nusatad
  • 3,231
  • 3
  • 11
  • 17
0

For those having the same issue, found the solution. Looks like HERE removed it from documentations or smth.

This is the way to do it.

_hereMapController.gestures.tapListener = TapListener.fromLambdas(
        lambda_onTap: (Point2D touchPoint) => _yourFunction(touchPoint));
Gicu Mironica
  • 585
  • 8
  • 22