+var SYJPathLength = (function(){
+ return {
+ update: function() {
+ var pathLength = 0, unit;
+ if (SYJView.mode === 'view') {
+ if (SYJView.viewLayer.features.length) {
+ pathLength = SYJView.viewLayer.features[0].geometry.getGeodesicLength(Mercator);
+ }
+ } else {
+ pathLength = SYJView.editControl.handler.line.geometry.getGeodesicLength(Mercator);
+ }
+
+ if (pathLength === 0) {
+ $("path-length").hide();
+ return;
+ }
+ $("path-length").show();
+
+ if (pathLength < 1000) {
+ // precision: 1 cm
+ pathLength = Math.round(pathLength * 100) / 100;
+ unit = 'm';
+ } else {
+ // precision: 1 m
+ pathLength = Math.round(pathLength) / 1000;
+ unit = 'km';
+ }
+ $("path-length-content").update(pathLength + ' ' + unit);
+ }
+ };
+}());
+