[OpenLayers-Users] Problems with DrawFeature and StyleMap
Daniel Muellertorgau
dmuellertorgau at googlemail.com
Wed Dec 14 05:51:24 EST 2011
Hello,
i have some trouble with DrawFeatrue in conjunction with polygons and
label in the temporary Style.
When entering the map an javascript error occurred.
I added a StyleMap to the Draw Feature Example. When you choose "draw"
polygon and enter the map
you will get an error.
What is my mistake?
Best regards
Daniel
Draw Feature Example---
[..]
map = new OpenLayers.Map('map');
var wmsLayer = new OpenLayers.Layer.WMS( "OpenLayers WMS",
"http://vmap0.tiles.osgeo.org/wms/vmap0?",
{layers: 'basic'});
var options = {
styleMap: new OpenLayers.StyleMap({
"default": new OpenLayers.Style({
pointRadius: 6, // sized according to type attribute
fillColor: "#0000FF",
strokeColor: "#0000FF",
strokeWidth: 2,
graphicZIndex: 1
}),
"select": new OpenLayers.Style({
pointRadius: 6,
fillColor: "#66ccff",
strokeColor: "#3399ff",
graphicZIndex: 2
}),
"temporary": new OpenLayers.Style({
pointRadius: 6,
fillColor: "#FF00FF",
strokeColor: "#FF00FF",
label: "Test",
graphicZIndex: 2
})
})
};
var pointLayer = new OpenLayers.Layer.Vector("Point
Layer",options);
var lineLayer = new OpenLayers.Layer.Vector("Line
Layer", options);
var polygonLayer = new
OpenLayers.Layer.Vector("Polygon Layer",options);
map.addLayers([wmsLayer, pointLayer, lineLayer, polygonLayer]);
map.addControl(new OpenLayers.Control.LayerSwitcher());
map.addControl(new OpenLayers.Control.MousePosition());
var drawOptions = {
'handlerOptions': {
'style': {
'strokeColor': '#FF0000',
'strokeOpacity': 1,
'strokeWidth': 2,
'fillColor': '#FF0000',
'fillOpacity': 0.5,
'pointRadius': 6
}
}
};
drawControls = {
point: new OpenLayers.Control.DrawFeature(pointLayer,
OpenLayers.Handler.Point, drawOptions),
line: new OpenLayers.Control.DrawFeature(lineLayer,
OpenLayers.Handler.Path, drawOptions),
polygon: new OpenLayers.Control.DrawFeature(polygonLayer,
OpenLayers.Handler.Polygon, drawOptions)
};
[..]
More information about the Users
mailing list