diff --git a/.gitignore b/.gitignore index ff7dfd2..7badfec 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ .idea *.iml node_modules +.vs diff --git a/.jshintrc b/.jshintrc deleted file mode 100755 index 1401d64..0000000 --- a/.jshintrc +++ /dev/null @@ -1,39 +0,0 @@ -{ - "predef": [ - "jasmine", - "spyOn", - "it", - "console", - "describe", - "expect", - "beforeEach", - "waits", - "waitsFor", - "runs" - ], - - "node" : true, - "browser" : true, - - "boss" : false, - "curly": false, - "debug": false, - "devel": false, - "eqeqeq": true, - "evil": true, - "forin": false, - "immed": true, - "laxbreak": false, - "newcap": true, - "noarg": true, - "noempty": false, - "nonew": false, - "nomen": false, - "onevar": true, - "plusplus": false, - "regexp": false, - "undef": true, - "sub": true, - "strict": false, - "white": true -} diff --git a/Gruntfile.js b/Gruntfile.js deleted file mode 100755 index 33f18b3..0000000 --- a/Gruntfile.js +++ /dev/null @@ -1,40 +0,0 @@ -'use strict'; - -module.exports = function(grunt) { - - grunt.initConfig({ - ghPagesDir: '../Leaflet.MultiOptionsPolyline@gh-pages/', - pkg: grunt.file.readJSON('package.json'), - uglify: { - options: { - banner: '/*! <%= pkg.name + " v" + pkg.version %> <%= grunt.template.today("dd-mm-yyyy") %> */\n' - }, - dist: { - files: { - '<%= pkg.name %>.min.js': ['<%= pkg.name %>.js'] - } - } - }, - jshint: { - files: ['Leaflet.MultiOptionsPolyline.js', 'demo/js/*.js'], - options: { - } - }, - copy: { - "gh-pages": { - files: [ - {expand: true, src: ['demo/**'], dest: '<%= ghPagesDir %>'}, - {expand: true, src: ['Leaflet.MultiOptionsPolyline.js'], dest: '<%= ghPagesDir %>'} - ] - } - } - - }); - - grunt.loadNpmTasks('grunt-contrib-uglify'); - grunt.loadNpmTasks('grunt-contrib-jshint'); - grunt.loadNpmTasks('grunt-contrib-copy'); - - grunt.registerTask('default', ['jshint', 'uglify']); - -}; \ No newline at end of file diff --git a/Leaflet.MultiOptionsPolyline.js b/Leaflet.MultiOptionsPolyline.js deleted file mode 100644 index 01f3644..0000000 --- a/Leaflet.MultiOptionsPolyline.js +++ /dev/null @@ -1,114 +0,0 @@ -(function (root, factory) { - if (typeof define === "function" && define.amd) { - define(["leaflet"], factory); - } else if (typeof module === "object" && module.exports) { - factory(require("leaflet")); - } else { - factory(root.L); - } -} (this, function (L) { - "use strict"; - -/* - * L.MultiOptionsPolyline is a MultiPolyLine which parts can be styled differently. - * options: { - * multiOptions: { - * optionIdxFn: function (latLng, prevLatLng, index, allLatlngs), - * fnContext: ctx, // the context to call optionIdxFn (optional) - * options: [{}, {}, {}] or function, // options for the index returned by optionIdxFn. If supplied with a function then it will be called with the index - * copyBaseOptions: true - * }, - * // other options from Polyline - * } - */ -var MultiOptionsPolyline = L.FeatureGroup.extend({ - - initialize: function (latlngs, options) { - var copyBaseOptions = options.multiOptions.copyBaseOptions; - - this._layers = {}; - this._options = options; - if (copyBaseOptions === undefined || copyBaseOptions) { - this._copyBaseOptions(); - } - - this.setLatLngs(latlngs); - }, - - _copyBaseOptions: function () { - var multiOptions = this._options.multiOptions, - baseOptions, - optionsArray = multiOptions.options, - i, len = optionsArray.length; - - baseOptions = L.extend({}, this._options); - delete baseOptions.multiOptions; - - for (i = 0; i < len; ++i) { - optionsArray[i] = L.extend({}, baseOptions, optionsArray[i]); - } - }, - - setLatLngs: function (latlngs) { - var i, len = latlngs.length, - multiOptions = this._options.multiOptions, - optionIdxFn = multiOptions.optionIdxFn, - fnContext = multiOptions.fnContext || this, - prevOptionIdx, optionIdx, - segmentLatlngs; - - this._originalLatlngs = latlngs; - - this.eachLayer(function (layer) { - this.removeLayer(layer); - }, this); - - for (i = 1; i < len; ++i) { - optionIdx = optionIdxFn.call( - fnContext, latlngs[i], latlngs[i - 1], i, latlngs); - - if (i === 1) { - segmentLatlngs = [latlngs[0]]; - prevOptionIdx = optionIdxFn.call(fnContext, latlngs[0], latlngs[0], 0, latlngs); - } - - segmentLatlngs.push(latlngs[i]); - - // is there a change in options or is it the last point? - if (prevOptionIdx !== optionIdx || i === len - 1) { - // Check if options is a function or an array - if (typeof multiOptions.options === "function") { - this.addLayer(L.polyline(segmentLatlngs, multiOptions.options(prevOptionIdx))); - } else { - this.addLayer(L.polyline(segmentLatlngs, multiOptions.options[prevOptionIdx])); - } - - prevOptionIdx = optionIdx; - segmentLatlngs = [latlngs[i]]; - } - } - - return this; - }, - - getLatLngs: function () { - return this._originalLatlngs; - }, - - getLatLngsSegments: function () { - var latlngs = []; - - this.eachLayer(function (layer) { - latlngs.push(layer.getLatLngs()); - }); - - return latlngs; - } -}); - -L.MultiOptionsPolyline = MultiOptionsPolyline; -L.multiOptionsPolyline = function (latlngs, options) { - return new MultiOptionsPolyline(latlngs, options); -}; - -})); diff --git a/Leaflet.MultiOptionsPolyline.min.js b/Leaflet.MultiOptionsPolyline.min.js deleted file mode 100644 index cfc727a..0000000 --- a/Leaflet.MultiOptionsPolyline.min.js +++ /dev/null @@ -1,2 +0,0 @@ -/*! Leaflet.MultiOptionsPolyline v1.0.0 26-11-2016 */ -!function(a,b){"function"==typeof define&&define.amd?define(["leaflet"],b):b("object"==typeof module&&module.exports?require("leaflet"):a.L)}(this,function(a){"use strict";var b=a.FeatureGroup.extend({initialize:function(a,b){var c=b.multiOptions.copyBaseOptions;this._layers={},this._options=b,(void 0===c||c)&&this._copyBaseOptions(),this.setLatLngs(a)},_copyBaseOptions:function(){var b,c,d=this._options.multiOptions,e=d.options,f=e.length;for(b=a.extend({},this._options),delete b.multiOptions,c=0;c Leaflet.MultiOptionsPolyline Demo - - - + +