am having point,polygon,line,hand(for map dragging) in my editing tool bar, now when I create any point or line I want to change its location by dragging that specific marker on the map, how do I add this option in editing tool bar. Code is here:
OpenLayers Editing Toolbar Example
<link rel="stylesheet" href="OpenLayers/theme/default/style.css" type="text/css">
<!--[if lte IE 6]>
<link rel="stylesheet" href="../theme/default/ie6-style.css" type="text/css">
<![endif]-->
<link rel="stylesheet" href="style.css" type="text/css">
<script src="OpenLayers/OpenLayers.js"></script>
<script src="OpenLayers/lib/Firebug/firebug.js"></script>
<script type="text/javascript">
var lon = 5;
var lat = 40;
var zoom = 5;
var map, layer;
function init(){
layer = new OpenLayers.Layer.WMS( "OpenLayers WMS",
"http://vmap0.tiles.osgeo.org/wms/vmap0", {layers: 'basic'} );
vlayer = new OpenLayers.Layer.Vector( "Editable" );
map = new OpenLayers.Map( 'map', {
controls: [
new OpenLayers.Control.PanZoom(),
new OpenLayers.Control.EditingToolbar(vlayer)
]
});
map.addLayers([layer, vlayer]);
map.setCenter(new OpenLayers.LonLat(lon, lat), zoom);
var click = new OpenLayers.Control.Click();
map.addControl(click);
click.activate();
}
OpenLayers.Control.Click = OpenLayers.Class(OpenLayers.Control, {
defaultHandlerOptions: {
'single': true,
'double': false,
'pixelTolerance': 0,
'stopSingle': false,
'stopDouble': false
},
initialize: function(options) {
this.handlerOptions = OpenLayers.Util.extend(
{}, this.defaultHandlerOptions
);
OpenLayers.Control.prototype.initialize.apply(
th开发者_运维问答is, arguments
);
this.handler = new OpenLayers.Handler.Click(
this, {
'click': this.trigger
}, this.handlerOptions
);
},
trigger: function(e) {
var lonlat = map.getLonLatFromViewPortPx(e.xy);
alert("You clicked near " + lonlat.lat + " N, " +
+ lonlat.lon + " E");
}
});
</script>
</head>
<body onload="init()">
<h1 id="title">Editing Toolbar Example</h1>
<div id="tags">
digitizing, point, line, linestring, polygon, editing
</div>
<p id="shortdesc">
Demonstrate polygon, polyline and point creation and editing tools.
</p>
<div id="panel"></div>
<div id="map" style="width: 1000px; height:500px;" ></div>
<div id="docs"></div>
</body>
</html>
精彩评论