You can't shade buildings on Google Maps itself, and the Maps JavaScript API has no "fill this building" switch. What you can do is draw a filled polygon over the building footprint using the Maps JavaScript API, or place a tinted image overlay on a map you control. The usual source for accurate outlines is the Google Maps Data layer, which exposes building footprints as clickable features. Shading is client-side rendering, so it never edits Google's base map for other users.

That distinction decides your whole approach. "Shading buildings in Maps code" usually means one of three things: highlighting buildings in a custom web map built on the JavaScript API, overlaying simple footprints in code, or coloring building polygons in a GIS tool. The steps below cover the first two, which are the ones that involve actual Maps code.

What "Shading a Building" Can and Can't Do in Maps

Google's consumer products give you no document layer. My Maps lets you draw shapes by hand, but it isn't code and won't auto-trace buildings. In a custom application, though, you control the canvas, so a filled shape over a footprint is a straightforward feature.

Three constraints apply:

The Data layer only shares what Google publishes. Building footprints are available at detailed zoom levels in many regions but not everywhere, and not uniformly. Don't assume a footprint exists; test in the target area. Base-map styling is separate. If you're using the map ID styling system (vector maps, cloud-based styling), you can dim or recolor the whole base map, but you can't tint an individual building through style rules on the standard map in the same fine-grained way you can with your own polygon. Privacy and scale. The API terms govern what you may display and cache, and drawing thousands of filled polygons degrades performance. For large building sets, a server-rendered tile layer is the right tool, not per-building loops in the browser.

If your building isn't in the Data layer, or your use case needs building interiors rather than a highlight, you're outside what these APIs support. A photorealistic 3D map or street-level imagery doesn't expose a per-building fill property you can drive from code.

Prerequisites Before You Draw

Set these up first, because the code won't run without them:

1: An API key with the Maps JavaScript API enabled. Create it in the Google Cloud console, restrict it to your authorized domains, and set billing alerts. The Maps JavaScript API requires a billing account. 2: A page that loads the loader script with your key and the current version. Loading is asynchronous; everything below runs inside the resolved promise. 3: Accurate coordinates. Either obtain building geometry from the Data layer at runtime, or bring your own polygon paths from a licensed survey or data provider. Don't eyeball corners from a screenshot. 4: A test location where footprints are published at high zoom, so you can tell a coding bug from missing data.

Confirm each step produces the expected result before moving on. If the map doesn't appear at all, the problem is in step 1 or 2, not in the drawing code.

Option 1: Highlight the Building's Own Footprint via the Data Layer

This is the closest thing to "shading a building" without bringing your own geometry: the Data layer supplies published footprints, and you color the clicked one. Here's the ordered procedure.

1: Create the map with the Data layer enabled by passing the FeatureLayer option when the map is constructed. Without it, the Data layer won't populate. 2: Bind a click listener to the Data layer. The event object carries the clicked feature in event.feature. 3: Read the geometry type in the feature. If it's a polygon, the feature has its footprint; if it isn't, bail out without styling. 4: Reset previous highlights first. Keep a reference to the feature you styled last and set its style back to the default, so you don't paint the whole neighborhood one click at a time. 5: Apply a style to the clicked feature only. Plain colors for fill and stroke are simplest; a dashed stroke can mark the boundary. Expect the footprint to read as a translucent tint rather than an opaque block—choose opacity so sat imagery and roads stay legible. 6: Verify by clicking several buildings in a row. The tint should move from feature to feature, and the underlying map should remain unchanged for anyone else viewing it.

The check for success is behavioral, not visual: exactly one building tinted at a time, and no styling applied to area labels or roadway features when you click them. If clicking a road tints something, your event handler isn't gating on polygon geometry.

Three practical notes. If a click returns no feature, zoom in and try again; footprints appear only at sufficient zoom. If clicks return nothing at all in a region, that's a data-availability limit, not a bug. And be aware the Data layer can include points of interest and other non-building features depending on your configuration options—filter by geometry if you need buildings only.

Option 2: Draw Your Own Filled Polygon When You Have Coordinates

When the footprint is absent from the Data layer, or your geometry comes from your own source, you draw the shape yourself. Prerequisites are the same key and loader setup, plus a clean array of loops.

1: Assemble the paths as an array of loops, each loop a list of latitude/longitude literals. Plan for holes if you're tracing a courtyard or an atrium: an inner loop ordered opposite the outer one produces a cutout instead of a solid blob. 2: Confirm your winding and coordinate order. Mixing longitude-first and latitude-first order is the most common silent failure; the polygon appears somewhere unexpected or vanishes. 3: Construct the polygon with your paths and a stroke option, and set clickable deliberately if the polygon should respond to clicks. 4: Set the fill color and opacity. Use a consistent color code across your data so shading means something, and pick opacity that survives overlaying roads and labels. 5: Add it to the map and pan around to confirm it sits on the building, not the parking lot next door. 6: Check the shape at two zoom levels. A polygon that looks right at city scale can be visibly offset at block scale if coordinates were captured from a mismatched imagery vintage.

Success is easy to overclaim, so be rigorous about two checks. First, do the overlay corners sit on the imagery corners at maximum useful zoom? Second, does the fill stay translucent when the base map switches to satellite view? If the tint becomes unreadable on satellite, raise the opacity slightly or drop the fill and keep only a thick stroke.

