[OpenLayers-Users] GeoJSON layer and modifyFeature control
Alexandre Dube
adube at mapgears.com
Thu Dec 4 14:11:11 EST 2008
Hi,
Maybe this can helps.
var oStyle = new OpenLayers.Style({
pointRadius: "${radius}",
fillOpacity: 0.4,
strokeColor: "#000000",
strokeWidth: 2
}, {
context: {
radius: function(feature) {
return Math.min(feature.attributes.count, 10)*2 + 13;
}
}
});
var oStyleMap = new OpenLayers.StyleMap({
"default": oStyle,
"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);
Cheers,
Alexandre
Adorian Ardelean wrote:
> Hi Eric,
>
> No...it is not working yet. There is some improvement indeed: I can
> see now the selection style, but vertexes are still not editable.
>
> I have tried to adapt the suggestion in post I have mentioned earlier.
>
> var styleMap = new OpenLayers.StyleMap();
>
> var rules = [new OpenLayers.Rule({
> symbolizer: template,
> elseFilter: true
> })];
> styleMap.styles["default"].addRules(rules);
>
> Using this the edit polygon works!!!. However, I did not figured out
> how to include "context" within this. Select style is also not visible
> (but I do not mind this, I can most probably find a work around for
> selection style).
>
> Initially I have used:
> var mystyle = new OpenLayers.Style(template, {context: context});
> var styleMap = new OpenLayers.StyleMap(mystyle);
> And context worked fine.
>
> Any hints on how to include context with rules?
>
> Thank you,
> Adorian
>
>
>
> On Thu, Dec 4, 2008 at 5:58 PM, Eric Lemoine <eric.c2c at gmail.com
> <mailto:eric.c2c at gmail.com>> wrote:
>
> Hello
>
> Try:
>
> new OpenLayers.StyleMap({
> "default": yourStyle
> });
>
> Hope this helps,
>
> Eric
>
> 2008/12/4, Adorian Ardelean <mynature at gmail.com
> <mailto:mynature at gmail.com>>:
> > Hi again,
> >
> > I have eliminated also the context for style as a source of
> problem for the
> > modifyFeature control not working. So it seems that just by
> specifying a
> > styleMap as option when declaring the vector layer makes the
> modifyFeature
> > control not functional.
> >
> > var template = {
> > fillOpacity: 0.6,
> > fillColor: "red",
> > strokeColor:"orange",
> > strokeWidth:"1"
> > };
> >
> > var mystyle = new OpenLayers.Style(template);
> >
> > var regions = new
> OpenLayers.Layer.Vector("regions",{extractAttributes:true,
> > format: OpenLayers.Format.GeoJSON, projection: new
> > OpenLayers.Projection("EPSG:4326"), styleMap: new
> > OpenLayers.StyleMap(mystyle)});
> >
> >
> > I think the solution might be somewhere in the post:
> > StyleMap and ModifyFeatures aren't compatible ?I will give it a try.
> >
> > All the best,
> > Adorian
> >
> >
> > Dr. Adorian Ardelean
> > coordinator of myNature Project
> >
> > http://mybiosis.info/nature/portal.php?pagename=firstpage [a
> Romanian
> > biodiversity-database]
> > http://mybiosis.info/nature/portal.php?pagename=adorian [CV]
> >
>
>
>
>
> --
> Dr. Adorian Ardelean
> coordinator of myNature Project
>
> proiectul myNature
> str. Rascoala din 1907 nr 12
> Timisoara 300523
> Romania
>
> http://mybiosis.info/nature/portal.php?pagename=firstpage [a Romanian
> biodiversity-database]
> http://mybiosis.info/nature/portal.php?pagename=adorian [CV]
>
>
> Projects in which I was involved:
> http://hercules.kgs.ku.edu/Hexacoral/Anemone2/ [Hexacorallians of the
> World]
> http://www.ubio.org [uBio Project]
> http://portal.ubio.org [uBio Portal]
> http://microscope.mbl.edu [micro*scope Project]
> http://starcentral.mbl.edu/biopedia [BioPedia]
> http://starcentral.mbl.edu/custar [CU*STAR]
> http://planktonnet.awi.de/index.php [planktonNet]
>
> Yahoo messenger: transylvaniasan
> ------------------------------------------------------------------------
>
> _______________________________________________
> Users mailing list
> Users at openlayers.org
> http://openlayers.org/mailman/listinfo/users
>
--
Alexandre Dubé
Mapgears
www.mapgears.com
More information about the Users
mailing list