An accessible click control implementation
Click, control, accessibility. Doesn't work However.
HTML
<link rel="stylesheet" href="http://openlayers.org/dev/theme/default/style.css">
<link rel="stylesheet" href="http://openlayers.org/dev/examples/style.css">
<script src="http://fbug.googlecode.com/svn/lite/branches/flexBox/content/firebug-lite-dev.js"></script>
<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.9/themes/base/jquery-ui.css">
<script src="http://openlayers.org/dev/OpenLayers.js"></script>
<title>Direction Arrows Example</title>
<body onload="init()">
<h1 id="title">OpenLayers Draw Feature Example</h1>
<div id="tags">
point, line, linestring, polygon, box, digitizing, geometry, draw, drag
</div>
<p id="shortdesc">
Demonstrate the rendering of arrows to show line direction. Can be useful for routing or trails.
</p>
<div id="map" class="smallmap"></div>
<ul id="controlToggle">
<li>
<input type="radio" name="type" value="none" id="noneToggle"
onclick="toggleControl(this);" checked="checked" />
<label for="noneToggle">navigate</label>
</li>
<li>
<input type="radio" name="type" value="line" id="lineToggle" onclick="toggleControl(this);" />
<label for="lineToggle">draw line</label>
</li>
<li>
<input type="radio" name="type" value="modify" id="modifyToggle" onclick="toggleControl(this);" />
<label for="modifyToggle">modify</label>
</li>
</ul>
</body>
</html>
CSS
<link rel="stylesheet" href="http://openlayers.org/dev/theme/default/style.css" type="text/css">
<link rel="stylesheet" href="http://openlayers.org/dev/examples/style.css" type="text/css">
#controlToggle li {
list-style: none;
}
p {
width: 512px;
}
/* avoid pink tiles */
.olImageLoadError {
background-color: transparent !important;
}
JavaScript
(function($) {
var map, drawControls;
function init() {
map = new OpenLayers.Map('map');
var wmsLayer = new OpenLayers.Layer.WMS("OpenLayers WMS", "http://vmap0.tiles.osgeo.org/wms/vmap0?", {
layers: 'basic'
});
var vector = new OpenLayers.Layer.Vector("Vector Layer", {
renderers: ['SVGExtended', 'VMLExtended', 'CanvasExtended'],
styleMap: new OpenLayers.StyleMap({
'default': OpenLayers.Util.extend({
orientation: true
}, OpenLayers.Feature.Vector.style['default']),
'temporary': OpenLayers.Util.extend({
orientation: true
}, OpenLayers.Feature.Vector.style['temporary'])
})
});
map.addLayers([wmsLayer, vector]);
map.addControl(new OpenLayers.Control.LayerSwitcher());
map.addControl(new OpenLayers.Control.MousePosition());
drawControls = {
line: new OpenLayers.Control.DrawFeature(
vector,
OpenLayers.Handler.Path
),
modify: new OpenLayers.Control.ModifyFeature(vector)
};
for (var key in drawControls) {
map.addControl(drawControls[key]);
}
map.setCenter(new OpenLayers.LonLat(0, 0), 3);
document.getElementById('noneToggle').checked = true;
}
function toggleControl(element) {
for (key in drawControls) {
var control = drawControls[key];
if (element.value == key && element.checked) {
control.activate();
} else {
control.deactivate();
}
}
}
init();
})(jQuery);