Search code examples
javascriptangularopenlayers

How to log the event object and see all of its properties on the browser


in the below log statement i am trying to log the event object on the browser so i can see the contents of it in terms of the values assigned to properties. that log statment should be displayed on the inspection section of the browser when i double click on the map.

but what happen is, i got something as shown in the screen shot posted below. the browser does not display the contents of the object

please let me know how to log the contents of an event to see all the properties and the values assigned to it code:

this.map.on('click', function(evt){
  var lonlat = transform(evt.coordinate, 'EPSG:3857', 'EPSG:4326')
  this.longitude = lonlat[0];
  this.latitude = lonlat[1];
  console.log("evt: " + evt);
});

screen shot: enter image description here


Solution

  • Don't use the concatenation plus operator - it will show the .toString() of the object which is not interesting for this element. If you use a comma, the console will expand

    console.log("evt: ", evt);
    

    or

    console.log("evt:");
    console.log(evt);