View on GitHub

Convert features into graphics to show them with mil2525d symbols.

Image of apply dictionary renderer to feature layer

Use case

A dictionary renderer uses a style file along with a rule engine to display advanced symbology. This is useful for displaying features using precise military symbology.

How to use the sample

Pan and zoom around the map. Observe the displayed military symbology on the map.

How it works

  1. Create a Geodatabase using Geodatabase.withFileUri().
  2. Load the geodatabase using Geodatabase.load().
  3. Instantiate a DictionarySymbolStyle using DictionarySymbolStyle.withFileUri().
  4. Load the dictionary symbol style using DictionarySymbolStyle.load().
  5. Cycle through each GeodatabaseFeatureTable from the geodatabase using Geodatabase.geodatabaseFeatureTables.
  6. Create a FeatureLayer from each table within the geodatabase using FeatureLayer.withFeatureTable().
  7. Create a DictionaryRenderer and assign it to each feature layer using featureLayer.renderer = dictionaryRenderer.
  8. Add the feature layers to the map using ArcGISMap.operationalLayers.addAll().
  9. Load the feature layers with FeatureLayer.load().
  10. After the layers have loaded, create a new extent from the union of all layer extents.
  11. Set that extent as the map view viewpoint using ArcGISMapViewController.setViewpoint().

Relevant API

  • DictionaryRenderer
  • DictionarySymbolStyle

Offline data

This sample uses the mil2525d stylx file and the military overlay geodatabase. They are downloaded from ArcGIS Online as part of the sample.

Tags

military, symbol

Sample code

apply_dictionary_renderer_to_feature_layer.dart
// Copyright 2026 Esri
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
import 'dart:io';
import 'package:arcgis_maps/arcgis_maps.dart';
import 'package:arcgis_maps_sdk_flutter_samples/common/common.dart';
import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
class ApplyDictionaryRendererToFeatureLayer extends StatefulWidget {
const ApplyDictionaryRendererToFeatureLayer({super.key});
@override
State<ApplyDictionaryRendererToFeatureLayer> createState() =>
_ApplyDictionaryRendererToFeatureLayerState();
}
class _ApplyDictionaryRendererToFeatureLayerState
extends State<ApplyDictionaryRendererToFeatureLayer>
with SampleStateSupport {
// Create a controller for the map view.
final _mapViewController = ArcGISMapView.createController();
@override
Widget build(BuildContext context) {
return Scaffold(
// Add a map view to the widget tree and set a controller.
body: ArcGISMapView(
controllerProvider: () => _mapViewController,
onMapViewReady: onMapViewReady,
),
);
}
Future<void> onMapViewReady() async {
// Create file references for the dictionary style and geodatabase.
final listPaths = GoRouter.of(context).state.extra! as List<String>;
final styleFile = File(listPaths.first);
final geodatabaseFile = File(listPaths.last);
// Create the map and assign it to the map view controller.
final map = ArcGISMap.withBasemapStyle(BasemapStyle.arcGISTopographic);
_mapViewController.arcGISMap = map;
// Open the geodatabase that contains the military overlay features.
final geodatabase = Geodatabase.withFileUri(geodatabaseFile.uri);
await geodatabase.load();
// Load the dictionary symbol style from the local stylx file.
final dictionarySymbolStyle = DictionarySymbolStyle.withFileUri(
styleFile.uri,
);
await dictionarySymbolStyle.load();
// Create a feature layer for each table in the geodatabase.
final featureLayers = <FeatureLayer>[];
for (final table in geodatabase.geodatabaseFeatureTables) {
final featureLayer = FeatureLayer.withFeatureTable(table);
// Apply a dictionary renderer so the layer uses military symbols.
featureLayer.renderer = DictionaryRenderer(
dictionarySymbolStyle: dictionarySymbolStyle,
);
featureLayer.minScale = 1000000;
featureLayers.add(featureLayer);
}
// Add all of the feature layers to the map.
map.operationalLayers.addAll(featureLayers);
// Load the layers so their content and extents are available.
await Future.wait(featureLayers.map((layer) => layer.load()));
// Build a combined extent from all loaded feature layers.
final envelopeBuilder = EnvelopeBuilder(
spatialReference: SpatialReference.wgs84,
);
featureLayers
.map((layer) => layer.fullExtent)
.nonNulls
.forEach(envelopeBuilder.unionWithEnvelope);
// Set the map viewpoint so all rendered features are visible.
_mapViewController.setViewpoint(
Viewpoint.fromTargetExtent(envelopeBuilder.extent),
);
}
}