Book Image

ArcGIS By Example

By : Hussein Nasser
Book Image

ArcGIS By Example

By: Hussein Nasser

Overview of this book

Table of Contents (17 chapters)
ArcGIS By Example
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Finding and highlighting the closest tower


We know how to add a point on the map and we also know how to find the distance between two points. What remains is finding the closest tower to the cell phone we are adding on the map. To do that, we need to find the distance between the point we are adding and all the towers. Compare all the distances and the shortest distance is the closest to the point. We will then get the tower name and display it as a message. Later, we will learn how to use the display object to highlight and flash that tower.

Finding the closest tower

To find the closest tower, we need to loop through all towers and run the same proximity code. While looping, we will take note of the shortest distance and save the corresponding ObjectID. If we found a shorter distance, we will update ObjectID and that will be our closest tower:

  1. Open our TelZaViBa project from the C:\ArcGISByExample\telzaviba\Code if you have closed it.

  2. Double-click on tlFindClosestTower to edit it.

  3. Delete all...