Search code examples
mapkitapple-maps

Getting the bounds of the map in mapkit.js


I can't figure out how to get the bounds of my mapkit.js map like map.getBounds() on google.maps With map.center i get the lat, lng of the center. Also there is a visibleMapRect that returns the following:

origin: g
x: 0.5644154498027297
y: 0.38366011721614135
size: _
height: 0.0038494348475155986
width: 0.0027777777777778763

But i'm not sure its relevant Do i have to calculate this myself? Is there a method to get the 4 corners of my map?


Solution

  • Finally figured it out

    const bounds = map.region.toBoundingRegion();
    

    Returns something like:

    {northLatitude: 38.49474438696218, eastLongitude: 24.190793833126634, southLatitude: 37.41403138384996, westLongitude: 23.190793833126634}