Forum Xamarin.iOS

Visible Map rectangle coordinates


How i can get the lat/long coordinates of visible rectangle of a Map ?


Best Answer


  • ColeXColeX Member, Xamarin Team Xamurai

    Do you mean Polygons on the map ?

    Which coordinates do yo want ? The four corner of the rectangle ?

  • DominicBeauprDominicBeaupr CAMember ✭✭
    I need the coordinates of the viewport rectangle. I want to display only the markers and polylines in this area.

  • ColeXColeX Member, Xamarin Team Xamurai

    You need to know the exact position(rectangle) on the map , so you could get the coordinates by tapping on the map , refer the solution for this .

  • DominicBeauprDominicBeaupr CAMember ✭✭
    edited November 2019

    I dont need to have the tapped coordinates, i need to get the four corners coordinates of the visible rectangle to be able to add only the polylines and markers include in this rectangle. Also i have some detection features where i also need to detect only the markers and polylines that user actually see. I'm not using Xamarin Forms but Xamarin iOS.

    More something like this :

    Thanks for your help

  • DominicBeauprDominicBeaupr CAMember ✭✭
    edited November 2019

    I tried this and it's working. Is there a better or quickest way ?

       var rect = mapView.VisibleMapRect;
       var nw = new MKMapPoint(rect.MinX, rect.MinY);
            var ne = new MKMapPoint(rect.MaxX, rect.MinY);
            var se = new MKMapPoint(rect.MaxX, rect.MaxY);
            var so = new MKMapPoint(rect.MinX, rect.MaxY);
            var nwPoint = MKMapPoint.ToCoordinate(nw);
            var nePoint = MKMapPoint.ToCoordinate(ne);
            var sePoint = MKMapPoint.ToCoordinate(se);
            var soPoint = MKMapPoint.ToCoordinate(so);
            var pinNw = new MKPointAnnotation(nwPoint, "nwPoint", "nwPoint");
            var pinNe = new MKPointAnnotation(nePoint, "nePoint", "nePoint");
            var pinSe = new MKPointAnnotation(sePoint, "sePoint", "sePoint");
            var pinSo = new MKPointAnnotation(soPoint, "soPoint", "soPoint");


Sign In or Register to comment.