First in the Projectquantan-master this project there is a editingpanel this tool bar, but also very good, functional very full, but one thing is only draw a polygon button, no point and path two, so you want to add one.
Then found the unified drawfeature style (olcontroldrawfeatureiteminactive), not divided into point, path and polygon, and then go to the source code to control the style point code to modify him, but never found, can only be dropped.
and went online search found a openlayers Control (new OpenLayers.Control.EditingToolbar (Vector_layer), which has four buttons, point, Path, polygon and pan, fortunately, are going to use it with the previous editingpanel to do a thing,
Found this var controls = [
New OpenLayers.Control.DrawFeature (layer, OpenLayers.Handler.Polygon, {' Displayclass ': ' Olcontroldrawfeaturepolygon '}),
New OpenLayers.Control.DrawFeature (layer, OpenLayers.Handler.Path, {' Displayclass ': ' Olcontroldrawfeaturepath '}),
New OpenLayers.Control.DrawFeature (layer, OpenLayers.Handler.Point, {' Displayclass ': ' Olcontroldrawfeaturepoint '})
] is the next class can add its own,
Try to add a similar in the Editingpanel, did not expect to succeed. It's pale. Final code:
1 1/** 2 2 * Provide a custom editing panel for editing a VEC layer. 3 3 * Not meant to being general purpose. 4 4 */5 5 var Editingpanel =Openlayers.class (OpenLayers.Control.Panel, {6 6 7 7 initialize:function(layer) {8 8 9 9 OpenLayers.Control.Panel.prototype.initialize.apply (this, [{}]); Ten to one var navigate = newOpenLayers.Control.Navigation ({title: "Pan Map" 13 13}); the. var drawfeaturepoint = newOpenLayers.Control.DrawFeature (17 17Layer, OpenLayers.Handler.Point, {title: "Pip", Handleroptions: {multi:true},20 20displayclass: ' Olcontroldrawfeaturepoint '21 21}22 22): Var drawfeaturepath= newOpenLayers.Control.DrawFeature (25 25Layer, OpenLayers.Handler.Path, {page title: "Draw Line", Handleroptions: {multi:true},28 28displayclass: ' Olcontroldrawfeaturepath '29 29}30 30): var Drawfeaturepolygon = newOpenLayers.Control.DrawFeature (32 32Layer, OpenLayers.Handler.Polygon, {title: Draw polygon, Handleroptions: {multi:true},35 35displayclass: ' Olcontroldrawfeaturepolygon '36 36}37 37); the newOpenLayers.Control.ModifyFeature (layer, {page title: "Modify Features" 41 41}); the Var del = new Deletefeature (layer, {title: Delete features)}), and the var save = newOpenLayers.Control.Button ({title: "Save Changes", Trigger:function() {edit.feature) {49
edit.selectControl.unselectAll ();
}51//fails if no save strategy52 * var strat = OpenLayers.Array.fi Lter ( layer.strategies, Wu Wu function(s) {return s instanceof openlayers.strategy.save;56 }57) [0];58 strat.save (); },60 displayclass: "Olcontrolsavefeatures" ); 62 62 63 63 This.defaultcontrol = navigate;64//this.addcontrols ([Save, Del, Edit,drawfeaturepoint,drawfeaturepath, Drawfeaturepolygon, navigate]); this. Addcontrols ([Navigate,drawfeaturepoint,drawfeaturepath, Drawfeaturepolygon, edit, Del,save]); The},68 of the "Editingpanel" (class_name)
The above a brief problem-solving process, as long as the patient problem will be resolved. Never give up on your own and believe that the problem can be solved in your heart.
To believe that as long as to persist, the problem will always be resolved, of course, insist on not blindly adhere to, and constantly find ways to solve problems, problems can always be the perfect solution. But sometimes the process is a little slow, but at first, no experience, slow a little more accumulation of experience are the same, will be more and more quickly, can only say that you are slowly deepening the cognition of things, the problem will slowly get to solve.
custom toolbar in Openlayers, including draw points, lines, polygons