My app is loading a HERE map, and works fine with a set of manually entered coordinates as the centre point.
I have implemented Geolocator
in another part of the app to produce the users location which is then implemented into a function to find places near their current location & display on map.
I have now taken the Geolocator
position finder and want to use it to open the map on the users location. The code uses async
and await
to get users coordinates.
The map open function does not want to accept async/ await
, yet I have tried building it within its own class and pulling the coords, without success.
I am relatively new and any advice is greatly appreciated
Async
& Await
are currently red underlined in the 'function to open map', and when I change MapMarkerExample
to mapMarkerExample
at the top of 'function to open map', _mapMarkerExample = MapMarkerExample (_showDialog, hereMapController);
is red underlined on `command to open map'
Command to open map
void _onMapCreated(HereMapController hereMapController) {
hereMapController.mapScene.loadSceneForMapScheme(MapScheme.normalDay, (MapError error) {
if (error == null) {
_mapMarkerExample = MapMarkerExample (_showDialog, hereMapController);
} else {
print("Map scene not loaded. MapError: " + error.toString());
}
});
}
Function to open map
MapMarkerExample(ShowDialogFunction showDialogCallback, HereMapController hereMapController) async {
_showDialog = showDialogCallback;
_hereMapController = hereMapController;
Position position = await Geolocator.getCurrentPosition(desiredAccuracy: LocationAccuracy.high);
var lat = position.latitude;
var long = position.longitude;
double distanceToEarthInMeters = 8000;
_hereMapController.camera.lookAtPointWithDistance(
GeoCoordinates(lat, long), distanceToEarthInMeters);
_setTapGestureHandler();
_showDialog("Note", "Tap markers for more.");
}