MousePosition: numDigits inconsistency, reported by kthy, patch by kthy, additional test by me, r=me (closes #1544)
git-svn-id: http://svn.openlayers.org/trunk/openlayers@7163 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -40,7 +40,7 @@ OpenLayers.Control.MousePosition = OpenLayers.Class(OpenLayers.Control, {
|
||||
* APIProperty: numDigits
|
||||
* {Integer}
|
||||
*/
|
||||
numdigits: 5,
|
||||
numDigits: 5,
|
||||
|
||||
/**
|
||||
* APIProperty: granularity
|
||||
@@ -144,7 +144,7 @@ OpenLayers.Control.MousePosition = OpenLayers.Class(OpenLayers.Control, {
|
||||
* lonLat - {<OpenLayers.LonLat>} Location to display
|
||||
*/
|
||||
formatOutput: function(lonLat) {
|
||||
var digits = parseInt(this.numdigits);
|
||||
var digits = parseInt(this.numDigits);
|
||||
var newHtml =
|
||||
this.prefix +
|
||||
lonLat.lon.toFixed(digits) +
|
||||
|
||||
@@ -3,14 +3,14 @@
|
||||
<script src="../../lib/OpenLayers.js"></script>
|
||||
<script type="text/javascript">
|
||||
var map, control;
|
||||
function test_Control_MousePosition_constructor (t) {
|
||||
function test_initialize (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_Control_MousePosition_redraw_noLayer_displayProjection(t) {
|
||||
function test_redraw_noLayer_displayProjection(t) {
|
||||
t.plan(2);
|
||||
control = new OpenLayers.Control.MousePosition({'displayProjection': new OpenLayers.Projection("WGS84")});
|
||||
map = new OpenLayers.Map('map');
|
||||
@@ -25,7 +25,7 @@
|
||||
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) {
|
||||
function test_destroy(t) {
|
||||
t.plan(1);
|
||||
|
||||
var map = new OpenLayers.Map('map');
|
||||
@@ -38,8 +38,7 @@
|
||||
t.eq(map.events.listeners.mousemove.length, listeners - 1, "mousemove event is unregistered");
|
||||
map.destroy();
|
||||
}
|
||||
|
||||
function test_MousePosition_addControl(t) {
|
||||
function test_addControl(t) {
|
||||
t.plan(4);
|
||||
|
||||
var map = new OpenLayers.Map('map');
|
||||
@@ -52,8 +51,7 @@
|
||||
t.eq(parseInt(map.viewPortDiv.lastChild.style.zIndex), map.Z_INDEX_BASE['Control'] + 5, "Viewport div contains control div");
|
||||
map.destroy();
|
||||
}
|
||||
|
||||
function test_Control_MousePosition_redraw_noLayer_displayProjection(t) {
|
||||
function test_redraw_noLayer_displayProjection(t) {
|
||||
t.plan(3);
|
||||
var control = new OpenLayers.Control.MousePosition();
|
||||
var map = new OpenLayers.Map('map');
|
||||
@@ -70,6 +68,18 @@
|
||||
t.eq(control.div.innerHTML, "-175.78125, 85.78125", "innerHTML set correctly when triggered.");
|
||||
map.destroy();
|
||||
}
|
||||
function test_formatOutput(t) {
|
||||
t.plan(1);
|
||||
var control = new OpenLayers.Control.MousePosition({
|
||||
prefix: 'prefix',
|
||||
suffix: 'suffix',
|
||||
separator: 'separator',
|
||||
numDigits: 3
|
||||
});
|
||||
var lonlat = new OpenLayers.LonLat(0.75699, 0.37365);
|
||||
var val = control.formatOutput(lonlat);
|
||||
t.eq(val, 'prefix0.757separator0.374suffix', 'formatOutput correctly formats the mouse position output');
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
Reference in New Issue
Block a user