Chapter 13 — I Need to Get To... 265
message = document.getElementById(“message”);
rrecording = document.getElementById(“rrecording”);
routeidfield = document.getElementById(“routeid”);
routetitle = document.getElementById(“routetitle”);
routedescription = document.getElementById(“routedesc”);
routeidfield.value = 0;
routetitle.value = ‘’;
routedescription.value = ‘’;
map = new GMap(document.getElementById(“map”));
map.addControl(new GSmallZoomControl());
map.centerAndZoom(new GPoint(-0.64,52.909444), 2);
}
}
With the variables initialized, you create the mapobject, add a simple zoom control, and then
zoom to a suitable area on the map according to the application.
Recentering and Zooming the Map
The recenterandzoom()function is the same as that shown in previous chapters, starting
with Chapter 10. The function accepts an array of points, calculates the center point and span
of those points, and both centers and zooms the Google Map until all of the supplied points
are displayed on the map.
You can see that in this application the process works just as well on points used to generate
markers as it does to generate routes.
Backend Database Interface
The server side of the route recording system must respond to a number of requests from the
Google Maps application. There are four basic operations to be supported:
Listing existing routes
Saving a route
Deleting a route
Getting a route
Response is obviously through XML, but in addition to the standard responses for a given
operation, there is also a requirement to send back error messages in the event of some sort of
failure of the backend process.
In addition to the four main functions, a fifth function returns a standardized message (and,
optionally, a number of attributes) and is primarily used when a function needs to return an
error message. Using a single function in this way makes it easier for the format of the message
to be standardized regardless of the function generating the error.