[OpenLayers-Users] GeoJSON layer and modifyFeature control
Eric Lemoine
eric.c2c at gmail.com
Fri Dec 5 00:54:04 EST 2008
On Thu, Dec 4, 2008 at 11:25 PM, Adorian Ardelean <mynature at gmail.com> wrote:
> Hi Alexandre,
>
> No. This is very similar to what I had initially except adding "select"
> style to stylemap. At click on feature, the select style is applied, but no
> edit of vertex is possible (no drag-able circles appear on vertexes).
>
> So I can make the layer editable by adding rule, but unfortunately paying
> with loss of context styling. Context styling works ok with your example and
> what I had in hand initially. If I could only include context inside rule
> somehow :-).
>
> var styleMap = new OpenLayers.StyleMap();
>
> var rules = [new OpenLayers.Rule({
> symbolizer: template,
> context: context,
> elseFilter: true
> })];
> styleMap.styles["default"].addRules(rules);
>
> It is midnight here, I will push on it tomorrow again. Thank you all for
> your kind help!
I added the code below to the modify-feature.html example and it
worked for me (code is based on Alexandre's):
var tpl = {
pointRadius: "${radius}",
fillOpacity: 0.4,
strokeColor: "#000000",
strokeWidth: 2
};
var ctx = {
context: {
radius: function(feature) {
return 10;
}
}
};
var oStyle = new OpenLayers.Style(tpl, ctx);
var oStyleMap = new OpenLayers.StyleMap({
"default": oStyle,
// works w/ or w/o the following
"select": new OpenLayers.Style({
fillColor: "#66ccff",
fillOpacity: 0.2,
strokeColor: "#3399ff"
})
});
var aoTypeColor = {
'1': {fillColor:"blue"},
'2': {fillColor:"red"},
'3': {fillColor:"yellow"},
'4': {fillColor:"white"}
};
oStyleMap.addUniqueValueRules("default", "Type", aoTypeColor);
oStyleMap.addUniqueValueRules("select", "Type", aoTypeColor);
var rules = [
new OpenLayers.Rule({
symbolizer: tpl,
context: ctx,
elseFilter: true
})
];
oStyleMap.styles["default"].addRules(rules);
oStyleMap.styles["select"].addRules(rules);
--
Eric
More information about the Users
mailing list