geographika

Developing geo-technologies

Archive for the ‘javascript’ tag

Logging OpenLayers with Firebug

with 2 comments

imageI take it as given that anyone developing with Firefox and OpenLayers has Firebug installed. Firebug has a number of powerful tools that can make the previous nightmare of JavaScript debugging tolerable.

One feature I recently “discovered” are the logging options. It’s definitely a timesaver over my previous method of putting temporary alert(vals); throughout my code. As well as debugging the logging is very useful for automatically documenting formulae in JavaScript with worked examples that can then be pasted straight into the documentation.

An example of the logging capabilities can be seen on my sample OpenLayers page. If you already have Firebug installed you should be able to see the output similar to that below when the page loads.

image

Read the rest of this entry »

Written by geographika

April 13th, 2010 at 8:07 pm

Minifying the Mapfish Client on Windows

with one comment

This page has 72 external Javascript scripts. Try combining them into one.

My YSlow Firefox plug-in was telling me that I had included too may JavaScript files, and that they should be combined into a single-file, and minified. The default setup of Mapfish has a single script include (mfbase\mapfish\MapFish.js), but this script  automatically loads around 40 further scripts.

I tried a couple of unsuccessful attempts at copying and pasting various Mapfish JS files into an online JavaScript compressor. However when referencing the minified file I kept getting “undefined” errors from various Mapfish plugins and OpenLayer objects.

Initially I was looking to download a ready-made “compiled” MapFish file, but was unable to find a version online. I have uploaded a zipped version so if you want the file without going through the steps below you can download a copy. Note that if you have made any modifications to the MapFish files then these will not be available, and there are no guarantees it will work.

There are instructions on creating a single-file Mapfish client build on the Mapfish site. This process uses JSBuild which is part of JSTools“a collection of python scripts for packaging and efficiently serving javascript.”
Unfortunately these instructions require a Linux operating system, and I’m using Windows. I eventually managed to “translate” these into Windows commands, and have documented the steps below.

Read the rest of this entry »

Written by geographika

January 28th, 2010 at 8:00 am

Mapfish JavaScript Toolbox

without comments

Mapfish is an open-source web mapping framework built using the Pylons Python web framework for “creating web services that allow querying and editing of geographic objects.” However the server-side functionality of the system I am currently working on is already handled by SQL Server 2008 Spatial and MapServer. What interested me more was that Mapfish “provides a complete RIA-oriented (Rich Internet Application) JavaScript toolbox.”

A couple of examples of the front-end interface can be found at the EU Inspire Geoportal, and the Marbled Murrelet Mashup. The Mapfish client combines three frameworks into one OpenLayers, GeoExt, and ExtJS.

The client JavaScript is available via downloaded from http://www.mapfish.org/downloads/. At the time of writing mapfish-client-1.2.tar.gz was the most recent version. The files can be unzipped using the open-source program 7-zip that handles both gzip and “tar ball” zip files. Once unzipped there are a number of samples that can be run and edited locally (look for the examples/map/index.html page). This alone is a huge step forward in creating a basic online mapping system that rivals proprietary offerings.

Further details on using the toolkit can be found at the Mapfish tutorial and this blog tutorial. I’ll also be writing some more technical posts, specifically around using Mapfish with Windows, as most of the current documentation assumes people are running Linux.

Written by geographika

January 14th, 2010 at 11:16 am