0

I am trying to set an individual Frame which defines the visible area of the Map.

Currently all the annotations are shown with mapView.showAnnotations but they aligned to fit in the whole iPad screen view. So they are partially hidden by Floating UI Elements (Green). Also the center of the screen is aligned to be the center of the iPad screen.

current ipad view

What I try to accomplish: I want something like a defined rectangle inside the Map to be the only regarded area in the map. But the Map itself (blue) shall still be shown behind the UI Elements.

goal ipad view

I thought it would be able to accomplish this by using setVisibleMapRect but when I ever I try to use this it does not take any effect. Is setVisibleMapRectactually the needed method to solve this problem?

PRSHL
  • 1,359
  • 1
  • 11
  • 30

2 Answers2

1

The actual answer I found out later is defining

mapView.layoutMargins = UIEdgeInsets(top: X, left: X, bottom: X, right: X)

so the map wont use the space defined by the margin

PRSHL
  • 1,359
  • 1
  • 11
  • 30
1

For others finding this via google, looking for a solution with MapKit JS:

In MapKit JS, the property to modify is called padding:

var map = new mapkit.Map("map");
    
// When showing the translucent side panel, shift the map content a little to the right.
if (window.innerWidth >= 768) {
  map.padding = new mapkit.Padding({top: 0, left: 600, bottom: 0, right: 0})
}

Documentation: mapkit.Padding

demo on iPad

fiedl
  • 5,667
  • 4
  • 44
  • 57