[OpenLayers-Users] Styling a GeoJson vector layer with a stylemap
by value
John Cole
jcole at solidearth.com
Wed Jan 18 11:36:21 EST 2012
Hey guys,
I'm trying to use a stylemap on a GeoJson datasource, and want to change
the color of the symbol based off of a field in the data.
My data looks like:
{
"type" : "GeometryCollection",
"geometries" : [{
"type" : "Point",
"_id" : {
"code" : "123",
"version" : 0
},
"coordinates" : [-86.586502, 34.731189],
"Status" : "W"
}, {
"type" : "Point",
"_id" : {
"code" : "234",
"version" : 0
},
"coordinates" : [-86.57294326, 34.73563314],
"Status" : "W"
}, {
"type" : "Point",
"_id" : {
"code" : "456",
"version" : 0
},
"coordinates" : [-86.45717254, 34.82754903],
"Status" : "A"
}
]
}
and my style stylemap:
var styleMap = new OpenLayers.StyleMap({
"default": new OpenLayers.Style({
fillOpacity: 0.5,
pointRadius: 5,
fillColor: "#ee9900"
})
});
var lookup = {
"S": {fillColor: "red"},
"A": {fillColor: "green"},
"X": {fillColor: "blue"}
};
styleMap.addUniqueValueRules("default", "Status", lookup);
However, when I apply the addUniqueValueRules, no features are drawn.
Tracing through the draw cycle,
line 117 of Comparison.js which is getting the value of "Status" from the
context returns undefined. What do I need to do to get the "Status" into
the correct context?
Thanks,
John
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20120118/91ad94c7/attachment-0001.html
More information about the Users
mailing list