Monday, February 7, 2011

Customized google maps

You change the look and feel of google maps easily.

Here is a simple example that turns off all labels on the map

map = new google.maps.Map(mapContainer, {}));

var noLabelStyle = new google.maps.StyledMapType([ {
featureType: "all",
elementType: "labels",
stylers: [
{ visibility: "off" }
]
}], {
name: "no_labels_style"
});

map.mapTypes.set('stylename', noLabelStyle);
map.setMapTypeId('stylename');


The most important part is the google.maps.StyledMapType class.
Its constructor expects an array, and that describes which element should be visible and how.

You can find the details documentation in the API reference.

1 comment: