Skip to content

Commit

Permalink
fixed conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
davidmtech committed Oct 1, 2018
2 parents 532098f + 62705c7 commit c854b4a
Show file tree
Hide file tree
Showing 24 changed files with 1,909 additions and 74 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vts-browser-js",
"version": "2.15.17",
"version": "2.16.0",
"description": "JavaScript WebGL 3D maps rendering engine",
"main": "src/browser/index.js",
"scripts": {
Expand Down
36 changes: 35 additions & 1 deletion src/browser/browser.css
Original file line number Diff line number Diff line change
Expand Up @@ -522,6 +522,17 @@
/*background-color: rgba(255, 255, 255, 0.9);*/
}

.vts-measure-tools div {
margin-right: 2px;
}

.vts-measure-tools {
font-family: Verdana, Tahoma, Geneva, Arial, Sans-serif;
font-size: 12px;
margin-top: 2px;
/*background-color: rgba(255, 255, 255, 0.9);*/
}

.vts-measure-tools-button {
border-radius: 2px;
border: 1px solid rgba(0, 0, 0, 0.7);
Expand All @@ -531,11 +542,34 @@
cursor: pointer;
}

.vts-measure-tools-button:hover {
.vts-measure-tools-button-selected {
border-radius: 2px;
display: inline-block;
padding: 0px 5px;
background-color: #fff;
cursor: pointer;
color: rgba(0, 102, 255, 1);
border: 1px solid rgba(0, 102, 255, 1);
}

.vts-measure-compute {
position: absolute;
font-family: Verdana, Tahoma, Geneva, Arial, Sans-serif;
font-size: 12px;
top: 0px;
left: 0px;
display: none;
border-radius: 2px;
background-color: #aaa;
border: solid 1px #000;
white-space: nowrap;
padding: 3px 1px 3px 3px;
}

.vts-measure-compute div {
margin-right: 2px;
}

/*
* FULLSCREEN
*/
Expand Down
19 changes: 11 additions & 8 deletions src/browser/browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ Browser.prototype.getControlMode = function() {


Browser.prototype.on = function(name, listener) {
this.core.on(name, listener);
return this.core.on(name, listener);
};


Expand Down Expand Up @@ -310,6 +310,7 @@ Browser.prototype.initConfig = function() {
controlSearchUrl : null,
controlSearchFilter : true,
controlMeasure : false,
controlMeasureLite : false,
controlLink : false,
controlGithub : false,
controlScale : true,
Expand Down Expand Up @@ -391,13 +392,14 @@ Browser.prototype.setConfigParam = function(key, value, ignoreCore) {
case 'controlSearchFilter': this.config.controlSearchFilter = utils.validateBool(value, true); break;
case 'controlSearchElement': this.config.controlSearchElement = value; this.updateUI(key); break;
case 'controlSearchValue': this.config.controlSearchValue = /*utils.validateString(*/value/*, null)*/; this.updateUI(key); break;
case 'controlLink': this.config.controlLink = utils.validateBool(value, false); this.updateUI(key); break;
case 'controlGithub': this.config.controlGithub = utils.validateBool(value, false); this.updateUI(key); break;
case 'controlMeasure': this.config.controlMeasure = utils.validateBool(value, false); this.updateUI(key); break;
case 'controlLogo': this.config.controlLogo = utils.validateBool(value, false); this.updateUI(key); break;
case 'controlFullscreen': this.config.controlFullscreen = utils.validateBool(value, true); this.updateUI(key); break;
case 'controlCredits': this.config.controlCredits = utils.validateBool(value, true); this.updateUI(key); break;
case 'controlLoading': this.config.controlLoading = utils.validateBool(value, true); this.updateUI(key); break;
case 'controlLink': this.config.controlLink = utils.validateBool(value, false); this.updateUI(key); break;
case 'controlGithub': this.config.controlGithub = utils.validateBool(value, false); this.updateUI(key); break;
case 'controlMeasure': this.config.controlMeasure = utils.validateBool(value, false); this.updateUI(key); break;
case 'controlMeasureLite': this.config.controlMeasureLite = utils.validateBool(value, false); this.updateUI(key); break;
case 'controlLogo': this.config.controlLogo = utils.validateBool(value, false); this.updateUI(key); break;
case 'controlFullscreen': this.config.controlFullscreen = utils.validateBool(value, true); this.updateUI(key); break;
case 'controlCredits': this.config.controlCredits = utils.validateBool(value, true); this.updateUI(key); break;
case 'controlLoading': this.config.controlLoading = utils.validateBool(value, true); this.updateUI(key); break;
case 'minViewExtent': this.config.minViewExtent = utils.validateNumber(value, 0.01, Number.MAXINTEGER, 100); break;
case 'maxViewExtent': this.config.maxViewExtent = utils.validateNumber(value, 0.01, Number.MAXINTEGER, Number.MAXINTEGER); break;
case 'sensitivity': this.config.sensitivity = utils.validateNumberArray(value, 3, [0,0,0], [10, 10, 10], [1, 0.12, 0.05]); break;
Expand Down Expand Up @@ -486,6 +488,7 @@ Browser.prototype.getConfigParam = function(key) {
case 'controlLink': return this.config.controlLink;
case 'controlGithub': return this.config.controlGithub;
case 'controlMeasure': return this.config.controlMeasure;
case 'controlMeasureLite': return this.config.controlMeasureLite;
case 'controlLogo': return this.config.controlLogo;
case 'controlFullscreen': return this.config.controlFullscreen;
case 'controlCredits': return this.config.controlCredits;
Expand Down
4 changes: 2 additions & 2 deletions src/browser/interface.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ BrowserInterface.prototype.destroyMap = function() {

BrowserInterface.prototype.on = function(eventName, call) {
if (this.killed) return;
this.core.on(eventName, call);
return this;
return this.core.on(eventName, call);
//return this;
};


Expand Down
2 changes: 2 additions & 0 deletions src/browser/ui/control/loading.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ UIControlLoading.prototype.show = function() {
this.ui.setControlVisible('link', false);
this.ui.setControlVisible('github', false);
this.ui.setControlVisible('measure', false);
this.ui.setControlVisible('measure2', false);
this.ui.setControlVisible('fullscreen', false);
this.ui.setControlVisible('credits', false);
this.ui.setControlVisible('loading', true);
Expand Down Expand Up @@ -73,6 +74,7 @@ UIControlLoading.prototype.hide = function() {
this.ui.setControlVisible('link', this.ui.config.controlLink, false);
this.ui.setControlVisible('github', this.ui.config.controlGithub, false);
this.ui.setControlVisible('measure', this.ui.config.controlMeasure, false);
this.ui.setControlVisible('measure2', this.ui.config.controlMeasureLite, false);
this.ui.setControlVisible('fullscreen', this.ui.config.controlFullscreen, false);
this.ui.setControlVisible('credits', this.ui.config.controlCredits, false);
this.ui.setControlVisible('loading', false);
Expand Down
236 changes: 236 additions & 0 deletions src/browser/ui/control/measure-lite.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,236 @@

import Dom_ from '../../utility/dom';
import {UIControlMeasureIcon as UIControlMeasureIcon_, UIControlMeasureIcon2 as UIControlMeasureIcon2_} from './measure';

//get rid of compiler mess
var dom = Dom_,
UIControlMeasureIcon = UIControlMeasureIcon_,
UIControlMeasureIcon2 = UIControlMeasureIcon2_;


var UIControlMeasureLite = function(ui, visible, visibleLock) {
this.ui = ui;
this.browser = ui.browser;
this.control = this.ui.addControl('measure2',
'<div id="vts-measure" class="vts-measure">'

+ '<img id="vts-measure-button"'
+ ' class="vts-measure-button"'
+ ' src="' + UIControlMeasureIcon + '">'

+ '<img id="vts-measure-button2"'
+ ' class="vts-measure-button"'
+ ' src="' + UIControlMeasureIcon2 + '">'

+ '<div id="vts-measure-text-holder" class="vts-measure-text-holder">'
+ '<div class="vts-measure-text-holder2">'
+ '<div class="vts-measure-text">'
+ '<textarea id="vts-measure-text-input" rows="6" cols="50" wrap="hard"></textarea>'
+ '</div>'
+ '<div class="vts-measure-tools">'
+ '<div id="vts-measure-clear" class="vts-measure-tools-button">Clear</div>'
+ '</div>'
+ '</div>'
+ '</div>'

+ '<div id="vts-measure-info" class="vts-measure-info">'
+ '</div>'

+ ' </div>', visible, visibleLock);

this.div = this.control.getElement('vts-measure');

this.buttonOff = this.control.getElement('vts-measure-button');
this.buttonOff.on('click', this.onSwitch.bind(this));
this.buttonOff.on('dblclick', this.onDoNothing.bind(this));

this.buttonOn = this.control.getElement('vts-measure-button2');
this.buttonOn.on('click', this.onSwitch.bind(this));
this.buttonOn.on('dblclick', this.onDoNothing.bind(this));

this.info = this.control.getElement('vts-measure-info');

var clearButton = this.control.getElement('vts-measure-clear');
clearButton.on('click', this.onClear.bind(this));
clearButton.on('dblclick', this.onDoNothing.bind(this));

this.measuring = false;
this.counter = 1;
this.lastCoords = null;

this.listPanel = this.control.getElement('vts-measure-text-holder');
this.list = this.control.getElement('vts-measure-text-input');

if (this.measuring) {
this.buttonOn.setStyle('display', 'block');
this.buttonOff.setStyle('display', 'none');
} else {
this.buttonOn.setStyle('display', 'none');
this.buttonOff.setStyle('display', 'block');
}

this.onMouseMoveCall = this.onMouseMove.bind(this);
this.onMouseLeaveCall = this.onMouseLeave.bind(this);
this.onMouseClickCall = this.onMouseClick.bind(this);

this.update();
};


UIControlMeasureLite.prototype.onDoNothing = function(event) {
dom.stopPropagation(event);
};

UIControlMeasureLite.prototype.onMouseLeave = function(event) {
this.info.setStyle('display', 'none');
};


UIControlMeasureLite.prototype.onMouseClick = function(event) {
var map = this.browser.getMap();
if (!map) {
return;
}

var mapElement = this.ui.getMapElement();
var state = mapElement.getDraggingState();

//if (state['dragging']) { //TODO: why does not work this parameter? Fix it once you have time
// return;
//}
var delta = state['absMoved'];

if ((delta[0]+delta[1]) > 0) {
return;
}

var coords = event.getMouseCoords();
var clickCoords = map.getHitCoords(coords[0], coords[1], 'fix');

if (!clickCoords) {
return;
}

clickCoords = map.convertCoordsFromNavToPublic(clickCoords, 'fix');

var str = '#' + this.counter + ' ' + clickCoords[0].toFixed(7) + ', ' + clickCoords[1].toFixed(7) + ', ' + clickCoords[2].toFixed(2) + 'm';

if (this.lastCoords) {
var res = map.getDistance(this.lastCoords, clickCoords, false, true);
var space = '\n ';

for (var i = 0, li = ('' + this.counter).length; i < li; i++) {
space += ' ';
}

str += space + 'great-circle distance: ';

if (res[0] > 100000) {
str += '' + (res[0]*0.001).toFixed(2) + 'km';
} else {
str += '' + res[0].toFixed(2) + 'm';
}

str += space + 'elevation difference: ' + (clickCoords[2] - this.lastCoords[2]).toFixed(2) + 'm';
str += space + 'euclidean distance: ';

if (res[2] > 100000) {
str += '' + (res[2]*0.001).toFixed(2) + 'km';
} else {
str += '' + res[2].toFixed(2) + 'm';
}
}

this.counter++;
this.lastCoords = clickCoords;

var listElement = this.list.getElement();
listElement.value += str + '\n';
listElement.scrollTop = listElement.scrollHeight; //scroll list to the last line
};

UIControlMeasureLite.prototype.onMouseMove = function(event) {
var map = this.browser.getMap();
if (!map) {
return;
}

var coords = event.getMouseCoords();
var clickCoords = map.getHitCoords(coords[0], coords[1], 'fix');

if (!clickCoords) {
this.info.setStyle('display', 'none');
return;
}

clickCoords = map.convertCoordsFromNavToPublic(clickCoords, 'fix');

var str = clickCoords[0].toFixed(7) + ', ' + clickCoords[1].toFixed(7) + ', ' + clickCoords[2].toFixed(2) + 'm';

coords[0] -= this.divRect.left;
coords[1] -= this.divRect.top;

this.info.setStyle('display', 'block');
this.info.setStyle('left', (coords[0]+20)+'px');
this.info.setStyle('top', (coords[1]+10)+'px');
this.info.setHtml(str);
};

UIControlMeasureLite.prototype.onSwitch = function() {
this.measuring = !this.measuring;

var mapElement = this.ui.getMapElement();

if (this.measuring) {
this.buttonOn.setStyle('display', 'block');
this.buttonOff.setStyle('display', 'none');

this.divRect = this.div.getRect();

mapElement.on('mousemove', this.onMouseMoveCall);
mapElement.on('mouseleave', this.onMouseLeaveCall);
mapElement.on('click', this.onMouseClickCall);

} else {
this.buttonOn.setStyle('display', 'none');
this.buttonOff.setStyle('display', 'block');

mapElement.off('mousemove', this.onMouseMoveCall);
mapElement.off('mouseleave', this.onMouseLeaveCall);
mapElement.off('click', this.onMouseClickCall);
}

this.updateLink();
this.update();
};

UIControlMeasureLite.prototype.onClear = function() {
this.counter = 1;
this.lastCoords = null;

var listElement = this.list.getElement();
listElement.value = '';
listElement.scrollTop = 0;
};

UIControlMeasureLite.prototype.update = function() {
//var button = this.control.getElement('vts-measure-button');

var left = 10 + (this.ui.config.controlZoom ? 70 : 0) +
(this.ui.config.controlSpace ? 35 : 0);

this.div.setStyle('left', left + 'px');
this.listPanel.setStyle('display', this.measuring ? 'block' : 'none');
};


UIControlMeasureLite.prototype.updateLink = function() {
/*
var linkValue = this.browser.getLinkWithCurrentPos();
if (this.list.getElement().value != linkValue) {
this.list.getElement().value = linkValue;
}*/
};


export default UIControlMeasureLite;
Loading

0 comments on commit c854b4a

Please sign in to comment.