Visible Map rectangle coordinates

Hi,

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

Thanks

Best Answer

Answers

  • 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.

    Thanks
  • 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 26

    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 : http://www.softwarepassion.com/how-to-get-geographic-coordinates-of-the-visible-mkmapview-area-in-ios/

    Thanks for your help

  • DominicBeauprDominicBeaupr CAMember ✭✭
    edited November 26

    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");
    

    Thanks

Sign In or Register to comment.