简体   繁体   English

OpenLayers的样式修改功能(拖动)

[英]style for OpenLayers modify feature (drag)

When I use drag feature, then the circles on the polygon edge has the same style. 使用拖动功能时,多边形边缘上的圆具有相同的样式。 For example, this OpenLayers site . 例如, 此OpenLayers网站 I need to change it, I mean they need to be a different color. 我需要更改它,我的意思是它们必须是其他颜色。 What is their (cycrles) style attribute? 他们的(循环)样式属性是什么?

In fact OpenLayers has very unlogic documentation and sometimes no docs. 实际上,OpenLayers具有非常不合逻辑的文档,有时甚至没有文档。 Here are all style parameters: OpenLayers.Feature.Vector 以下是所有样式参数: OpenLayers.Feature.Vector

fill    {Boolean} Set to false if no fill is desired.
fillColor   {String} Hex fill color.  Default is “#ee9900”.
fillOpacity {Number} Fill opacity (0-1).  Default is 0.4
stroke  {Boolean} Set to false if no stroke is desired.
strokeColor {String} Hex stroke color.  Default is “#ee9900”.
strokeOpacity   {Number} Stroke opacity (0-1).  Default is 1.
strokeWidth {Number} Pixel stroke width.  Default is 1.
strokeLinecap   {String} Stroke cap type.  Default is “round”.  [butt | round | square]
strokeDashstyle {String} Stroke dash style.  Default is “solid”.  [dot | dash | dashdot | longdash | longdashdot | solid]
graphic {Boolean} Set to false if no graphic is desired.
pointRadius {Number} Pixel point radius.  Default is 6.
pointerEvents   {String} Default is “visiblePainted”.
cursor  {String} Default is “”.
externalGraphic {String} Url to an external graphic that will be used for rendering points.
graphicWidth    {Number} Pixel width for sizing an external graphic.
graphicHeight   {Number} Pixel height for sizing an external graphic.
graphicOpacity  {Number} Opacity (0-1) for an external graphic.
graphicXOffset  {Number} Pixel offset along the positive x axis for displacing an external graphic.
graphicYOffset  {Number} Pixel offset along the positive y axis for displacing an external graphic.
rotation    {Number} For point symbolizers, this is the rotation of a graphic in the clockwise direction about its center point (or any point off center as specified by graphicXOffset and graphicYOffset).
graphicZIndex   {Number} The integer z-index value to use in rendering.
graphicName {String} Named graphic to use when rendering points.  Supported values include “circle” (default), “square”, “star”, “x”, “cross”, “triangle”.
graphicTitle    {String} Tooltip when hovering over a feature.  deprecated, use title instead
title   {String} Tooltip when hovering over a feature.  Not supported by the canvas renderer.
backgroundGraphic   {String} Url to a graphic to be used as the background under an externalGraphic.
backgroundGraphicZIndex {Number} The integer z-index value to use in rendering the background graphic.
backgroundXOffset   {Number} The x offset (in pixels) for the background graphic.
backgroundYOffset   {Number} The y offset (in pixels) for the background graphic.
backgroundHeight    {Number} The height of the background graphic.  If not provided, the graphicHeight will be used.
backgroundWidth {Number} The width of the background width.  If not provided, the graphicWidth will be used.
label   {String} The text for an optional label.  For browsers that use the canvas renderer, this requires either fillText or mozDrawText to be available.
labelAlign  {String} Label alignment.  This specifies the insertion point relative to the text.  It is a string composed of two characters.  The first character is for the horizontal alignment, the second for the vertical alignment.  Valid values for horizontal alignment: “l”=left, “c”=center, “r”=right.  Valid values for vertical alignment: “t”=top, “m”=middle, “b”=bottom.  Example values: “lt”, “cm”, “rb”.  Default is “cm”.
labelXOffset    {Number} Pixel offset along the positive x axis for displacing the label.  Not supported by the canvas renderer.
labelYOffset    {Number} Pixel offset along the positive y axis for displacing the label.  Not supported by the canvas renderer.
labelSelect {Boolean} If set to true, labels will be selectable using SelectFeature or similar controls.  Default is false.
labelOutlineColor   {String} The color of the label outline.  Default is ‘white’.  Only supported by the canvas & SVG renderers.
labelOutlineWidth   {Number} The width of the label outline.  Default is 3, set to 0 or null to disable.  Only supported by the canvas & SVG renderers.
fontColor   {String} The font color for the label, to be provided like CSS.
fontOpacity {Number} Opacity (0-1) for the label
fontFamily  {String} The font family for the label, to be provided like in CSS.
fontSize    {String} The font size for the label, to be provided like in CSS.
fontStyle   {String} The font style for the label, to be provided like in CSS.
fontWeight  {String} The font weight for the label, to be provided like in CSS.
display {String} Symbolizers will have no effect if display is set to “none”.  All other values have no effect.

This is how I've done it: 这是我的方法:

var layer_style = OpenLayers.Util.extend({},OpenLayers.Feature.Vector.style['default']);

layer_style.fillColor = "#333333";
layer_style.strokeColor = "#F62958";
layer_style.strokeOpacity = 0.75;
layer_style.fillOpacity = 0.5;
layer_style.strokeWidth = 5;
layer_style.pointRadius = 3; 

layers_layer = osMap.getVectorLayer();

layers_layer.style = layer_style;

lines_layer could be a new layer too, just as long as it's where the item you want to modify is located. lines_layer也可以是新图层,只要它是您要修改的项目所在的位置即可。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM