Adobe Illustrator – Masking using layers with stroke?

I’m working with Google Maps in making a campus map comprised of a number of tile overlays. Two of these overlays- accessibility (paths) and parking- are layered under other elements (with strokes) which help define it’s shape within sidewalks and parking lots:

However, to create their individual tile overlays, I need to export only what is shown of these two layers as seen in the right side of the below image.

My approach up to now:

  1. Make every element layered below the target layer hidden.
  2. Take every element which exists above the target layer and make their fill and/or stroke black as needed. (Essentially making a mask which compensates for the strokes of the other layers. See below image, left.)
  3. Export the file to Photoshop.
  4. Using Magic Wand or Color Selector, remove the black, resulting in the target layer in the desire shape.

This does exactly what I want and fits perfectly in the space, but it is somewhat complex for other users and leaves some evidence behind of the approach- namely, darker pixels at the edges- in the final product (below, right)

*(Note: In the right image, “white” is equivalent to “transparent”.)
All elements over are black (left) and final (right)

Thus, my question is “is there a way to include the stroke in ‘masking’ elements”? For instance, is there a way to make a mask which also includes the stroke on an element rather than just along the drawn path?

Or, perhaps even more fun, is there a way to color/swatch a shape to be “transparent” rather than simply “none” so that it still hides what is below it, but prints/exports as being transparent?

Alternatively, is there any other more simple approach which does not include the following:

  • Combining the render and overlay layers. (Results in 6 overlays rather than 3.)
  • Drawing the overlay layers to perfectly match the sidewalk/lot. (Most higher elements use strokes which are not easily traced, and would be much more work.)

EDIT: Here is an .ai file with a simple arrangement of what I’m working with if anyone would like to play around or get some additional context.


After the comments above, try this.

This is a temporary step to get the export which could then be discarded or undone if needed.


  • Green objects are on their own layer/layers
  • stripe pattern is on its own layer
  • pink/purple/blue paths are on a layer.
  • the black areas in your image above are simply flat shapes, no effects.

If all of this is true…….

Opacity masks

  1. Select all the black objects in your second attached image
  2. Edit > Cut
  3. Select everything on a layer you wish to mask (like the blue
  4. Edit > Paste in Front
  5. Pathfinder > Unite (this creates one compound shape from all the black areas)
  6. Select everything on the layer – stripes and black areas.
  7. In the Transparency Panel, click the Make Mask button
  8. Tick the “inverted” option on the Transparency Panel.

This should leave you with only the visible areas on the fill layers which could then be exported. If the green shapes change later, you would need to go through the steps again, deleting the existing mask and replacing it with a new one.

Once you do these steps a couple times I’m certain you could streamline or even create an action to do most of it. For example – copy green shapes, turn off green layer visibility, select blue layer, paste in front, set fills to black, pathfinder > unite, select all, make mask, export.

Another option…..

Clipping Masks

For this to work, all the green areas much touch each other at some point… any point

  1. Duplicate the green layer
  2. Select all on the duplicate.
  3. Pathfinder > Unite
  4. From the Layer Panel menu, choose Make Clipping Mask
  5. Expand the duplicate layer in the Layers Panel so you can see it’s
  6. Drag all other layers in the Layers Panel below the Clipping Path item in the
    duplicate layer

The primary difference between these two methods is whether or not the green areas are touching each other. The opacity mask allows you to create masks form any number of shapes regardless of where they are or how they interact with each other. The Second, clipping mask, method requires that all shapes be touching and the mask is a single path or compound path.

Opacity masks can even use gradient fills to create graduated masks. Clipping masks are always hard edged, flat, shapes.

Opacity masks work…..

Using your file I had no issue setting up an opacity mask.

New File Download


  1. copy “Buildings”, “Detail Layer”, and “Green” layer contents.
  2. Create a new layer below the three layers listed in #1.
  3. Drag all other layers into this new layer
  4. Click the circle to the right of this new layer’s name on
    the Layer Panel to select the Layer itself
  5. Choose Make Opacity mask from the Transparency Panel menu
  6. Click the black mask box on the Transparency Panel.
  7. Edit > Paste In Front
  8. Object > Expand
  9. Set fill color to black and stroke to “none” (if it’s not “none”
  10. Untick the “Clip” option on the Transparency Panel.

As you can see it’s pretty straight-forward and I don’t really understand where you may have issues with this technique. Not sure where “random spattering” would enter the scenario. You can continually add new sub-layers to the masked layer and the objects will continue to be masked by the shape of the opacity mask. If you need to alter the opacity mask, just click the circle next to it’s name, then click the mask thumbnail on the transparency panel. You can then paste in new objects or remove objects as needed. Just be certain they are filled with black and expanded so any strokes are seen as shapes.

Source : Link , Question Author : Nick Mischler , Answer Author : Scott

Leave a Comment