Book Image

Learning ArcGIS Runtime SDK for .NET

By : Ron Vincent
Book Image

Learning ArcGIS Runtime SDK for .NET

By: Ron Vincent

Overview of this book

ArcGIS is a geographic information system (GIS) that enables you to work with maps and geographic information. It can be used to create and utilize maps, compile geographic data, analyze mapped information, share and discover geographic information and manage geographic information in a database. This book starts by showing you where ArcGIS Runtime fits within Esri’s overall platform strategy. You'll create an initial map using the SDK, then use it to get an understanding of the MVVM model. You'll find out about the different kinds of layers and start adding layers, and you'll learn to transform maps into a 3D scene. The next chapters will help you comprehend and extract information contained in the maps using co-ordinates and layer objects. Towards the end, you will learn to set the symbology, decide whether to use 2D or 3D, see how to implement 2D or 3D, and learn to search and find objects. You'll also get to grips with many other standard features of the Application Programming Interface (API), including create applications and finally testing, licensing, and deploying them. Once completed, you will be able to meet most of the common requirements of any mapping application for desktop or mobile platforms.
Table of Contents (19 chapters)
Learning ArcGIS Runtime SDK for .NET
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
3
Maps and Layers
12
Configuring, Licensing, and Deploying
Index

Preface

Welcome to the exciting world of building native, cross-platform mapping apps! For many kinds of app, a map is not only a nice feature, it's a must. With this book, you're going to explore ArcGIS Runtime, which is a Software Developer Kit (SDK) from Esri, the world's largest provider of Geographic Information System software. With this SDK, you're going to be taken on a journey from the basics up to an intermediate level of understanding how to build a complete, professional application by learning the ArcGIS Runtime SDK and Application Programming Interface (API). With ArcGIS Runtime, you can build native, cross-platform mapping apps that can include the ability to display data in 2D and 3D from online or offline data sources, edit online and offline data, online and offline geocoding and routing, conduct spatial analysis, navigation, and so on. What's more is that ArcGIS Runtime comes in several languages, such as .NET (C# and Visual Basic), Java SE, Objective-C, and C++. As a result, you can build highly performant apps and run them natively on Windows, iOS, OS X, Android, and Linux.

With the API, you can build interactive, beautiful maps that you can then sell on the App Store, or make available to users in your organization as part of an Enterprise Mobility strategy, or even embed a map into another app such as a military system. Your users will then be able to access a rich set of content from the cloud (ArcGIS Online or Portal for ArcGIS) or in disconnected mode using offline data that you or your organization has created. As you gain more familiarity with the API, you'll find that it's much easier than previous technologies from Esri and offers new possibilities such as augmented reality, real-time mapping, virtual reality, disconnected analytics, and a whole host of other possibilities.

Although Esri's help for ArcGIS Runtime is great, you'll find that this book offers more. In fact, this book will provide you step-by-step instructions in C# for building an app. Not only that, it shows you how to structure your app using the Model-View-ViewModel pattern, a popular pattern for .NET developers. You will, along the way, learn about 3D mapping and spatial analysis and even how to test your apps using test-driven development and take a deep dive into performance testing. By the time you're done reading this book, you will have all the necessary skills to build an app from beginning to deployment on the selected devices, no matter if it's a laptop, tablet, or smart phone. The reason for this is that the API is nearly identical across all platforms. As a result, what you learn in this book, except for differences in the languages, will for the most part apply to other flavors of ArcGIS Runtime. Learn the API once, and then apply across multiple platforms.

What this book covers

Chapter 1, Introduction to ArcGIS Runtime, introduces you to the world of native mapping apps, where you will learn about the ArcGIS Runtime SDK language options, the history of Esri's developer technologies, native versus web versus hybrid apps, types of mappings apps, ArcGIS Runtime architecture, system requirements, setting up your development environment, and finally, you'll build your first app using a code-behind file approach.

Chapter 2, The MVVM Pattern, takes the app you built in Chapter 1, Introduction to ArcGIS Runtime, and transforms it using a pattern called Model-View-ViewModel. With this pattern, you'll have an app that supports the notion of separation of concern, which makes your app more maintainable, blendable, and testable. The concepts you will learn in this chapter will be expanded on as you walk through the remaining chapters. At the same time, you will explore the ArcGIS Runtime SDK.

Chapter 3, Maps and Layers, introduces you to the MapView class and how to add all the different kinds of layers supported by ArcGIS Runtime. You will learn about projections, MapGrid, scale, overlays, location display for navigation, events, map interactions, map extent, the wide range of supported layers types (dynamic map service, tiled map service, feature services, and so on), the ArcGIS Runtime geodatabase, and so on.

Chapter 4, From 2D to 3D, will introduce you the exciting world of 3D by explaining the importance of 3D, how to navigate in 3D, how to add layers in 3D, adding vertical exaggeration using surface models, MVVM in 3D, and 3D content.

Chapter 5, Geometry and Symbology, will take you down to the fundamental constructs of layers by explaining all of the options you have to create geometry, and then how to symbolize the geometry in your layers. You will learn the difference between mutable and immutable geometry for the MapPoint, envelope, multipart, polyline, polygon, and multipoint geometry, and then explore the GeometryEngine class so that you can do vector operations, such as reprojecting and union. You'll also learn about converting units of measure and area. After geometry is covered, you will then learn about how to symbolize the geometry using simple symbols, renderers, and even military symbols.

Chapter 6, Displaying Information, teaches you how to handle mouse events with MVVM so that you can display information by interacting with the map. You will also learn how to make your maps even more useful by showing a legend, scale bar, label features, create overlays, and showing your current location using a GPS.

Chapter 7, Finding, Querying, and Identifying Features, will introduce you to tasks so that you can find objects in the map, conduct online and offline searching, and interactively discover information in a layer by just clicking on an object (identify).

Chapter 8, Geocoding and Routing, provides you with an understanding of geocoding, which is the process of turning a street address into coordinates. You will learn about online and offline geocoding, finding places using just their name, and then how to route between two or more locations.

Chapter 9, Editing Features, details the differences between online and offline editing, how to prepare data for either online or offline editing, and then how to add, update, and delete features. This chapter also discusses the concept of selection, and finally, committing and syncing edits.

Chapter 10, Spatial Analysis, will introduce you the spatial analysis using ArcGIS Runtime, and then discuss geoprocessing, which allows you to exploit the powerful tools from ArcGIS Desktop or Pro so that you can add powerful analytical capabilities to your app from either ArcGIS Server or locally using a geoprocessing package. You learn, by way of example, how to do line of sight analysis and generate drive-time polygons. Also, you'll learn about synchronous and asynchronous geoprocessing.

Chapter 11, Testing and Performance, will show you how to take the concepts you learned about in the previous chapters with regards to the API and MVVM by showing you how to unit test your app so that you know it works at the most fundamental level. You will also be shown the important of test-driven development using a sample app you developed in an earlier chapter. Lastly, you will take a deeper dive into optimizing your app from the server side if it uses on-premise data sources. You will then get a detailed explanation of how ArcGIS Runtime's high-performance rendering engine works.

Chapter 12, Configuring, Licensing, and Deploying, will finally explain what you will need to consider when configuring your app so that users can make the app look and behave how they need it to, and then discuss what steps you need to take to license your app properly, and finally, the steps required to deploy your app to your users.

What you need for this book

To work through the sample apps in this book, you will need a reasonably good laptop or desktop computer that meets these minimum hardware/OS/.NET requirements:

  • Internet access with a sufficiently fast download speed.

  • 2.2 GHz or higher.

  • Intel Pentium, Intel Core Duo, or Xeon Processor.

  • 1.5 GB of available disk space.

  • 2 GB or higher of RAM. Even more may be required for the chapter on 3D.

  • A graphics card with 64 MB of RAM, 256 MB of RAM is recommend. NVIDIA, ATI, and Intel chipsets are supported.

  • Windows 8.1 Basic, Professional and Enterprise, Windows 7 Ultimate, Enterprise, Professional or Home Premium, Windows 7 SP1 Ultimate, Enterprise, and Professional or Home Edition.

  • .NET 4.5.2, 4.5.1 or 4.5. The sample apps are using .NET 4.5.

  • Visual Studio 2013 (all editions). You can also use Visual Studio Express 2013 for Windows Desktop, Visual Studio 2012 with Update 3 (all editions), and Visual Studio Express 2012 for Windows Desktop and Update 3. Chapter 1, Introduction to ArcGIS Runtime, will show you how to download a free copy of Visual Studio 2013. It's also possible to use Visual Studio 2015, but ArcGIS Runtime does not currently have a project template for that version.

Who this book is for

