Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can we know that map Coordinates are in current region or not in current region?

I am working on map view app.I want know that how we can identify that coordinates are in my current region(Map region that bound with screen) or outside of it.

Thanks In Advance.

like image 340
Nitin Avatar asked Oct 09 '22 19:10

Nitin


1 Answers

You have different options. You can see this sample code from apple: Regions. That, has I understand, check the device position by the antenna's position.

Or tracking device position, and check if is inside a region defined by You. Check this question

If you find a better solution, please let me know.

EDIT:

To check if a coordinate is visible in the map try using this:

// Your coordinates - Lisbon for example
float lisbonLatitudeValue = 38.7069320;
float lisbonLongitudeValue = -9.1356321;

CLLocationCoordinate2D lisbonCoordinates = CLLocationCoordinate2DMake(lisbonLatitudeValue, lisbonLongitudeValue);

if (MKMapRectContainsPoint(mapView.visibleMapRect, MKMapPointForCoordinate(lisbonCoordinates)))
{
    // do something
    NSLog(@" - Lisbon is visible");
}
else {
    // do something
    NSLog(@" - Lisbon is not visible");
}

Hope it helps

like image 135
Frade Avatar answered Oct 13 '22 01:10

Frade