[OpenLayers-Users] Destroy/Delete a vector feature
Eric Lemoine
eric.c2c at gmail.com
Wed Dec 17 02:09:21 EST 2008
On Tue, Dec 16, 2008 at 11:04 PM, Yves Moisan <yves.moisan at boreal-is.com> wrote:
>
>> The state of features read from your web service is null, isn't it? Do
>> you really need it to be "unknown"?
>
> You are right. I got it almost working. If only I could assign a style
> to feature.state = null, I'd be done
>
> var lookup = {};
> @@ lookup["null"] = {fillColor: "blue"}; @@
> lookup[OpenLayers.State.UNKNOWN] = {fillColor: "blue"};
> lookup[OpenLayers.State.UPDATE] = {fillColor: "green"};
> lookup[OpenLayers.State.DELETE] = {fillColor: "red"};
> lookup[OpenLayers.State.INSERT] = {fillColor: "orange"};
How about something like that:
var styleMap = new OpenLayers.StyleMap();
// create a styleMap for the vector layer so that features
// have different styles depending on their state
var context = function(feature) {
return {
state: feature.state || OpenLayers.State.UNKNOWN
};
};
var lookup = {};
lookup[OpenLayers.State.UNKNOWN] = {fillColor: "blue"};
lookup[OpenLayers.State.UPDATE] = {fillColor: "green"};
styleMap.addUniqueValueRules("default", "state", lookup, context);
--
Eric
More information about the Users
mailing list