This book is for you. It will take your through a journey of how to use the API and provide you with enough details so that you can apply these concepts to the other supported languages. However, this book will focus on the .NET version of the SDK because it offers all of the capabilities due to the fact that it runs on a Windows desktop or laptop computer. This book will focus on C# because it is quite popular with the .NET developers and because many long term Esri users have a great deal of experience with previous technologies, such as ArcGIS Desktop and Engine.

This doesn't mean you will only understand the material if you're familiar with Esri's technology. In fact, just the opposite is true. If you're new to Esri technology, you will be introduced to the concepts and then shown where to go to learn more about Esri's platform.

Most of the content was written for new to intermediate developers. However, there are a few cases where more advanced material is presented. This is especially the case if you're new to 3D in Chapter 4, From 2D to 3D, or unit testing and performance testing in Chapter 11, Testing and Performance. When it comes to .NET, you should have a basic understanding of C# and, in particular, of the task parallel library and asynchronous programming in general. You should also understand the basics of Windows Presentation Foundation, with a special emphasis on binding. All the other material will be explained so that you can build a complete native app.

Conventions

In this book, you will find a number of text styles that distinguish between different kinds of information. Here are some examples of these styles and an explanation of their meaning.

A block of code is set as follows:

// create a graphics layer and give it an ID
var graphicsLayer = new Esri.ArcGISRuntime.Layers.GraphicsLayer();
graphicsLayer.ID = "MyGraphicsLayer";

// add the graphics layer to the map
MyMapView.Map.Layers.Add(graphicsLayer);

A block of XAML code will appear like this:

<esri:GroupLayer DisplayName="Basemap Group">
    <esri:ArcGISTiledMapServiceLayer 
        DisplayName="Imagery" IsVisible="False"
            ServiceUri="http://services.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer" />
    <esri:ArcGISTiledMapServiceLayer DisplayName="Street"
        ServiceUri="http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer" />
</esri:GroupLayer>

When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:

USE MyDatabase;
GO
SELECT Name, ProductNumber, ListPrice AS Price
FROM Production.Product 
WHERE ProductLine = 'R' 
AND DaysToManufacture < 4
ORDER BY Name ASC;
GO

New terms and important words are shown in bold. Words that you see on the screen, for example, in menus or dialog boxes, appear in the text like this: "Clicking the Next button moves you to the next screen."

Note

Warnings or important notes appear in a box like this.

Tip

Tips and tricks appear like this.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or disliked. Reader feedback is important for us as it helps us develop titles that you will really get the most out of.

To send us general feedback, simply e-mail , and mention the book's title in the subject of your message.

If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide at www.packtpub.com/authors.

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Downloading the example code

You can download the example code files for this book from https://github.com/rvinc66/ArcGISRuntimeBook.

You can download the example code files for this book from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.

You can download the code files by following these steps:

  1. Log in or register to our website using your e-mail address and password.

  2. Hover the mouse pointer on the SUPPORT tab at the top.

  3. Click on Code Downloads & Errata.

  4. Enter the name of the book in the Search box.

  5. Select the book for which you're looking to download the code files.

  6. Choose from the drop-down menu where you purchased this book from.

  7. Click on Code Download.

You can also download the code files by clicking on the Code Files button on the book's webpage at the Packt Publishing website. This page can be accessed by entering the book's name in the Search box. Please note that you need to be logged in to your Packt account.

Once the file is downloaded, please make sure that you unzip or extract the folder using the latest version of:

  • WinRAR / 7-Zip for Windows

  • Zipeg / iZip / UnRarX for Mac

  • 7-Zip / PeaZip for Linux

Downloading the color images of this book

We also provide you with a PDF file that has color images of the screenshots/diagrams used in this book. The color images will help you better understand the changes in the output. You can download this file from http://www.packtpub.com/sites/default/files/downloads/LearningArcGISRuntimeSDKForNET_ColorImages.pdf.

Errata

Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you could report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/submit-errata, selecting your book, clicking on the Errata Submission Form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded to our website or added to any list of existing errata under the Errata section of that title.

To view the previously submitted errata, go to https://www.packtpub.com/books/content/support and enter the name of the book in the search field. The required information will appear under the Errata section.

Piracy

Piracy of copyrighted material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works in any form on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.

Please contact us at with a link to the suspected pirated material.

We appreciate your help in protecting our authors and our ability to bring you valuable content.

Questions

If you have a problem with any aspect of this book, you can contact us at , and we will do our best to address the problem.