I have to develop interactive floor plan navigator and viewer for apartment buildings, which will succeed its Flash-based predecessor.
I am now in the process of evaluating techniques and technologies best suited to implement this in HTML5. I will have to support all common browsers (IE starting with 7).
Requirements:
- The user is presented with several static outdoor views of the building, between which he can switch with a simple widget.
- They will be able to select a floor on this outside view. On mouseover (click for touch devices) the floor will be highlighted.
- Upon clicking on the floor you switch to a floor plan, which - again on mouseover/onclick - provides detailed information about the apartment.
- Some animations should be involved, but nothing too fancy.
You can view a version of the flash-based version here: http://salitergasse.at/sg9/eigentumswohnungen/moedling/perchtoldsdorf
I have been thinking of the options for implementing this. I will also need a quick way of selecting polygons for the floors (overview) an the apartments (floor plan) to allow non-developers to create new buildings.
The options I came up with:
- Use plain images and image maps for the layovers.
- Use canvas(utilizing Google's Javascript solution for browsers without support). Load the image in the canvas tag and dynamically create the layovers.
- Use SVG
What is the best option for cross-browser compatability?
I'm planning something similar for indoor navigation :)
I ended up using OpenLayers (http://openlayers.org/)
Actually OpenLayers was invented for GIS Stuff (Maps etc.) but you can easily define a X-Y-Z metric coordinate system and simply feed it with vector data.
The big benefit is that it comes with many features like drawing, different vector overlays, collision detection, distance measuring, tooltips, marks etc:
For OpenLayers 2.x (originally) see:
http://dev.openlayers.org/releases/OpenLayers-2.13.1/examples/
http://dev.openlayers.org/releases/OpenLayers-2.13.1/examples/draw-feature.html
http://dev.openlayers.org/releases/OpenLayers-2.13.1/examples/transform-feature.html
For OpenLayers 3.x see:
http://openlayers.org/en/v3.4.0/examples/
http://openlayers.org/en/v3.4.0/examples/draw-features.html
You can communicate over GeoJSON, GML etc. with the backend. We used PostGIS as backend to store the vector data. There's also a spatial extension for mysql (http://dev.mysql.com/doc/refman/5.0/en/spatial-extensions.html).
Just define a simple X-Y-Z coordinate system with a well chosen reference point :)
Either SVG or Canvas will suit your needs. You'll probably have an easier time developing this in SVG simply because of how much is already done for you.
Here are some other considerations:
At this point they are pretty equal compatibility-wise, save for older versions of IE. You can get those to work with Canvas using the excanvas library, but it kinda sucks, especially if anything is going to be moving.
I'd recommend SVG solely because you will be able to get off the ground developing it much much faster for a floor-plan type of app. Everything is already a DOM object. Events, mouse handling, etc, is already done for you.
But if you really want it to work on (older?) android phones, Canvas may be the better bet for now.