3

I am able to work with web development tools like firebug and dev tools and solve bugs in my javascript files. But when it comes to bugs that produce errors such as "typeError: e is null" which prompts me to the third party js library I am using, how am I supposed to debug that issue?

I am creating a django app to integrate with a bigger django project. I am using openlayers as simple as possible and even though I am not getting any errors, apart from a css warning, my map division is not loading any maps...How am I supposed to work around this and of course any future similar problems?

Any advice or link would be much appreciated.

7
  • Could you supply the OpenLayers code you used to initialize the map? Also, I've been using olwidget with some success. Might be worth looking at.
    – geomajor56
    Commented Jul 10, 2013 at 14:15
  • While your'e at it, check out Leaflet and this django-leaflet plugin. I haven't tried it out yet but I will soon. Leaflet is much easier to use and the docs are great
    – geomajor56
    Commented Jul 10, 2013 at 14:21
  • thanks for the hints and tips. I am using leaflet as well. its giving me some trouble as well. I can use both Open layers and leaflet on simple stand alone web pages but something is going wrong when integrating into a big django project.
    – Antony
    Commented Jul 10, 2013 at 14:45
  • I am using openlayers-2.12
    – Antony
    Commented Jul 10, 2013 at 14:46
  • So, does anyone have experience on having no error shown and still having no map loading?
    – Antony
    Commented Jul 10, 2013 at 15:02

2 Answers 2

4

In general, debugging JavaScript code is not as easy as debugging your python code although firebug has made the problem much simpler already.

When it comes to js libraries like OpenLayers, first make sure you have the uncompressed version for development. When some error occurs, you can find the source file and the code line the defect originates in Firebug's console with a link to script provided. Find the code that causes the error and set break point where appropriate and repeat the process just as how you debug in other programming language.

Personally I find the firebug official documentation(faq & wiki) is quite useful, and especially this javascript debugging page.

3

All javascript libraries come in source form, so it is only a matter of taking the time to dive into the code. OpenLayers is no different, only you are probably using the minified, compressed into a single huge file version which is hard to read for humans.

To help with debugging you should use the non-minified version of the libraries when developing and switch to minified and unified versions in production.

With non-minified, non-unified versions of huge libraries like OpenLayers you will find inspecting code and debugging much easier.

For example OpenLayers ships with both a minified/unified single js file (recommended for production and usually available under the root and the build directory) and the unminified source code tree in the lib directory.

Most modern development environments offer the possibility to minify and concat javascript and css as part of the build process.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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