7

How do I fit the Frame (A) of the Map Item exactly to the extent of the Map Canvas (B)?

Example

I have done all of the following:

  1. In Project View, I clicked "Zoom to layer" (specifically, the widest raster layer).
  2. In Print Composer, under the Item Properties tab, specifically Extent, I clicked "Set to map extent."

These together were insufficient to move A to B.

2
  • Welcome to GIS SE! As a new user be sure to take the Tour where you will see that there should be only one question asked per question under our focussed Q&A format.
    – PolyGeo
    Commented Jan 10, 2018 at 21:40
  • Does the view in the print composer change when you click "set to map extent?"
    – csk
    Commented Jan 11, 2018 at 17:43

3 Answers 3

5

Firstly, it seems like the extent of your data and your map in the composer are of different ratios - if you want your data to completely fill up the map item in the composer, you will either end up cutting out some data, or there will be some white space. So you might want to make sure your map item in the composer is more square than rectangular.

You could do this by clicking and dragging the corners of the map item using the Select/Move item tool (third down on the left).

Alternatively, you could set the extents of the map item to the extents of the largest item in your canvas (the raster background, perhaps - right click -> Properties -> Information -> Extent). You could also set the map item extents to a vector layer in your project by using a data defined override with x_min($geometryoflayer) or similar functions. I'm not sure how to do that with raster layers, I think you need custom Python code.

Otherwise I would try changing the scale of the map in the map item and moving around the content until you are satisfied, using the "Move item content" tool on the left hand side (like a map with four blue arrows on it, 4th item from the top). You can click and drag, or use the mouse wheel to increase/decrease scale. For fine tuned scale adjustments go to the Item Properties for the map and try out different scales. Note that your map item needs to be unlocked in the print composer for this to work.

5

Instead of creating a separate item to use as a frame, you can simply add a frame to the map itself. Select the map item, look at the item properties panel and check the box where it says Frame. If you don't have the item properties panel, enable it from View menu > Panels > Item properties. enter image description here

The technical term for a map in the print composer is just map, or map item, or print composer map item. QGIS distinguishes this from the main project map by calling the visible area of the main project map the "map canvas."

If you still want to fit the frame to the map item, manually re-size the frame by dragging the corners. They should automatically snap to the edges of the map when you get close.

2
  • 1
    This is part of my problem. There aren't two separate items in the image I posted, just one. I added a Frame to the Map Item, but the extent of the Map Canvas (B in the image) is smaller than that of the Map Item with Frame (A in the image). If I try to shrink the Map Item to fit the Frame to the extent of the Map Canvas, it rescales the Map Canvas, too.
    – Blake
    Commented Jan 10, 2018 at 21:11
  • Oh, I misunderstood your issue. It looks the same in a screenshot.
    – csk
    Commented Jan 10, 2018 at 21:21
4

If I understand your question correctly, you are adding the frame correctly by selecting the Frame checkbox under the Map item's properties, but you need the map to fill the frame completely. The first thing to check would be the "Extents" section of the map item's properties and click on the "Set to map canvas extent" button to see if that does what you want. If it still does not, verify that the map is filling the canvas in the QGIS application window, as this is what will be displayed in the map item.

3
  • This should do what you want. Make sure the map canvas (in the main project window) is zoomed to the WIDTH of the map content. Then click "set to map canvas extent." Adjusting the height of the map item to fit the content won't change the scale.
    – csk
    Commented Jan 10, 2018 at 21:20
  • In the main project window, does "Zoom to layer" (specifically, the largest raster layer) zoom to the width of the entire map content?
    – Blake
    Commented Jan 10, 2018 at 21:23
  • The "Zoom to layer" will "fit" all of the features in that layer within the map canvas window. Commented Jan 10, 2018 at 22:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.