Find symbols within the mil2525d specification that match a keyword.

Use case
You can use support for military symbology to allow users to report changes in the field using the correct military symbols.
How to use the sample
By default, leaving the fields blank and hitting search will find all symbols.
To search for certain symbols, enter text into one or more search boxes and click ‘Search for symbols’. Results are shown in a list. Pressing ‘Clear’ will reset the search.
How it works
- Create a symbol dictionary with the mil2525d specification by passing the string “mil2525d” and the path to a .stylx file to the
SymbolDictionaryconstructor. - Create
SymbolStyleSearchParameters. - Add members to the
names,tags,symbolClasses,categories, andkeyslist fields of the search parameters. - Search for symbols using the parameters with
DictionarySymbolStyle::searchSymbolsAsync(SymbolStyleSearchParameters). - Get the
Symbolfrom the list of returnedSymbolStyleSearchResultListModels.
Relevant API
- DictionarySymbolStyle
- Symbol
- SymbolStyleSearchParameters
- SymbolStyleSearchResultListModel
Offline Data
Read more about how to set up the sample’s offline data here.
| Link | Local Location |
|---|---|
| Mil2525d Stylx File | <userhome>/ArcGIS/Runtime/Data/styles/arcade_style/mil2525d.stylx |
Additional information
This sample features the mil2525D specification. The ArcGIS Maps SDK for Qt supports other military symbology standards, including mil2525C and mil2525B(change 2). See the Military Symbology Styles overview on ArcGIS Solutions for Defense for more information about support for military symbology.
Tags
CIM, defense, look up, MIL-STD-2525B, MIL-STD-2525C, MIL-STD-2525D, mil2525b, mil2525c, mil2525d, military, military symbology, search, symbology
Sample Code
// [WriteFile Name=SearchDictionarySymbolStyle, Category=Search]// [Legal]// Copyright 2016 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// http://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.// [Legal]
#ifdef PCH_BUILD#include "pch.hpp"#endif // PCH_BUILD
// sample headers#include "SearchDictionarySymbolStyle.h"
// ArcGIS Maps SDK headers#include "DictionarySymbolStyle.h"#include "SymbolStyleSearchParameters.h"#include "SymbolStyleSearchResultListModel.h"
// Qt headers#include <QFuture>#include <QStandardPaths>#include <QtCore/qglobal.h>
using namespace Esri::ArcGISRuntime;
// helper method to get cross platform data pathnamespace{ QString defaultDataPath() { QString dataPath;
#ifdef Q_OS_IOS dataPath = QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation); #else dataPath = QStandardPaths::writableLocation(QStandardPaths::HomeLocation); #endif
return dataPath; }} // namespace
using namespace Esri::ArcGISRuntime;
SearchDictionarySymbolStyle::SearchDictionarySymbolStyle(QQuickItem* parent) : QQuickItem(parent){}
SearchDictionarySymbolStyle::~SearchDictionarySymbolStyle() = default;
void SearchDictionarySymbolStyle::init(){ qmlRegisterType<SearchDictionarySymbolStyle>("Esri.Samples", 1, 0, "SearchDictionarySymbolStyleSample"); qmlRegisterUncreatableType<QAbstractListModel>("Esri.Samples", 1, 0, "AbstractListModel", "AbstractListModel is uncreateable");}
void SearchDictionarySymbolStyle::componentComplete(){ QQuickItem::componentComplete();
//Get the data path QString datapath = defaultDataPath() + "/ArcGIS/Runtime/Data/styles/arcade_style/mil2525d.stylx";
//Create the dictionary from datapath (added since 100.6) m_dictionarySymbolStyle = DictionarySymbolStyle::createFromFile(datapath, this);}
QAbstractListModel* SearchDictionarySymbolStyle::searchResultsListModel() const{ return m_searchResults;}
void SearchDictionarySymbolStyle::search(const QStringList& namesSearchParam, const QStringList& tagsSearchParam, const QStringList& classesSearchParam,const QStringList& categoriesSearchParam, const QStringList& keysSearchParam){ //Create search parameters and search with the parameters SymbolStyleSearchParameters searchParameters; searchParameters.setCategories(categoriesSearchParam); searchParameters.setKeys(keysSearchParam); searchParameters.setNames(namesSearchParam); searchParameters.setSymbolClasses(classesSearchParam); searchParameters.setTags(tagsSearchParam); m_dictionarySymbolStyle->searchSymbolsAsync(searchParameters).then(this, [this](SymbolStyleSearchResultListModel* results) { m_searchResults = results; emit searchResultsListModelChanged(); emit searchCompleted(results->size()); });}// [WriteFile Name=SearchDictionarySymbolStyle, Category=Search]// [Legal]// Copyright 2016 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// http://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.// [Legal]
#ifndef SEARCHDICTIONARYSYMBOLSTYLE_H#define SEARCHDICTIONARYSYMBOLSTYLE_H
// Qt headers#include <QAbstractListModel>#include <QQuickItem>#include <QUuid>
namespace Esri::ArcGISRuntime{ class DictionarySymbolStyle;}
class SearchDictionarySymbolStyle : public QQuickItem{ Q_OBJECT
Q_PROPERTY(QAbstractListModel* searchResultsListModel READ searchResultsListModel NOTIFY searchResultsListModelChanged)
public: explicit SearchDictionarySymbolStyle(QQuickItem* parent = nullptr); ~SearchDictionarySymbolStyle() override;
enum class FieldEnum { FieldNames, FieldTags, FieldClasses, FieldCategories, FieldKeys }; Q_ENUM(FieldEnum)
void componentComplete() override; static void init(); Q_INVOKABLE void search(const QStringList& namesSearchParam, const QStringList& tagsSearchParam, const QStringList& classesSearchParam,const QStringList& categoriesSearchParam, const QStringList& keysSearchParam);
QAbstractListModel* searchResultsListModel() const;
signals: void searchCompleted(int count); void searchResultsListModelChanged();
private: Esri::ArcGISRuntime::DictionarySymbolStyle* m_dictionarySymbolStyle = nullptr; QAbstractListModel* m_searchResults = nullptr;};
#endif // SEARCHDICTIONARYSYMBOLSTYLE_H// [WriteFile Name=SearchDictionarySymbolStyle, Category=Search]// [Legal]// Copyright 2016 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// http://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.// [Legal]
import QtQuickimport QtQuick.Controlsimport QtQuick.Layoutsimport Esri.Samples
SearchDictionarySymbolStyleSample { id: searchDictionarySymbolStyleSample width: 800 height: 600
readonly property double fontSize: 16 readonly property var repeaterModel: ["Names", "Tags", "Symbol Classes", "Categories", "Keys"] readonly property var hintsModel: ["Fire", "Sustainment Points", "3", "Control Measure", "25212300_6"] property var searchParamList: [[],[],[],[],[]]
ColumnLayout { id: topRectangle anchors { fill: parent margins: 9 }
Column { id: fieldColumn visible: !hideSearch.checked enabled: visible Layout.fillWidth: true Layout.margins: 8
Repeater { id: repeater model: repeaterModel
Rectangle { width: parent.width height: childrenRect.height color: "lightgrey" border.color: "darkgrey" radius: 2 clip: true
GridLayout { anchors { left: parent.left right: parent.right margins: 3 } columns: 3 rowSpacing: 0 Text { text: repeaterModel[index] font.bold: true verticalAlignment: Text.AlignVCenter horizontalAlignment: Text.AlignLeft wrapMode: Text.WordWrap }
TextField { id: categoryEntry Layout.fillWidth: true placeholderText: repeaterModel[index] +" (e.g. "+ hintsModel[index] +")" selectByMouse: true validator: RegularExpressionValidator{ regularExpression: /^\s*[\da-zA-Z_][\da-zA-Z\s_]*$/ } onAccepted: addCategoryButtonMouseArea.clicked(true); }
Rectangle { id: addCategoryButton height: childrenRect.height width: height color: "transparent" Image { source: parent.enabled ? "qrc:/Samples/Search/SearchDictionarySymbolStyle/ic_menu_addencircled_light.png" : "qrc:/Samples/Search/SearchDictionarySymbolStyle/ic_menu_addencircled_dark.png" } enabled: categoryEntry.text.length > 0
MouseArea { id: addCategoryButtonMouseArea anchors.fill: parent onClicked: { if (categoryEntry.text.length === 0) return;
const tmp = searchParamList; tmp[index].push(categoryEntry.text);
searchParamList = tmp; categoryEntry.text = ""; } } }
Label { id: categoryList Layout.fillWidth: true Layout.column: 1 Layout.row: 1 text: searchParamList[index].length > 0 ? searchParamList[index].join() : "" }
Rectangle { height: childrenRect.height width: height color: "transparent" Image { source: parent.enabled ? "qrc:/Samples/Search/SearchDictionarySymbolStyle/ic_menu_closeclear_light.png" : "qrc:/Samples/Search/SearchDictionarySymbolStyle/ic_menu_closeclear_dark.png" } enabled: categoryList.text.length > 0
MouseArea { anchors.fill: parent onClicked: { categoryEntry.text = ""; const tmp = searchParamList; tmp[index] = [];
searchParamList = tmp; } } } } } } }
Row { spacing: 10
Button { id: seachBtn width: childrenRect.width Image { id: searchImage anchors { top: parent.top bottom: parent.bottom margins: 3 } source: "qrc:/Samples/Search/SearchDictionarySymbolStyle/ic_menu_find_light.png" }
Text { anchors { left: searchImage.right verticalCenter: parent.verticalCenter margins: 3 } text: searchParamList[0].length === 0 && searchParamList[1].length === 0 && searchParamList[2].length === 0 && searchParamList[3].length === 0 && searchParamList[4].length === 0 ? "List All" : "Search" }
onClicked: { //start the search resultView.visible = false;
searchDictionarySymbolStyleSample.search(searchParamList[SearchDictionarySymbolStyleSample.FieldNames], searchParamList[SearchDictionarySymbolStyleSample.FieldTags], searchParamList[SearchDictionarySymbolStyleSample.FieldClasses], searchParamList[SearchDictionarySymbolStyleSample.FieldCategories], searchParamList[SearchDictionarySymbolStyleSample.FieldKeys]); } }
Button { text: "Clear" onClicked: { //Set the results visibility to false resultView.visible = false; //Reset the search parameters searchParamList = [[],[],[],[],[]]; } }
Button { id: hideSearch checked: false checkable: true Image { anchors { top: parent.top bottom: parent.bottom horizontalCenter: parent.horizontalCenter margins: 3 } source: parent.checked ? "qrc:/Samples/Search/SearchDictionarySymbolStyle/ic_menu_collapsed_light.png" : "qrc:/Samples/Search/SearchDictionarySymbolStyle/ic_menu_expanded_light.png" } } }
Text { id: resultText visible: resultView.visible text: "Result(s) found: " + resultView.count font.pixelSize: fontSize }
Rectangle { id: bottomRectangle Layout.fillHeight: true Layout.fillWidth: true
//Listview of results returned from Dictionary ListView { id: resultView anchors { fill: parent margins: 10 } spacing: 20
clip: true model: searchResultsListModel
delegate: Component { Row { anchors { margins: 20 } width: resultView.width spacing: 10
Image { source: symbolUrl }
Column { width: parent.width spacing: 10
Text { id: nameText text: "<b>Name:</b> " + name font.pixelSize: fontSize width: parent.width wrapMode: Text.WrapAtWordBoundaryOrAnywhere }
Text { text: "<b>Tags:</b> " + tags font.pixelSize: fontSize width: nameText.width wrapMode: Text.WrapAtWordBoundaryOrAnywhere }
Text { text: "<b>SymbolClass:</b> " + symbolClass font.pixelSize: fontSize width: nameText.width wrapMode: Text.WrapAtWordBoundaryOrAnywhere }
Text { text: "<b>Category:</b> " + category font.pixelSize: fontSize width: nameText.width wrapMode: Text.WrapAtWordBoundaryOrAnywhere }
Text { text: "<b>Key:</b> " + key font.pixelSize: fontSize width: nameText.width wrapMode: Text.WrapAtWordBoundaryOrAnywhere } } } } } } }
//Search completed onSearchCompleted: count => { seachBtn.enabled = true; resultView.visible = true;
//Update the number of results retuned resultText.text = "Result(s) found: " + count }}// [Legal]// Copyright 2016 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// http://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.// [Legal]
// sample headers#include "SearchDictionarySymbolStyle.h"
// ArcGIS Maps SDK headers#include "ArcGISRuntimeEnvironment.h"
// Qt headers#include <QCommandLineParser>#include <QDir>#include <QGuiApplication>#include <QQmlEngine>#include <QQuickView>#include <QSettings>
// Platform specific headers#ifdef Q_OS_WIN#include <Windows.h>#endif
#define STRINGIZE(x) #x#define QUOTE(x) STRINGIZE(x)
int main(int argc, char *argv[]){ Esri::ArcGISRuntime::ArcGISRuntimeEnvironment::setUseLegacyAuthentication(false); QGuiApplication app(argc, argv); app.setApplicationName(QString("SearchDictionarySymbolStyle"));
// Use of ArcGIS location services, such as basemap styles, geocoding, and routing services, // requires an access token. For more information see // https://links.esri.com/arcgis-runtime-security-auth.
// The following methods grant an access token:
// 1. User authentication: Grants a temporary access token associated with a user's ArcGIS account. // To generate a token, a user logs in to the app with an ArcGIS account that is part of an // organization in ArcGIS Online or ArcGIS Enterprise.
// 2. API key authentication: Get a long-lived access token that gives your application access to // ArcGIS location services. Go to the tutorial at https://links.esri.com/create-an-api-key. // Copy the API Key access token.
const QString accessToken = QString("");
if (accessToken.isEmpty()) { qWarning() << "Use of ArcGIS location services, such as the basemap styles service, requires" << "you to authenticate with an ArcGIS account or set the API Key property."; } else { Esri::ArcGISRuntime::ArcGISRuntimeEnvironment::setApiKey(accessToken); }
// Initialize the sample SearchDictionarySymbolStyle::init();
// Initialize application view QQuickView view; view.setResizeMode(QQuickView::SizeRootObjectToView);
// Add the import Path view.engine()->addImportPath(QDir(QCoreApplication::applicationDirPath()).filePath("qml"));
QString arcGISRuntimeImportPath = QUOTE(ARCGIS_RUNTIME_IMPORT_PATH);
#if defined(LINUX_PLATFORM_REPLACEMENT) // on some linux platforms the string 'linux' is replaced with 1 // fix the replacement paths which were created QString replaceString = QUOTE(LINUX_PLATFORM_REPLACEMENT); arcGISRuntimeImportPath = arcGISRuntimeImportPath.replace(replaceString, "linux", Qt::CaseSensitive); #endif
// Add the Runtime and Extras path view.engine()->addImportPath(arcGISRuntimeImportPath);
// Set the source view.setSource(QUrl("qrc:/Samples/Search/SearchDictionarySymbolStyle/SearchDictionarySymbolStyle.qml"));
view.show();
return app.exec();}