3

How to use the console.log() on openlayers3 objects?

For example if I log the map object in openlayers2 this is a result. this

Here i can observe the map, layers, baselayers etc. and its very helpful in development.

But with the new openlayers i.e. openlayers3 when i console log the map object i get something totally different in log. After googling a bit, i found this post, and tried logging the map object as map.getLayers() and i get this output

which doesn't seems helpful compared to older version.

So is there any way to log the openlayers objects so as to get the log clear as it used to in the version 2+. Any pointers related to this are most welcome.

0

First off, you're already using the debug.js version, so that's good. You're not really doing anything wrong or missing anything.

Unfortunately, there were a lot of enhancements in the v3 engine which means you'll have to go digging for the information you want.

For instance, the map projection information is no longer found on the map object directly, but within map.getView() (see below).

Have a look through the API and you will eventually come across the methods / properties that will get the information you need.

API for Map: http://openlayers.org/en/master/apidoc/ol.Map.html
API for View: http://openlayers.org/en/master/apidoc/ol.View.html

Example of map.getView():

screen

Good Luck!

  • It seems that this is the only way you can work with OL3 as of now. – Suraj Apr 30 '15 at 9:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.