spatialillusions / milsymbol

Military Symbols in JavaScript
www.spatialillusions.com/milsymbol
MIT License
531 stars 132 forks source link

Searchable milsymbols #270

Closed sjlynch closed 1 year ago

sjlynch commented 2 years ago

Hi!

Is there a way to search for symbols using human readable text vs using SIDC? For example, if a user types in "fishing", "leisure" or "missile" then I want all of the icons related to the search term to appear. I know how to implement the actual search, that's easy, the problem I'm facing is that I can't find a way to map human readable text to the SIDC for each symbol.

I sort of see how the document https://spatialillusions.com/milsymbol/docs/milsymbol-2525d.html is created in source, but I don't think those labels are exposed in the milsymbol library itself, are they? Short of manually building and/or copy/pasting a SIDC<->Human-readable-text, is there any easier way to do this that I'm not seeing?

Thanks!

kjellmf commented 2 years ago

Måns has published symbology data (with labels and sidcs) in separate repositories:

I have used this data to search for symbols in a couple of projects. You basically end up with a large list of objects you can search through. If you are familiar with Vue.js you can find a few examples below:

Building a searchable list: https://github.com/kjellmf/orbat-mapper/blob/665b796e60969d4c6a2c1938f6605d29857922bb/src/composables/symbolData.ts#L27

Doing the actual search: https://github.com/kjellmf/orbat-mapper/blob/665b796e60969d4c6a2c1938f6605d29857922bb/src/components/SymbolPickerModal.vue#L162

Constructing the final SIDC: https://github.com/kjellmf/orbat-mapper/blob/665b796e60969d4c6a2c1938f6605d29857922bb/src/components/SymbolPickerModal.vue#L172

sjlynch commented 2 years ago

Thank you!! This is exactly what I was hoping for!