Google Maps in Grayscale

后端 未结 8 625
误落风尘
误落风尘 2021-01-30 05:01

Is there any way to display a Google Map (embedded via the Javascript API) in grayscale without losing any other functionality?

8条回答
  •  温柔的废话
    2021-01-30 05:56

    Just use CSS3 grayscale() filter effect for the Google maps iframe element! It works because the js code prints images.

    iframe { 
      -webkit-filter: grayscale(100%);
      -moz-filter: grayscale(100%);
      -ms-filter: grayscale(100%);
      -o-filter: grayscale(100%);
      filter: grayscale(100%);
      filter: url(grayscale.svg); /* Firefox 4+ */
      filter: gray; /* IE 6-9 */
    }
    

    Try also to target only the background images by applying this to the very first div element under the div.gm-style (or any other wrapper). I don't know if Google changes the dom structure often but at the moment speaking (25 Nov 2014) this works fine.

    iframe .gm-style > div:first-child {
      // Same code here
    }
    

提交回复
热议问题