OpenLayers 3中的图标阴影标记

时间:2014-12-13 11:54:30

标签: openlayers-3

在OpenLayers 3中,是否有任何优雅的方法可以将阴影标记添加到图标循环中? 我正在努力为ol3中的图标添加阴影......并且没有关于此事的一致材料。

1 个答案:

答案 0 :(得分:0)

尝试(使用示例样式):

    var iconStyle = new ol.style.Style({
        image: new ol.style.Circle({
            radius: 10,
            snapToPixel: false,
            fill: new ol.style.Fill({
                color: 'rgba(77,135,254,0.4)'
            })
        }),
        zIndex: 1
    });

   var shadowStyle = new ol.style.Style({
        stroke: new ol.style.Stroke({
            color: 'rgba(0,0,0,0.5)',
            width: 6
        }),
        zIndex: 0
    });

   iconFeature.setStyle([iconStyle, shadowStyle]);

然后:

        var iconSource = new ol.source.Vector(); // create an empty source 

        var icon = new ol.geom.Point( 
            // your point
        );

        var iconFeature = new ol.Feature({ // create a feature
            geometry: icon
        });

        iconSource.addFeature(iconFeature); // add the feature to the source

        var iconLayer = new ol.layer.Vector({ // create a layer with that source
            source: iconSource
        });
        map.addLayer(iconLayer); // add the layer to the map
相关问题