Friday, July 25, 2008

GIS Server REST and Quirks Mode

ESRI recently released their REST API for GIS Server. I finally got a chance to put the REST API to use today and I have to say that I love it thus far! This really changes the picture for developing web apps using GIS Server.

I did, however, notice that the javascript examples produced by the REST services aren't XHTML. This has the side effect of forcing the browser into quirks mode. You can see why this was likely intended by adding a DOCTYPE declaration to the top of one of the sample pages:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "">

When you do this, the map disappears! The sample pages use a table layout with style="height: 99%;" to expand the table row to fill the page. The problem with this approach is that it is only supported in quirks mode.

I'm not an expert on CSS but I am able to get a map to fill the page without using a table layout or quirks mode. You should be able to just add this style declaration in the <head> section of your page:
html, body, div#map {
height: 99%;
body {
margin: 0px; /* Used here for IE & Mozilla */
padding: 0px; /* Used here for Opera */
div#map {
width: 99%;

Using this approach, you don't have to embed your maps in a table layout and you can write true XHTML.

No comments: