<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Vivian Quach</title>
    <description>The latest articles on DEV Community by Vivian Quach (@vquach2404).</description>
    <link>https://dev.to/vquach2404</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1254707%2F8124223e-105f-4ed3-aead-289185d06a55.png</url>
      <title>DEV Community: Vivian Quach</title>
      <link>https://dev.to/vquach2404</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/vquach2404"/>
    <language>en</language>
    <item>
      <title>How to use SF Symbols in your ArcGIS Maps SDK for Swift app</title>
      <dc:creator>Vivian Quach</dc:creator>
      <pubDate>Sat, 13 Jan 2024 00:51:54 +0000</pubDate>
      <link>https://dev.to/vquach2404/how-to-use-sf-symbols-in-your-arcgis-maps-sdk-for-swift-app-49oi</link>
      <guid>https://dev.to/vquach2404/how-to-use-sf-symbols-in-your-arcgis-maps-sdk-for-swift-app-49oi</guid>
      <description>&lt;p&gt;Want to know a Swift Maps SDK secret? The Swift Maps SDK supports showing Apple’s SF Symbols® on maps! Read on to learn the benefits of incorporating SF Symbols into apps built with the Swift Maps SDK by looking at what SF Symbols are, how to improve your iOS development experience, and how you can build visually beautiful iOS apps.&lt;/p&gt;

&lt;p&gt;Maps and symbols go together like mac and cheese – they’re a perfect combination and enhance each other’s properties. Symbology plays an important role in GIS as &lt;a href="https://developers.arcgis.com/documentation/glossary/symbol/" rel="noopener noreferrer"&gt;symbols&lt;/a&gt; can express meanings through images, color, and size. Most, if not all, maps will incorporate symbology in some way.&lt;/p&gt;

&lt;p&gt;The most basic symbols you may see are dots to represent cities and stars to emphasize capitals. Consider how your local weather presenter might present the forecast. They stand in front of a map with images of clouds or suns, and you instantly know what kind of weather to expect for the day. Symbols convey messages that can bypass any language barriers.&lt;/p&gt;

&lt;p&gt;With the Swift Maps SDK, it’s easy to &lt;a href="https://developers.arcgis.com/swift/maps-2d/tutorials/display-a-map/" rel="noopener noreferrer"&gt;display maps&lt;/a&gt; containing symbol-rich cartography authored using e.g. ArcGIS Pro desktop app or an ArcGIS Map Viewer web app. But sometimes, you want to programmatically add additional custom &lt;a href="https://developers.arcgis.com/documentation/mapping-apis-and-services/visualization/point-line-and-polygon-styles/#symbols" rel="noopener noreferrer"&gt;symbols&lt;/a&gt; to the map on your app or change the original symbology of a data layer on the map. You can do this easily with the Swift Maps SDK, let’s look at how using Apple’s SF Symbols as an example.&lt;/p&gt;

&lt;h2&gt;
  
  
  What are SF Symbols?
&lt;/h2&gt;

&lt;p&gt;The Swift Maps SDK offers a number of predefined simple 2D and 3D symbols (e.g. circles, diamonds, cubes, and more), as well as support for advanced symbols using the multilayer symbols API or style files (.stylx) created from ArcGIS Pro. To take your customization even further, you can import your own images as e.g. JPEG, PNG format, and create symbols from them using the picture marker symbol API. There are endless possibilities, but the hardest part about symbology is curating symbols that look good and fit your needs. An easy approach when developing iOS applications is to use Apple’s SF Symbols which are compatible with the Swift Maps SDK.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fflqtkmex1ux3njt7i23v.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fflqtkmex1ux3njt7i23v.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://developer.apple.com/design/human-interface-guidelines/sf-symbols" rel="noopener noreferrer"&gt;SF Symbols&lt;/a&gt; are vector-based images created for iOS apps, provided to developers by Apple. The “SF” in SF Symbols refers to the San Francisco system font used by Apple platforms. In Apple’s words, SF Symbols are “a library of iconography designed to integrate seamlessly with San Francisco.” The symbols are customizable in color, size, and weight. Developers are encouraged to use these in their iOS apps. You can &lt;a href="https://developer.apple.com/sf-symbols/" rel="noopener noreferrer"&gt;download&lt;/a&gt; the SF Symbols app to browse the thousands of symbols that are offered.&lt;/p&gt;

&lt;p&gt;Note: the library does contain copyrighted symbols and there are limitations on their use – check the SF Symbols documentation for more &lt;a href="https://developer.apple.com/design/human-interface-guidelines/sf-symbols#Custom-symbols" rel="noopener noreferrer"&gt;information&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  How do SF Symbols benefit developers?
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffzyp6dqj0d0cugagwm2r.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffzyp6dqj0d0cugagwm2r.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F749u3n8ib9q7jydji7xb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F749u3n8ib9q7jydji7xb.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Symbols are used to indicate an action or to convey a message. You can find good examples of SF Symbols in any iOS app built by Apple. The Apple News app is a good example of using SF Symbols in a toolbar alongside text to indicate the active tab in an app. In some cases, text isn’t even necessary. For example, users can infer what action a trash can symbol represents. Additionally, SF Symbols vary in color and size. Adjusting the colors is easy using the system colors. And because SF Symbols are vector-based, the images can scale without losing quality.&lt;/p&gt;

