Skip to content

SDKs · Flutter

Step 7 — 3D buildings & trees

Extruded buildings, trees, colors and on/off switches.

Buildings and trees
final options = UbHubMapOptions(
  apiKey: apiKey,
  buildings: UbHubBuildings.detailed, // none, flat (default), extruded or detailed
  trees: UbHubTrees.extruded,         // none (default), points or extruded
  initialZoom: 16,
  initialTilt: 55,                    // 0-60
);

UbHubMap(
  options: options,
  height: 480,
  tiltGesturesEnabled: true,
  buildingStyle: const UbHubBuildingStyle(
    color: Color(0xFF1D4ED8),
    heightScale: 1.5, // 0-10
  ),
  treeStyle: const UbHubTreeStyle(color: Color(0xFF22C55E)),
  showBuildings: showBuildings, // toggles live, no new map load
  showTrees: showTrees,
);
SettingChanging it
buildings, treesNew UbHubMapOptions: loads a new style (one map load)
buildingStyle, treeStyleRestyles the layer in place
showBuildings, showTreesHides or shows the layer in place
  • Omitted style values keep the basemap's building colors. A color's alpha is ignored; use opacity.
  • UbHubBuildings.none leaves the buildings and their tiles out; a hidden layer loads no new tiles. On Nova, none keeps Nova's own flat buildings.
  • UbHubBuildings.detailed draws the detailed 3D buildings as parts (wings, towers, roof steps), each raised to its own height, and UbHubTrees.extruded draws trees as a trunk and a crown, natively on Android and iOS. Sloped roofs become steps; the website's exact meshes need a 3D Tiles renderer (React & Next.js SDK).

Upgrade to 0.8.1

Version 0.6.0 cannot load the current standard basemap, 0.7.0 fails when a building or tree style changes, and 0.8.0 can crash an Android app that is closed with the back button. Run flutter pub upgrade ubhub_maps.