-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Convert mapview points to location coordinates #2
Comments
Hi Sandeep. Firstly, this is probably a much better question for the official ArcGIS Runtime for iOS forum, but I'm happy to help you here. In your example, you are getting the top-left and bottom-right points in map coordinates. You can do this using the AGSEnvelope *mapCoordsExtent = self.mapView.visibleAreaEnvelope;
AGSEnvelope *latLonExtent =
[[AGSGeometryEngine defaultGeometryEngine] projectGeometry:mapCoordsExtent
toSpatialReference:[AGSSpatialReference wgs84SpatialReference]];
NSPredicate *pred = [NSPredicate predicateWithFormat:@"latitude <= %f AND longitude >= %f AND latitude >= %f AND longitude <= %f",
latLonExtent.ymax, latLonExtent.xmin,
latLonExtent.ymin, latLonExtent.xmax]; Note that if you want to translate Map coordinates in the
For what it's worth, if I were doing this, I would probably create a category on Let me know if this helps, Nick. |
Thanks Nick. I will let you know about this solution. Regards, |
Hey Nick, Its not exactly same as MKMapView co-ordinates. But its manageable. AGSMapView coordinates---------> 51.330850 :: 8.978842 :: 48.330850 :: 13.046838 Thank You Very Much for your solution. Regards, |
Glad I could help. While the coordinates are close enough, I'm intrigued by the discrepancy. How are you setting the extent of the initial map for the AGSMapView (and likewise, how are you setting it with an MKMapView)? Cheers, Nick. |
Hi Nick, Here is the zoom extent for AGSMapView:
and for MKMapView: Thanks, |
Thanks Sandeep. Any reason you're using different widths and heights for MKMapView and AGSMapView code? That would explain some of the difference. You're also declaring a 3x3 degree minimal coverage area in the AGSMapView code and an coverage of 2.3x1.7 degrees for the MKMapView. Nick. |
There is no reason. I want to use same degrees used for MKMapView in AGSMapView. May be this will give correct results: AGSEnvelope *envelope = [AGSEnvelope envelopeWithXmin:(11.012840 - 1.7) Please correct me if I am wrong. Thanks |
Not quite. X is longitude, Y is latitude. Also (and I haven't used MKMapView) I think you would have to halve the deltas on AGSMapView. The MKMapView documentation seems to say the span is full width and height so when calculating edges around the center-point you'll want to use 1.15 and 0.85 instead of 2.3 and 1.7. Like I said, I'm not familiar with MKMapView though. Let me know if that works. N |
Hi Nicholas,
How to convert screen points to location coordinates using AGSMapView?
There are couple of methods available in MKMapView for converting these:
Please tell me is there are any equivalent methods to achieve the same.
My context is that:
This is my code:
CLLocationCoordinate2D topCord = [self.mapView convertPoint:self.mapView.frame.origin toCoordinateFromView:self.mapView];
CLLocationCoordinate2D bottomCord = [self.mapView convertPoint:CGPointMake(self.mapView.frame.origin.x + self.mapView.frame.size.width, self.mapView.frame.origin.y + self.mapView.frame.size.height)
toCoordinateFromView:self.mapView];
NSPredicate *pred = [NSPredicate predicateWithFormat:@"latitude <= %f AND longitude >= %f AND latitude >= %f AND longitude <= %f", topCord.latitude,topCord.longitude,bottomCord.latitude,bottomCord.longitude];
where self.mapView is kind of MKMapView. This is giving proper results.
How to achieve the same using ArcGIS API's?
Please help me in this scenario. Waiting for your kind reply.
Regards,
Sandeep
The text was updated successfully, but these errors were encountered: