Skip to content

Instantly share code, notes, and snippets.

@piscis
Created February 17, 2015 15:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save piscis/0ec630e3a080de5975b1 to your computer and use it in GitHub Desktop.
Save piscis/0ec630e3a080de5975b1 to your computer and use it in GitHub Desktop.
....
features = [List-with-FeaturePoints-generated-on-the-client]
vectorSource = new ol.source.GeoJSON(({
"object":
"type": "FeatureCollection"
"features": features
}));
vectorLayer = new ol.layer.Image({"source": new ol.source.ImageVector(
source: vectorSource
style: (feature) ->
prop = feature.getProperties();
fillColor = prop.color
if !fillColor
ft = [0,0,0,0]
else
ft = fillColor.split("(")[1].split(")")[0].split(",")
ft.push(1)
baseStyle = {
fill: new ol.style.Fill({
color: "rgba(#{ft[0]},#{ft[1]},#{ft[2]},#{ft[3]})"
})
stroke: new ol.style.Stroke(
color: "rgba(#{ft[0]},#{ft[1]},#{ft[2]},#{ft[3]})"
width: 1
)
}
if prop.line > 0
baseStyle.stroke = new ol.style.Stroke(
color: "#333"
width: prop.line
)
return [new ol.style.Style(baseStyle)]
)});
_that._clearLayerGroup('gridlayer')
targetGroup.getLayers().push(vectorLayer)
....
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment