同じレイヤーに複数の画像を配置するには、次のようなスタイルマップを作成できます
var style = new OpenLayers.StyleMap({
default :new OpenLayers.Style({
'pointRadius': 10,
'externalGraphic': '/images/${icon}.png'
})
})
ここで、「${icon}」は機能の属性です。
次の例では、「スター」と「ホーム」の2つの画像を使用します
var path = new OpenLayers.Layer.Vector( "images" );
//set the styleMap
path.styleMap = style;
map.addLayers([path]);
//create a new feature
var pointHome = new OpenLayers.Geometry.Point(-57.533832,-25.33963);
var featureHome = new OpenLayers.Feature.Vector(pointHome);
//set the icon of the feature
featureHome.attributes["icon"] ="home";
var pointStar = new OpenLayers.Geometry.Point(-57.533371,-25.338946);
var featureStar = new OpenLayers.Feature.Vector(pointStar);
//set the icon of the feature
featureStar.attributes["icon"] ="star";
path.addFeatures([featureHome, featureStar]);