&lt;p&gt;You can also use symbols to represent a large data set. Thinking again of our local weather forecast, clouds and suns symbolize the weather data. Because we may use a variety of symbols in one app, it is important that the symbols have a consistent theme or font. Utilizing SF Symbols can make your apps look more cohesive.&lt;/p&gt;

&lt;p&gt;Speaking of cohesion, iOS developers know how important it is to incorporate a consistent, clean Apple “look” to their apps. Apple is known for upholding a certain “look” to all their products and encourages their developers do the same. Apps that adhere to the same standards exude a sense of professionalism and blend seamlessly with the iOS environment. Incorporating SF Symbols in your apps can help you achieve that Apple look with minimal effort.&lt;/p&gt;

&lt;h2&gt;
  
  
  How to add SF Symbols to your Swift Maps SDK app
&lt;/h2&gt;

&lt;p&gt;We’re ready to symbolize! Let’s create a Swift Maps SDK app that shows the start of a hiking trail in Malibu, California, using the &lt;a href="https://developers.arcgis.com/swift/maps-2d/tutorials/display-a-map/" rel="noopener noreferrer"&gt;Display a map tutorial app&lt;/a&gt;. This app simply displays a map with an existing basemap style and using this project as a starting point, all we need to do is add a single symbol on top of the basemap.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 1: Add a GraphicsOverlay
&lt;/h3&gt;

&lt;p&gt;Symbols are only attributes of &lt;a href="https://developers.arcgis.com/documentation/glossary/graphic/" rel="noopener noreferrer"&gt;graphics&lt;/a&gt; or renderers. To display symbols, the first step is to add a &lt;a href="https://developers.arcgis.com/documentation/glossary/graphics-overlay/" rel="noopener noreferrer"&gt;graphics overlay&lt;/a&gt;. A graphics overlay allows you to add graphics to a layer which is then overlaid on top of the map.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// `model` is an ObservableObject that contains a GraphicsOverlay.
MapView(map: map, graphicsOverlays: [model.graphicsOverlay])
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 2: Create a UIImage from an SFSymbol
&lt;/h3&gt;

&lt;p&gt;Choose an SF Symbol from the library that is suitable for your needs; in this case, we’ve selected the “figure.walk.circle.fill” symbol. Once you’ve selected an SF Symbol, create a UIImage using its system name. The name must match exactly as it appears in the SF Symbol app, so the compiler knows which symbol to use.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let image = UIImage(systemName: "figure.walk.circle.fill")!
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 3: Create a PictureMarkerSymbol
&lt;/h3&gt;

&lt;p&gt;Next, create a &lt;a href="https://developers.arcgis.com/swift/api-reference/documentation/arcgis/picturemarkersymbol" rel="noopener noreferrer"&gt;PictureMarkerSymbol&lt;/a&gt; using the UIImage. The PictureMarkerSymbol class uses an image to symbolize graphics and features that have point or multipoint geometry. Note: PictureMarkerSymbols do not support GIFs nor can they detect theme changes; therefore, SF Symbols cannot be animated and changing the app’s light and dark appearance will have no effect.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let symbol = PictureMarkerSymbol(image: image)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 4: Create a point
&lt;/h3&gt;

&lt;p&gt;Create a point to use as the location for the symbol.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let point = Point(x: -118.806546, y: 34.020933, spatialReference: .wgs84)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 5: Create a graphic
&lt;/h3&gt;

&lt;p&gt;Create a graphic using the point and PictureMarkerSymbol.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let graphic = Graphic(geometry: point, symbol: symbol)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 6: Add the graphic
&lt;/h3&gt;

&lt;p&gt;Lastly, add the Graphic to the graphics overlay. Now we know where to go for a fun hike in Malibu. How easy was that?&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;graphicsOverlay.addGraphic(graphic)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhj2k2v7xtp0f72htpp1v.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhj2k2v7xtp0f72htpp1v.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Adding SF Symbols to a dataset
&lt;/h2&gt;

&lt;p&gt;There is of course more than one hiking trail in Malibu. Let’s try adding multiple symbols at once to multiple points, using a data layer. A &lt;a href="https://developers.arcgis.com/documentation/glossary/feature-layer-server-side/" rel="noopener noreferrer"&gt;feature layer&lt;/a&gt; contains a dataset that can be visualized by a &lt;a href="https://developers.arcgis.com/swift/styles-and-data-visualization/symbols-renderers-and-styles/#renderers" rel="noopener noreferrer"&gt;renderer&lt;/a&gt; which contains a set of symbols. This feature layer contains data of multiple trailheads in Malibu, California. Plain circles on a map would do the job but using the “figure.walk.circle.fill” SF Symbol helps convey the message that these points are trailheads. The &lt;a href="https://developers.arcgis.com/swift/layers/tutorials/add-a-feature-layer/" rel="noopener noreferrer"&gt;Add a feature layer tutorial app&lt;/a&gt; displays the Malibu trailhead feature layer on top of a map. Using this app as a starting point, all we need to do is add a renderer.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 1: Create a UIImage
&lt;/h3&gt;

&lt;p&gt;To create a feature layer renderer, make a UIImage of the SF Symbol you want to display. We’re still using the “figure.walk.circle.fill” SF Symbol.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let image = UIImage(systemName: "figure.walk.circle.fill")!
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 2: Create a PictureMarkerSymbol
&lt;/h3&gt;

&lt;p&gt;Using that image, create a PictureMarkerSymbol.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let symbol = PictureMarkerSymbol(image: image)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 3: Create a SimpleRenderer
&lt;/h3&gt;

&lt;p&gt;Lastly, create a &lt;a href="https://developers.arcgis.com/swift/api-reference/documentation/arcgis/simplerenderer" rel="noopener noreferrer"&gt;SimpleRenderer&lt;/a&gt; with that symbol and set it to the feature layer’s renderer property. That’s it! Creating multiple SF Symbols is just as easy as making just one symbol! Notice below the difference between using a default circle and an SF Symbol to indicate the trailheads.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;featureLayer.renderer = SimpleRenderer(symbol: symbol)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0o4bcowaisdt9yhfdn2w.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0o4bcowaisdt9yhfdn2w.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Customizing SF Symbols
&lt;/h2&gt;

&lt;p&gt;What happens if you don’t like the default style of SF Symbols? Just as you can customize the default Swift Maps SDK symbols, you can easily customize SF Symbols to your preference!&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 1: Preview
&lt;/h3&gt;

&lt;p&gt;Open the SF Symbols app and ensure the Rendering Inspector panel is visible. Select your symbol and use the Rendering Inspector to preview different colors and rendering modes. We’ve changed the palette rendering mode and used purple and cyan.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flodgrm75z1n423y2mb6z.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flodgrm75z1n423y2mb6z.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 2: Make a configuration
&lt;/h3&gt;

&lt;p&gt;Once you’ve customized the symbol to your liking, take it to the code. Symbol configuration is an object that contains the styling information that will be applied to the UIImage. Create a symbol configuration based off the settings in preview.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var config = UIImage.SymbolConfiguration(paletteColors: [.systemPurple, .systemCyan])

config = config.applying(UIImage.SymbolConfiguration(font: .systemFont(ofSize: 30.0)))
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 3: Apply the configuration
&lt;/h3&gt;

&lt;p&gt;Create an image with the configuration or apply the configuration to an existing image. There you have it, a quick and simple way to stylize SF Symbols which you can then display in your Swift Maps SDK app!&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Creates the image with the configuration.

let imageWithConfig = UIImage(systemName: "figure.walk.circle.fill", withConfiguration: config)!

// Applies the symbol to the configuration after.

let appliedConfigImage = image.applyingSymbolConfiguration(config)!
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F87oluylyphyedg8czis1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F87oluylyphyedg8czis1.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Summary
&lt;/h2&gt;

&lt;p&gt;The use of symbols in your Swift Maps SDK apps provide meaningful context and messaging to your users. By including SF Symbols (tools provided by Apple) in your app, you can use them to indicate actions or convey messages alongside text or just by themselves. The ArcGIS Maps SDK for Swift makes it easy to add customized symbols to your app by utilizing the PictureMarkerSymbol and Renderer classes. Doing so can save you time and help you create an app that users will be drawn to.&lt;/p&gt;

&lt;p&gt;You can check out the code on my &lt;a href="https://github.com/vquach2404/SFSymbols-and-ArcGIS/tree/main" rel="noopener noreferrer"&gt;GitHub&lt;/a&gt; to review the examples in this blog in depth. Once you’re ready to try it out for yourself, you can create a &lt;a href="https://developers.arcgis.com/sign-up/" rel="noopener noreferrer"&gt;developer account&lt;/a&gt; for free and download &lt;a href="https://dev.toArcGIS%20Maps%20SDK%20for%20Swift"&gt;ArcGIS Maps SDK for Swift&lt;/a&gt; and get started with our tutorials and documentation. For more help with styling a feature layer, check out the &lt;a href="https://developers.arcgis.com/swift/styles-and-data-visualization/tutorials/style-a-feature-layer/" rel="noopener noreferrer"&gt;tutorial&lt;/a&gt;!&lt;/p&gt;

</description>
      <category>ios</category>
      <category>swiftui</category>
      <category>arcgis</category>
      <category>symbology</category>
    </item>
  </channel>
</rss>
