flutter_mapbox_navigation icon indicating copy to clipboard operation
flutter_mapbox_navigation copied to clipboard

How to add raster tiles to mapbox navigation ?

Open manhlh opened this issue 3 years ago • 0 comments

I had try with mapStyleUrlDay and mapStyleUrlNight but not work.

`getApplicationDocumentsDirectory().then((dir) async { String documentDir = dir.path; String stylesDir = '$documentDir/styles'; var mapStyle = { 'version': 8, 'sources': { 'raster-tiles': { 'type': 'raster', 'tiles': [ 'https://DOMAIN/tm6/{z}/{x}/{y}@2x.png?apikey=API_KEY' ], 'tileSize': 256 } }, 'layers': [ { 'id': 'simple-tiles', 'type': 'raster', 'source': 'raster-tiles', 'minzoom': 0, 'maxzoom': 18 } ] };

  await new Directory(stylesDir).create(recursive: true);

  File styleFile = new File('$stylesDir/style.json');

  await styleFile.writeAsString(jsonEncode(mapStyle));
  print("String style path: ${styleFile.path}");
  setState(() {
    styleAbsoluteFilePath = styleFile.path;
  });
});

_options = MapBoxOptions( //initialLatitude: 36.1175275, //initialLongitude: -115.1839524, zoom: 15.0, tilt: 0.0, bearing: 0.0, enableRefresh: false, alternatives: true, voiceInstructionsEnabled: true, bannerInstructionsEnabled: true, allowsUTurnAtWayPoints: true, mode: MapBoxNavigationMode.drivingWithTraffic, units: VoiceUnits.imperial, simulateRoute: false, animateBuildRoute: true, longPressDestinationEnabled: true, language: "vi", mapStyleUrlDay: styleAbsoluteFilePath, mapStyleUrlNight: styleAbsoluteFilePath,

);

`

manhlh avatar Apr 14 '21 09:04 manhlh