var lon = -140.9; var lat = 63.391; var found = l.Graphics.Any(g => g.Geometry is MapPoint && Math.Round((g.Geometry as MapPoint).X, 1) == lon && Math.Round((g.Geometry as MapPoint).Y, 3) ==lat);
I have a map where I have a bunch of graphics displayed on a graphics layer. I need to add some new graphics but I don't want to add to a lat/long combination that already has one. Is there any method/function that can do this for me? If not, any suggestion on what is the most efficient way to find out this information?Thanks!
There's no method that checks if lat/lon already exist, but you can use Linq query to do that:The following code checks if any graphic with x/y value exist. Note that the precision need to match in order for this function to return true. var lon = -140.9; var lat = 63.391; var found = l.Graphics.Any(g => g.Geometry is MapPoint && Math.Round((g.Geometry as MapPoint).X, 1) == lon && Math.Round((g.Geometry as MapPoint).Y, 3) ==lat);
Angemeldete Mitglieder können Beiträge verfassen, Updates folgen und mehr. Neu hier? Registriere ein kostenloses Konto.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.