[GIS] Is it possible to gray out a Google Maps map except for some area

areagoogle mapskmlpolygonregion

What i am looking for is a way to emphasize a certain area on a Google Maps map by graying out the rest of the world.

I heard about some solution of using 2 polygons of which 1 is visible and the other not and that it only works if the map is static (no map movement). However i want the user to be able to zoom and drag the map.

I am also interested in other ways i haven't thought of to emphasize an area.

update:

When i try the solution posted by radek (i.e. creating a KML with a Polygon with an outerBoundaryIs (bigger than view) and an innerBoundaryIs (being area to emphasize)) I get the problem that when i zoom in, rectangular areas are not covered by the surrounding polygon anymore. See:

enter image description here

Anyone with experience/solution to that?

update2:

I finally had time to test radek's solution using Google Fusion Tables. At first i had the same issues with missing tiles as with KML (see picture above), but after another load it seems like it had picked up and it was showing the tiles totally correct. I have a feeling that the jquery hack in his solution was meant for tiles that weren't loading:

setTimeout(function(){ 
        $("img[src*='googleapis']").each(function() { 
            $(this).attr("src",$(this).attr("src")+"&"+(new Date()).getTime()); 
        }); 
    }, 5000);

As the tiles seemed to load after a refresh i haven't used the hack myself. If the bug happens for every new user I will experiement with it.

Best Answer

Google Maps Mania blog points to example of Swiss Administrative Boundaries Map:

enter image description here

The code from Vasile is on github.