For multiple buildings—a portfolio or a downtown block—the same construction repeats per footprint. Keep a registry of polygons so you can recolor or remove them programmatically instead of accumulating stale overlays as users navigate.

A Simpler Alternative: A Pre-Rendered Tinted Overlay Tile

If all you need is a static shaded footprint on a map you control, don't draw polygons at all.

1: Produce a transparent PNG of the building footprint, colored as you want, aligned to geographic coordinates. 2: Add it as a ground overlay on the map, positioning it with the bounds you supply. 3: Check the alignment against satellite imagery at high zoom, adjusting the bounds until edges match.

This works when the footprint is fixed and the map is yours. It won't survive a redesign of imagery, doesn't update, and can't be toggled per-building at runtime the way polygons can, but it's dramatically less code. A web tool such as georeferencing software or a map-rectifier will generate the bounds for you; that part is outside Maps code, and you should verify the corner coordinates against known landmarks rather than trusting the tool blindly.

What a Building Style Property Would Require

The most common misuse of the request is the belief that a JavaScript API method like setOptions or a style rule can fill a base-map building. A single building is not a styleable DOM element on the standard map. The style options you can change (on the underlying map or the map ID styling configuration) act on map-wide categories, not one footprint—so use your own polygon for per-building shading, and reserve base-map styling for dimming the whole backdrop behind it.

Tooling-specific paths exist for GIS work, where the same footprints from a building layer are rendered as filled symbols natively. Those tools deserve their own tutorial; the underlying principle in browser code is unchanged: get geometry, style it with a fill color and opacity, add it.

Verifying Your Shading Render Correctly

The failure modes cluster predictably, so test for them in order.

Nothing appears. Check the API key and the loader promise first; a script error in the key setup usually logs a specific message to the console. A shape appears in the wrong place. Re-check coordinate order and the winding of inner loops. Clicks do nothing. Ensure the Data layer was enabled in the map options and that the click listener is attached to the layer, not the base map object. The map is slow. Count your overlay objects. Drag-heavy polygon layers should be simplified before rendering; for thousands of buildings, draw them server-side into tiles. The tint is invisible over satellite. Test the stroke-only variant before chasing the fill. The shape doesn't match what you expected. Confirm the footprint actually exists in the published data for that location and zoom; if it doesn't, the correct fix is supplying your own geometry, not tuning the style.

Once these pass at your test coordinates, spot-check one location in a different region. Building data availability varies geographically, and an approach that works downtown in one city may return nothing elsewhere.

Limits, Costs, and the Version You're On

Two limits are worth stating plainly because they invalidate naive plans. First, no amount of client-side code will make your shade visible to other Google Maps users, because you're styling your own map instance, not the shared base map. Second, the Data layer only returns what Google publishes; anything else needs your own geometry.

Costs come from the Maps JavaScript API's usage-based billing, which requires a billing account and applies per-dynamic-map-load (or per-1000 dynamic maps). The exact rates change and depend on your cloud account and map-styling configuration, so check the current pricing page in the Google Cloud console before budgeting. The Data layer itself doesn't add a separate line item, but the dynamic map it renders on does.

Versions matter too. Google has been shifting map rendering toward vector and web-map-based styling, and functionality in the JavaScript API and the newer web components can differ. If a tutorial uses the older Maps API loader pattern or deprecated classes, the code may fail outright. Verify the current official samples for your version before adapting code, and check exact method availability in the console, since you can't rely on a blog snippet from a prior version.

Choosing Between the Two Code Paths

Decide with one question: do you already have reliable geometry?

You don't, and the building is likely published: use the Data layer and highlight the clicked feature. Less code, but you're limited to what Google has, and the highlight only exists for user clicks unless you attach it to a search or selection event. You do, or you need persistent shading: construct polygons from your coordinates. More work, full control, and it works where footprints are missing—provided your geometry is accurate. You only need one static tint: use a ground overlay from a transparent image.

For most interactive cases, the polygon path is the durable one. Styled shapes survive restyling and zooming without re-deriving geometry, and they can be exactly the color your design calls for, including a translucent fill that keeps labels readable. The Data layer path is the quick one for a highlight-on-click prototype.

A note on the size of the population you're serving: a handful of overlays is free of visible cost, but a dense overlay layer on a low-end phone will stutter. In that case, cap overlays to the viewport and remove those that pan out of range—this is a rendering discipline, not an API requirement.

FAQ

Can I shade a building in regular Google Maps, the site or app?

No. The consumer map gives you no code layer. You can annotate in My Maps, but it doesn't auto-trace buildings, and shading requires your own custom map.

Does the building I want show up in the Data layer?

Only if Google publishes footprints there for that location and you've zoomed in enough. Test with a few launches; if clicks return nothing, provide your own geometry.

Can a style rule recolor one building across the whole map?

Not on the standard base map—style rules work on categories of features, not a single footprint. Per-building shading requires your own polygon.

Will my shaded building be visible to anyone else?

Only to users of your own application with your key and code. The Google Maps base map isn't modified for anyone else.

How do I tint a building with a hole, such as a courtyard?

Include the inner loop as a separate path in the polygon and order it opposite the outer loop. Rather than tuning colors, verify the geometry.

What if I need many buildings tinted at once?

Pre-render the overlay as tiles on the server instead of looping polygons in the browser; per-building overlays will slow panning. Match any offering to how you'll render it.