From OpenStreetMap Wiki
Jump to: navigation, search

Thanks to Steve, we now have the Ming library installed on the server. Ming is a super-flexible (LGPL) library that enables you to dynamically produce Flash .SWF files from the scripting language of your choice, which in OSM's case is Ruby.

Like many such projects, Ming is excellently engineered and badly documented. More information on using Ming with OSM will follow, but here are some starting points.

  • libming.net is the official docs wiki, but still in very early stages.
  • gazb's Ming examples (PHP) is a goldmine of working Ming code that you can learn from.
  • PHP Ming docs are probably the best (though still incomplete) function reference available.
  • Ming-Ruby has a few real Ruby examples.
  • Adobe's ActionScript dictionary is the essential ActionScript reference. Warning for Mac users - ridiculously slow in Safari, so use Firefox.

Using Ming on dev.openstreetmap.org

Ming-Ruby doesn't appear to be capable of writing direct to the browser under mod_ruby: it sends stuff to stdout rather than to the Apache Request object. Instead, we must write the SWF to a temporary file, then output the file:

require 'ming/ming'
include Ming

r = Apache.request
r.content_type = 'application/x-shockwave-flash'

Ming.set_scale(20.0)       # any number you like, but remember the Ming. bit
Ming.set_SWF_version(6)    # the behaviour of your ActionScript will depend on the version chosen

(put the rest of your code here, remembering to finish with a next_frame)

m.save(filename)           # where m is your SWFMovie object


write_exports is missing from Ming-Ruby. Required patch is here, hopefully we can apply it soon.


Here's a fairly fatuous example of Ming running on dev.