[Openstreetmap] SVG, JavaScript, DOM, AJAX and web mapping

Nick Whitelegg Nick.Whitelegg at solent.ac.uk
Tue Jul 5 15:20:41 BST 2005


Was reading last week about a technology variously known as "Remote
Scripting" or "AJAX" (Asynchronous JavaScript And XML) which allows
JavaScript running on a browser to send an HTTP request to a web server *at
any point* (not just when the user submits a form) and then the server
responds with some XML which the JavaScript can then use to manipulate the
Document Object Model of the web page, and change the page content *without
having to load a new page*.

This is an interesting concept and got me wondering about how it could be
used for web mapping. An approach where...

1) User navigates the map by pressing an arrow key, e.g. moves left
2) Client (JavaScript ) sends server an HTTP request for data in the new
grid square
3) Server sends back the data in the new grid square as XML embedded within
an HTTP response
4) JavaScript processes the data. Map is stored client-side as an SVG
document. JavaScript redraws the map by manipulating the Document Object
Model of the SVG.

This would reduce load on the server significantly and lead to much cleaner
client-server separation in the code (hence more maintainable code) as well
as creating a "rich web app" which was as smooth and seamless as a regular
desktop app (no page reloads necessary) and opens up the possibility of all
sorts of advanced user interaction.

To make this work (i.e. allow the client to dynamically create an image
from XML data) would require browser SVG support. Apparently Firefox 1.1
will support SVG natively. I can see how all this would work apart from one
thing which I'm not sure can be done or not. Can JavaScript embedded within
an HTML document access and manipulate the Document Object Model of an SVG
document?

Thanks,
Nick





More information about the talk mailing list