text: !function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var o;"undefined"!=typeof window?o=window:"undefined"!=typeof global?o=global:"undefined"!=typeof self&&(o=self),o.geojson2svg=e()}}(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
  //index.js 
  (function() { 
  	var singles = ['Point', 'LineString', 'Polygon'];
  	var multies = ['MultiPoint', 'MultiLineString', 'MultiPolygon'];
  	function explode(g) {
  	  if( multies.indexOf(g.type) > -1) {
  	    return g.coordinates.map(function(part) {
  	      var single = {};
  	      single.type = g.type.replace('Multi','');
  	      single.coordinates = part;
          if(g.crs) single.crs = g.crs;
  	      return single;
  	    });  
  	  } else {
  	    return false;
  	  }
  	}
  	function implode(gs) {
  	  var sameType = gs.every(function(g) { 
  	    return singles.indexOf(g.type) > -1;
  	  })
      var crs = gs[0].crs || 0;
      var sameCrs = gs.every(function(g) {
        var gcrs = g.crs || 0;
        return gcrs == crs;
      });
  	  if(sameType && sameCrs) {
  	    var multi = {};
  	    multi.type = 'Multi' + gs[0].type;
  	    multi.coordinates = [];
        if(crs != 0) multi.crs = crs;
  	    gs.forEach(function(g) {
  	      multi.coordinates.push(g.coordinates);
  	    });
  	    return multi;
  	  } else {
  	    return false;
  	  }
  	};
  	var multigeojson = {
  	  explode: explode,
  	  implode: implode
  	};
  	if(typeof module !== 'undefined' && module.exports) {
  	  module.exports = multigeojson;
  	} else if(window) {
  	  window.multigeojson = multigeojson;
  	}
  })();
  
  },{}],2:[function(require,module,exports){
  module.exports = extend
  
  function extend() {
      var target = {}
  
      for (var i = 0; i < arguments.length; i++) {
          var source = arguments[i]
  
          for (var key in source) {
              if (source.hasOwnProperty(key)) {
                  target[key] = source[key]
              }
          }
      }
  
      return target
  }
  
  },{}],3:[function(require,module,exports){
  //converter.js
  var multi = require('multigeojson');
  function getCoordString(coords,res,origin) {
    //origin - svg image origin 
    var coordStr = coords.map(function(coord) {
      return (coord[0] - origin.x)/res + ',' + (origin.y - coord[1])/res;
    });
    return coordStr.join(' ');
  }
  function addAttributes(ele,attributes) {
    var part = ele.split('/>')[0];
    for(var key in attributes) {
      if(attributes[key]) {
        part += ' ' + key + '="' + attributes[key] + '"';
      }
    }
    return part + ' />';
  }
  
  function point(geom,res,origin,opt) {
    var r = opt && opt.r ? opt.r : 1;
    var path = 'M' + getCoordString([geom.coordinates],res,origin)
      +' m'+ -r+ ',0'+ ' a'+r+','+ r + ' 0 1,1 '+ 2*r + ','+0
      +' a'+r+','+ r + ' 0 1,1 '+ -2*r + ','+0;
    return [path];
  }
  function multiPoint(geom,res,origin,opt) {
    var explode = opt && opt.hasOwnProperty('explode') ? opt.explode : false;
    var paths = multi.explode(geom).map(function(single) {
      return point(single,res,origin,opt)[0];
    });
    if(!explode) return [paths.join(' ')];
    return paths;
  
  }
  function lineString(geom,res,origin,otp) {
    var coords = getCoordString(geom.coordinates,res,origin);
    var path = 'M'+ coords;  
    return [path];
  }
  function multiLineString(geom,res,origin,opt) {
    var explode = opt && opt.hasOwnProperty('explode') ? opt.explode : false;
    var paths = multi.explode(geom).map(function(single) {
      return lineString(single,res,origin,opt)[0];
    });
    if(!explode) return [paths.join(' ')];
    return paths;
  }
  function polygon(geom,res,origin,opt) {
    var mainStr,holes,holeStr;
    mainStr = getCoordString(geom.coordinates[0],res,origin);
    if (geom.coordinates.length > 1) {
      holes = geom.coordinates.slice(1,geom.coordinates.length);
    }
    var path = 'M'+ mainStr;
    if(holes) {
      for(var i=0;i<holes.length; i++) {
        path += ' M' +  getCoordString(holes[i],res,origin);
      }
    }
    path += 'Z';
    return [path];
  }
  function multiPolygon(geom,res,origin,opt) {
    var explode = opt.hasOwnProperty('explode') ? opt.explode : false;
    var paths = multi.explode(geom).map(function(single) {
      return polygon(single,res,origin,opt)[0];
    });
    if(!explode) return [paths.join(' ').replace(/Z/g,'') + 'Z'];
    return paths;
  }
  module.exports = {
    Point: point,
    MultiPoint: multiPoint,
    LineString: lineString,
    MultiLineString: multiLineString,
    Polygon: polygon,
    MultiPolygon: multiPolygon
  };
  
  },{"multigeojson":1}],4:[function(require,module,exports){
  var extend = require('xtend'),
  	converter = require('./converter.js');
  
  //g2svg as geojson2svg (shorthand)
  var g2svg = function(viewportSize,options) {
    if(!viewportSize) return;
    this.viewportSize = viewportSize;
    this.options = options || {};
    this.mapExtent = this.options.mapExtent ||
      {
        left: -20037508.342789244,
        right: 20037508.342789244,
        bottom: -20037508.342789244,
        top: 20037508.342789244
      };
    this.res = this.calResolution(this.mapExtent,this.viewportSize,
      this.options.fitTo);
  };
  g2svg.prototype.calResolution = function(extent,size,fitTo) {
    var xres = (extent.right - extent.left)/size.width;
    var yres = (extent.top - extent.bottom)/size.height;
    if (fitTo) { 
      if (fitTo.toLowerCase() === 'width') {
        return xres;
      } else if (fitTo.toLowerCase() === 'height') {
        return yres;
      } else {
        throw new Error('"fitTo" option should be "width" or "height" ');
      }
    } else {
      return Math.max(xres,yres);
    }
  };
  g2svg.prototype.convert = function(geojson,options)  {
    var opt = extend(extend({},this.options), options || {});
    var multiGeometries = ['MultiPoint','MultiLineString','MultiPolygon'];
    var geometries = ['Point', 'LineString', 'Polygon'];
    var svgElements = [];
    if (geojson.type == 'FeatureCollection') {
      for(var i=0; i< geojson.features.length; i++) {
        svgElements = svgElements.concat(
          this.convertFeature(geojson.features[i],opt));
      }
    } else if (geojson.type == 'Feature') {
      svgElements = this.convertFeature(geojson,opt);
    } else if (geojson.type == 'GeomtryCollection') {
      for(var i=0; i< geojson.geometries.length; i++) {
        svgElements = svgElements.concat(
          this.convertGeometry(geojson.geometries[i],opt));
      }
    } else if (converter[geojson.type]) {
      svgElements = this.convertGeometry(geojson,opt);
    } else {
      return;
    }
    if(opt.callback) opt.callback.call(this,svgElements);
    return svgElements;
  };
  g2svg.prototype.convertFeature = function(feature,options) {
    if(!feature && !feature.geometry) return;
    var opt = extend(extend({},this.options), options || {});
    opt.attributes = opt.attributes || {};
    opt.attributes.id = opt.attributes.id || feature.id || null;
    return this.convertGeometry(feature.geometry,opt);
  };
  g2svg.prototype.convertGeometry = function(geom,options) {
    if(converter[geom.type]) {
      var opt = extend(extend({},this.options), options || {});
      var output = opt.output || 'svg';
      var paths = converter[geom.type].call(this,geom,
        this.res,
        {x:this.mapExtent.left,y:this.mapExtent.top},
        opt
      );
      var svgJsons,svgEles;
      if (output.toLowerCase() == 'svg') {
        svgJsons = paths.map(function(path) {
          return pathToSvgJson(path,geom.type,opt.attributes,opt);
        });
        svgEles = svgJsons.map(function(json) {
          return jsonToSvgElement(json,geom.type);
        });
        return svgEles;
      } else {
        return paths;
      }
    } else {
      return;
    }
  };
  var pathToSvgJson = function(path,type,attributes,opt) {
    var svg = {};
    var forcePath = opt && opt.hasOwnProperty('forcePath') ? opt.forcePath
       : true;
    if((type == 'Point' || type == 'MultiPoint') && !forcePath) {
      svg['cx'] = path.split(',')[0];
      svg['cy'] = path.split(',')[1];
      svg['r'] = opt && opt.r ? opt.r : '1';
    } else {
      svg = {d: path};
      if(type == 'Polygon' || type == 'MultiPolygon') {
        svg['fill-rule'] == 'evenodd'; 
      } 
    }
    for (var key in attributes) {
      svg[key]= attributes[key];
    }
    return svg;
  };
  var jsonToSvgElement = function(json,type,opt) {
    var forcePath = opt && opt.hasOwnProperty('forcePath') ? opt.forcePath
       : true;
    var ele ='<path';
    if((type == 'Point' || type == 'MultiPoint') && !forcePath) {
      ele = '<circle';
    }
    for(var key in json) {
      ele += ' ' + key +'="' + json[key] + '"';
    }
    ele += '/>';
    return ele;
  };
  
  module.exports = g2svg;
  
  },{"./converter.js":3,"xtend":2}],5:[function(require,module,exports){
  var g2svg = require('./instance.js');
  var geojson2svg = function(viewportSize,options) {
    if(!viewportSize) return;
    return new g2svg(viewportSize,options);
  };
  
  module.exports = geojson2svg;
  
  },{"./instance.js":4}]},{},[5])(5)
  });
  
  
  //# sourceMappingURL=geojson2svg.js.map