MapGuide API for node.js
node-mapguide consists of the following components:
- A pre-processor utility (IMake) to generate a constants.js file and to generate a sanitized SWIG input file
- A heavily-modified version of SWIG (http://www.swig.org/) that supports generating Node.js wrapper code for MapGuide
- A node native addon VS project to build the C++ sources generated by SWIG
- Microsoft Visual Studio 2012 (tested with Express Edition for Windows Desktop)
- node.js source (tested on latest stable v0.10.21)
- Jake (https://github.com/mde/jake)
- njake (https://github.com/prabirshrestha/njake). A copy of njake is included here for convenience
- A subversion checkout of MapGuide Open Source trunk
- Build MapGuide Open Source
- Build node.js from source. If you have multiple versions of Visual Studio, make sure node's build script uses the VS2012 compiler. MapGuide does not export a C-linkable API (and neither does node/V8) thus node.js must be built with the same compiler used to build MapGuide.
- Install Jake locally:
npm install jake
- Install ini module:
npm install ini
- Build node-mapguide with jake from VS2012 command prompt
jake MG_SRC=<path to MapGuide Source dir> NODE_SRC=<path to node.js source dir>
swig.bat
(HACK: This was supposed to be an exec() task in Jake, but some paths get screwed up. Anyone know why?)jake MG_SRC=<path to MapGuide Source dir> NODE_SRC=<path to node.js source dir> api
Once built, the MapGuide API extension for node.js will reside in the Release
directory of your node.js source
TBD
var mg = require("./MapGuideNodeJsApi");
var constants = require("./mgconstants");
mg.MgInitializeWebTier("C:\path\to\webconfig.ini");
//All MapGuide classes are prefixed under the alias you've required() under
var conn = new mg.MgSiteConnection();
var user = new mg.MgUserInformation("Anonymous", "");
conn.Open(user);
//Where certain known constants are expected, use the mgconstants module
var resSvc = conn.CreateService(constants.MgServiceType.ResourceService);
var featSvc = conn.CreateService(constants.MgServiceType.FeatureService);
- Use NAN (https://github.com/rvagg/nan) to better insulate us from changes to underlying Node API
- Port existing API test runner across to node.js for basic API validation/verification