in the below code, i want to have the variable
mLeftClicksCount
initialized to zero. i tried the following but i get value equal to NaN as shown in the image below
mLeftClicksCount : number;
mLeftClicksCount : number = 0;
please let me know how to initialze a variable of type number
code:
this.map.on('click', function(evt){
++this.mLeftClicksCount;
if (this.mLeftClicksCount > 2) {
this.mLeftClicksCount = 1;
//(document.getElementById("originLngTextId") as HTMLInputElement).value = "";
//(document.getElementById("originLngTextId") as HTMLInputElement).value = "";
}
var lonlat = transform(evt.coordinate, 'EPSG:3857', 'EPSG:4326')
this.longitude = lonlat[0];
this.latitude = lonlat[1];
console.log("evt: " , evt);
console.log("evt: " , evt.target.longitude);
console.log("evt: " , evt['target']['latitude']);
console.log("this.mLeftClicksCount: " , this.mLeftClicksCount);
if (this.mLeftClicksCount == 1) {
(document.getElementById("originLngTextId") as HTMLInputElement).value = evt.target.longitude;
(document.getElementById("originLatTextId") as HTMLInputElement).value = evt.target.latitude;
} else if (this.mLeftClicksCount == 2) {
(document.getElementById("destinationLngTextId") as HTMLInputElement).value = evt.target.longitude;
(document.getElementById("destinationLatTextId") as HTMLInputElement).value = evt.target.latitude;
}
});