How to implement mapView.visibleArea().contains(graphic)?

712
1
05-23-2017 01:29 PM
NikolayYekimov1
New Contributor III

v10.2.5 had an ability to tell if the mapView contains a graphic:  mapView.visibleArea().contains(graphic.geometry.envelope.center). In v 100.0 there is no contains method for 

mapView.visibleArea which is AGSPolygon. It's easy to just take a polygon and start comparing xmin xmax ymin ymax, the caveat is to do it with respect to rotation angle. Any ideas? 

Tags (1)
0 Kudos
1 Reply
MarkDostal
Esri Contributor

Thank you for your question!  Take a look at the AGSGeometryEngine class.  That has a method "geometry:containsGeometry", which should do what you want:

guard let visibleArea = mapView.visibleArea else { return }

guard let graphicCenter = graphic.geometry?.extent.center else { return }

let isGraphicInMapView = AGSGeometryEngine.geometry(visibleArea, contains: graphicCenter)