Search dictionary symbol style

View inC++QMLView on GitHubSample viewer app

Find symbols within the mil2525d specification that match a keyword.

screenshot

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

  1. Create a symbol dictionary with the mil2525d specification by passing the string "mil2525d" and the path to a .stylx file to the SymbolDictionary constructor.
  2. Create SymbolStyleSearchParameters.
  3. Add members to the names, tags, symbolClasses, categories, and keys list fields of the search parameters.
  4. Search for symbols using the parameters with DictionarySymbolStyle.searchSymbols(SymbolStyleSearchParameters).
  5. Get the Symbol from the list of returned SymbolStyleSearchResultListModels.

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. ArcGIS Runtime 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.

While developing, you can omit the path to the .stylx style file; Runtime will refer to a copy installed with the SDK. For production, you should take care to deploy the proper style files and explicitly specify the path to that file when creating the symbol dictionary. 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

SearchDictionarySymbolStyle.qml
Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
// [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 QtQuick 2.6
import QtQuick.Controls 2.2
import QtQuick.Layouts 1.3
import Esri.ArcGISRuntime 100.15
import Esri.ArcGISExtras 1.1

Rectangle {
    id: rootRectangle
    clip: true
    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"]
    readonly property url dataPath: System.userHomePath + "/ArcGIS/Runtime/Data/styles/arcade_style/mil2525d.stylx"
    property var searchParamList: [[],[],[],[],[]]
    property DictionarySymbolStyle dictionarySymbolStyle: Factory.DictionarySymbolStyle.createFromFile(dataPath);

    Connections {
        target: dictionarySymbolStyle

        function onSearchSymbolsStatusChanged() {
            if (dictionarySymbolStyle.searchSymbolsStatus !== Enums.TaskStatusCompleted)
                return;

            resultView.visible = true;

            //Update the number of results retuned
            resultText.text = "Result(s) found: " + dictionarySymbolStyle.searchSymbolsResult.count
        }
    }

    SymbolStyleSearchParameters {
        id: searchParams
    }

    ColumnLayout {
        id: topRectangle
        anchors {
            fill: parent
            margins: 9
        }

        Column {
            id: fieldColumn
            Layout.fillWidth: true
            Layout.margins: 8
            visible: !hideSearch.checked
            enabled: visible

            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: RegExpValidator{ regExp: /^\s*[\da-zA-Z_][\da-zA-Z\s_]*$/ }
                            onAccepted:  addCategoryButton.mouseArea.clicked();
                        }

                        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: mouseArea
                                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: 100
                height: 32
                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: {
                    resultView.visible = false;

                    searchParams.names = searchParamList[0];
                    searchParams.tags = searchParamList[1];
                    searchParams.symbolClasses = searchParamList[2];
                    searchParams.categories = searchParamList[3];
                    searchParams.keys = searchParamList[4];

                    dictionarySymbolStyle.searchSymbols(searchParams);
                }
            }

            Button {
                text: "Clear"
                enabled: resultView.count > 0
                onClicked: {
                    //Set the results visibility to false
                    resultView.visible = false;
                    //Reset the search parameters
                    searchParamList = [[],[],[],[],[]];
                }
            }

            Button {
                id: hideSearch
                height: seachBtn.height
                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: dictionarySymbolStyle.searchSymbolsResult

                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
                            }
                        }
                    }
                }
            }
        }
    }
}

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.