Вот код скрипта, удалил все что не касается (заменил на ...........)
Код: Выделить всё
App.control.mapPanel = Ext.extend(GeoExt.MapPanel, {
...........
strokeColor: '#3366FF',
strokeOpacity: 1,
strokeWidth: '2',
cursor: 'pointer',
fillColor: '#99CCFF',
fillOpacity: 0.50,
pointRadius: '5',
...........
getStyle: function(){
var style = [];
style['strokeColor'] = this.strokeColor;
style['strokeOpacity'] = this.strokeOpacity;
style['strokeWidth'] = this.strokeWidth;
style['cursor'] = this.cursor;
style['fillColor'] = this.fillColor;
style['fillOpacity'] = this.fillOpacity;
style['pointRadius'] = this.pointRadius;
return style;
},
setStyle: function(style) {
var defStyle = {
strokeColor : style['strokeColor'],
strokeOpacity : style['strokeOpacity'],
strokeWidth : style['strokeWidth'],
cursor : style['cursor'],
fillColor : style['fillColor'],
fillOpacity: style['fillOpacity'],
pointRadius: style['pointRadius']
};
alert("SET STYLE: "+style['strokeColor']);
var sty = OpenLayers.Util.applyDefaults(defStyle, OpenLayers.Feature.Vector.style["default"]);
var sm = new OpenLayers.StyleMap({
'default': sty,
'select': {
strokeColor: "red",
fillColor: "red"
}
});
return sm;
},
buildMap: function(){
..........
var polygon_layer = new OpenLayers.Layer.Vector("polygon", {
styleMap: this.setStyle(this.getStyle())
});
var center_layer = new OpenLayers.Layer.Vector("center", {
styleMap: this.setStyle(this.getStyle())
});
map.addLayers([center_layer, polygon_layer]);
....................
},
buildToolbar: function(){
....................
function style() {
var mapEditor = Ext.getCmp('app-mappanel');
alert("GET STYLE: "+mapEditor.getStyle().strokeColor);
return mapEditor.getStyle();
}
.....................
action = new GeoExt.Action({
text: '',
iconCls: 'icon-draw-path',
control: new OpenLayers.Control.DrawFeature(polygon_layer, OpenLayers.Handler.Path, {
featureAdded: function() {
var mapEditor = Ext.getCmp('app-mappanel');
mapEditor.setStyle(style());
},
handlerOptions:{
style: {
strokeColor: style().strokeColor,
strokeWidth: style().strokeWidth,
cursor: style().cursor,
fillColor: style().fillColor,
fillOpacity: style().fillOpacity,
pointRadius: style().pointRadius
}
}
}),
map: map,
toggleGroup: "draw",
allowDepress: false,
tooltip: "Нарисовать линию",
group: "draw"
});
actions["draw_line"] = action;
toolbarItems.push(action);
toolbarItems.push({
text: 'Настройка',
menu: new Ext.menu.Menu({
items: [
{
text: 'Линия',
menu: {
items: [
{
text: 'Изменить цвет',
menu: new Ext.menu.ColorMenu({
handler: function(cm, color){
var mapEditor = Ext.getCmp('app-mappanel');
var style = mapEditor.getStyle();
style['strokeColor'] = color;
mapEditor.setStyle(style);
}
})
},{
.............
}
]
})
});
return toolbarItems;
},
initComponent: function(){
...........