0

I'm using the explore Edition of here SDK to to truck location updates. I want that the map rotate and the indicator to move with my physical location changes. Unfortunately the indication is always in my current location. This is my code :

CameraExample(HereMapController hereMapController)
   : _hereMapController = hereMapController {
 _initializeMap();
}

Future<void> _initializeMap() async {
 // Get current position
 final position = await Geolocator.getCurrentPosition();
 GeoCoordinates currentLocation =
     GeoCoordinates(position.latitude, position.longitude);

 // Look at current position with tilt and bearing
 var bearingInDegrees = 0.0;
 var tiltInDegrees = 45.0;
 var orientation = GeoOrientationUpdate(bearingInDegrees, tiltInDegrees);
 var distanceToEarthInMeters = 1000 * 10.0; // Set to 10 kilometers.
 MapMeasure mapMeasureZoom =
     MapMeasure(MapMeasureKind.distance, distanceToEarthInMeters);
 _hereMapController.camera
     .lookAtPointWithMeasure(currentLocation, mapMeasureZoom);
 _hereMapController.camera.lookAtPointWithGeoOrientationAndMeasure(
     currentLocation, orientation, mapMeasureZoom);

 // Add location indicator
 _addLocationIndicator(
     currentLocation, LocationIndicatorIndicatorStyle.navigation);

 GeoCoordinates targetLocation = GeoCoordinates(
     currentLocation.latitude + 0.1, currentLocation.longitude + 0.1);
 GeoCoordinatesUpdate geoCoordinatesUpdate =
     GeoCoordinatesUpdate.fromGeoCoordinates(targetLocation);
 double bowFactor = 1.0;
 MapCameraAnimation animation = MapCameraAnimationFactory.flyTo(
     geoCoordinatesUpdate, bowFactor, const Duration(seconds: 3));
 _hereMapController.camera.startAnimation(animation);
}

void _addLocationIndicator(GeoCoordinates geoCoordinates,
   LocationIndicatorIndicatorStyle indicatorStyle) {
 LocationIndicator locationIndicator = LocationIndicator();

 locationIndicator.locationIndicatorStyle = indicatorStyle;


 // For testing purposes, we create a Location object. Usually, you may want to get this from
 // a GPS sensor instead.
 Location location = Location.withCoordinates(geoCoordinates);
 location.time = DateTime.now();
 location.bearingInDegrees = 0.0;

 locationIndicator.updateLocation(location);
.
 _hereMapController.addLifecycleListener(locationIndicator);
}
}

ASMA
  • 59
  • 1
  • 5

0 Answers0