Hi!
Is there any way to display a Google Map (embedded via the Javascript API) in grayscale without losing any other functionality?
Thanks,
DLiKS
Hi!
Is there any way to display a Google Map (embedded via the Javascript API) in grayscale without losing any other functionality?
Thanks,
DLiKS
Apart from writing the good people at Google and asking them to create grey-scale versions of all of their image tiles and an optional API parameter, no.
IE has the filter: gray
directive.
It renders any HTML element in grayscale. JSFiddle here.
You may be able to apply this to the map's parent DIV. It may turn the map it contains in to a grayscale represtenation. I can't say whether this will work without side effects - you'd have to try. But it's well possible.
IE only, though, but supported since Version 4.
Other than that, I think there is a Flash API for Maps, isn't there? It might be easier to achieve there.
Yes, in V3 of the api they have introduced StyledMaps
.
They've even provided a tool for you to generate the code for the styles you like. Slide the "Saturation" all the way down and you've got grayscale going on!
The following example displays a grayscale map of Brooklyn:
var map;
var brooklyn = new google.maps.LatLng(40.6743890, -73.9455);
var stylez = [
{
featureType: "all",
elementType: "all",
stylers: [
{ saturation: -100 } // <-- THIS
]
}
];
var mapOptions = {
zoom: 11,
center: brooklyn,
mapTypeControlOptions: {
mapTypeIds: [google.maps.MapTypeId.ROADMAP, 'tehgrayz']
}
};
map = new google.maps.Map(document.getElementById("map_canvas"), mapOptions);
var mapType = new google.maps.StyledMapType(stylez, { name:"Grayscale" });
map.mapTypes.set('tehgrayz', mapType);
map.setMapTypeId('tehgrayz');