Tuesday, October 18, 2016

node js module client side browsify



How to use Esri/arcgis-to-geojson-utils in client side browser.


0) install browerify  by :    C:\Users\HU_J>npm install -g browserify

1) go to the target directory.  npm install arcgis-to-geojson-utils

  C:\Apache24\htdocs\civilgis\public\js\arcgis>npm install arcgis-to-geojson-utils

2)now you have see node_modules folder has been created.

browserify -r arcgis-to-geojson-utils > bundle.js

   
C:\Apache24\htdocs\civilgis\public\js\arcgis>browserify arcgis_to_geojson.js -o
bundle.js

C:\Apache24\htdocs\civilgis\public\js\arcgis>browserify -r arcgis-to-geojson-uti
ls > bundle.js

3) now include "bundle.js" in html tag.





4). now you could use node module in javascript such as:
        "require" your module


     arcgisToGeoJSON = require('arcgis-to-geojson-utils').arcgisToGeoJSON;
                             //var _geojson_object = arcgisToGeoJSON(data);
                             var _geojson_object = arcgisToGeoJSON(JSON.parse(data));

                              alert(JSON.stringify(_geojson_object));

No comments: