I’m doing something a little different and creating an interactive map for a university using SVG graphics and the JQuery plugin.
What I am trying to work out is the best way of tying this into a database. Basically what will happen is the map loads, and then when the user hovers over a room, it displays details about the room.
These details are coming from a database, but I figured that an SQL query every time the user hovers over a new room is going to be overkill.
What I have at the moment is that when the map loads all the details about the rooms for that floor are loaded into an XML file, then, when a user hovers over a room, it uses an AJAX call to extract the details from the XML file and display them on the screen. However, I’m worried about server load with this, is there a better alternative anyone can think of?
Depends on what type of SQL query you are talking about. If you are query by primary key then it you can literally perform thousands without incurring much cost at all.
One AJAX call per room sounds as though it might be less than ideal from a users perspective since there will be a ‘lag’ between hovering over the room and the information appearing.
If you get the entire floor when the page loads and cache it then there will be only one query on the server and the user interface will be very responsive. This would therefore seem to be the ideal case for you.