Interactive Floor Plans in HTML5

妖精的绣舞 提交于 2019-12-02 16:21:21

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:

  • Canvas works in all "modern" browsers, but not IE7/8
  • SVG works in all modern browser, and VML (very close) is in IE7/8
  • Text rendering in Canvas can look pretty different per-browser right now
  • Canvas works in Android and iOS to an extent (minor things like text gradients still mess up)
  • SVG does not work in android (at least it didn't a year ago. Anything change?) It does work in iOS
  • The accessibility of SVG is FAR better. Text is searchable, therefore SEO-friendly, blind-friendly, copy-and-paste friendly, etc. Interacting with the rest of the DOM is a lot more natural.
  • Canvas performance is better, but you don't need that.

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.

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 :)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!