Note : This repo and this doc are heavily adapted from the angular-underscore-module, developed by andresesfm. Kudos to him.
Turf is a JavaScript library developed by people from MapBox that gives you methods to manipulate geodata with JS. The library is composed of several independant module, each of which achieve a particular geotreatment.
As this module is only a wrapper to access turf in an Angular Way, you still need to download the actual library. You have several options to do so:
- Download the complete minified version of the library here
- Use this online turf builder to build your own version of Turf, using only the module you need for your project. This is the recommended option
- Install Browserify by yourself and build your own version of Turf, using only the module you need for your project (see the turf documentation)
Either way, you should finally have a single js file, named whatever you want, that contains all the necessary code. For the rest of this documentation, we will assume that your js file is named turf.min.js
-
Make sure you have downloaded and included
turf.min.js
in your project:<script src="path/to/turf.min.js">
-
get this module
bower install tazaf/angular-turf-module
-
Add angular-turf-module.js to your main file (index.html)
<script src="path/to/angular-turf-module/angular-turf-module.js"></script>
-
Add the module as a dependency in your App definition
angular.module('MyApp', ['TurfModule'])
-
To use, add as an injected dependency to your Controller/Service and it is ready to use
angular .module('MyApp') .controller('MyCtrl', function ($scope, turf) { ... //Use turf var pt1 = turf.point([-75.343, 39.984]); ...
- Turf: http://turfjs.org/
- Turf Builder Tool: https://turfjs-builder.herokuapp.com/
- Github: https://github.com/tazaf/angular-turf-module