Spherical mercator example now makes use of this, displaying coordinates in lon/lat instead of meters, and permalink/argparser now work in lon/lat as well. this functionality will make using SphericalMercator easier for a number of applications. r=tschaub (Closes #1036) git-svn-id: http://svn.openlayers.org/trunk/openlayers@5519 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
79 lines
3.4 KiB
HTML
79 lines
3.4 KiB
HTML
<html>
|
|
<head>
|
|
<script src="../../lib/OpenLayers.js"></script>
|
|
<script type="text/javascript">
|
|
var map, control;
|
|
function test_01_Control_MousePosition_constructor (t) {
|
|
t.plan( 2 );
|
|
|
|
control = new OpenLayers.Control.MousePosition();
|
|
t.ok( control instanceof OpenLayers.Control.MousePosition, "new OpenLayers.Control returns object" );
|
|
t.eq( control.displayClass, "olControlMousePosition", "displayClass is correct" );
|
|
}
|
|
function test_02_Control_MousePosition_redraw_noLayer_displayProjection(t) {
|
|
t.plan(2);
|
|
control = new OpenLayers.Control.MousePosition({'displayProjection': new OpenLayers.Projection("WGS84")});
|
|
map = new OpenLayers.Map('map');
|
|
map.addControl(control);
|
|
control.redraw({'xy': new OpenLayers.Pixel(10,10)});
|
|
control.redraw({'xy': new OpenLayers.Pixel(12,12)});
|
|
t.eq(control.div.innerHTML, "", "innerHTML set correctly");
|
|
l = new OpenLayers.Layer('name', {'isBaseLayer': true});
|
|
map.addLayer(l);
|
|
map.zoomToMaxExtent();
|
|
control.redraw({'xy': new OpenLayers.Pixel(10,10)});
|
|
control.redraw({'xy': new OpenLayers.Pixel(12,12)});
|
|
t.eq(control.div.innerHTML, "-175.78125, 85.78125", "innerHTML set correctly when triggered.");
|
|
}
|
|
function test_MousePosition_destroy(t) {
|
|
t.plan(1);
|
|
|
|
var map = new OpenLayers.Map('map');
|
|
var control = new OpenLayers.Control.MousePosition();
|
|
map.addControl(control);
|
|
|
|
var listeners = map.events.listeners.mousemove.length;
|
|
control.destroy();
|
|
|
|
t.eq(map.events.listeners.mousemove.length, listeners - 1, "mousemove event is unregistered");
|
|
map.destroy();
|
|
}
|
|
|
|
function test_MousePosition_addControl(t) {
|
|
t.plan(4);
|
|
|
|
var map = new OpenLayers.Map('map');
|
|
var control = new OpenLayers.Control.MousePosition();
|
|
map.addControl(control);
|
|
|
|
t.ok(control.map === map, "Control.map is set to the map object");
|
|
t.ok(map.controls[map.controls.length - 1] === control, "map.controls contains control");
|
|
t.eq(parseInt(control.div.style.zIndex), map.Z_INDEX_BASE['Control'] + 5, "Control div zIndexed properly" );
|
|
t.eq(parseInt(map.viewPortDiv.lastChild.style.zIndex), map.Z_INDEX_BASE['Control'] + 5, "Viewport div contains control div");
|
|
map.destroy();
|
|
}
|
|
|
|
function test_02_Control_MousePosition_redraw_noLayer_displayProjection(t) {
|
|
t.plan(3);
|
|
var control = new OpenLayers.Control.MousePosition();
|
|
var map = new OpenLayers.Map('map');
|
|
map.addControl(control);
|
|
t.eq(control.div.innerHTML, "0.00000, 0.00000", "innerHTML set correctly");
|
|
control.redraw({'xy': new OpenLayers.Pixel(10,10)});
|
|
control.redraw({'xy': new OpenLayers.Pixel(12,12)});
|
|
t.eq(control.div.innerHTML, "0.00000, 0.00000", "innerHTML set correctly");
|
|
var l = new OpenLayers.Layer('name', {'isBaseLayer': true});
|
|
map.addLayer(l);
|
|
map.zoomToMaxExtent();
|
|
control.redraw({'xy': new OpenLayers.Pixel(10,10)});
|
|
control.redraw({'xy': new OpenLayers.Pixel(12,12)});
|
|
t.eq(control.div.innerHTML, "-175.78125, 85.78125", "innerHTML set correctly when triggered.");
|
|
map.destroy();
|
|
}
|
|
</script>
|
|
</head>
|
|
<body>
|
|
<div id="map" style="width: 1024px; height: 512px;"/>
|
|
</body>
|
|
</html>
|