Google Earth API Samples - Styling Placemarks using Style Maps

Last Modified:
06/08/2009
Installed Plugin Version:
...

Relevant Resources:

Relevant Code Excerpt:

// Apply stylemap to a placemark
var styleMap = ge.createStyleMap('');

// Create normal style for style map
var normalStyle = ge.createStyle('');
var normalIcon = ge.createIcon('');
normalIcon.setHref('http://maps.google.com/mapfiles/kml/shapes/triangle.png');
normalStyle.getIconStyle().setIcon(normalIcon);

// Create highlight style for style map
var highlightStyle = ge.createStyle('');
var highlightIcon = ge.createIcon('');
highlightIcon.setHref('http://maps.google.com/mapfiles/kml/shapes/square.png');
highlightStyle.getIconStyle().setIcon(highlightIcon);

styleMap.setNormalStyle(normalStyle);
styleMap.setHighlightStyle(highlightStyle);

// Apply stylemap to a placemark
placemark.setStyleSelector(styleMap);