1
0
mirror of https://github.com/wavded/js-shapefile-to-geojson synced 2024-11-23 14:34:54 +00:00

Merge pull request #11 from mcclintock-lab/add-worker-jsroot

Add jsRoot constructor option
This commit is contained in:
Marc Harter 2013-09-09 16:38:29 -07:00
commit ad2ca227e8

View File

@ -1,14 +1,18 @@
(function(window,undefined){ (function(window,undefined){
if(window.document && window.Worker){ if(window.document && window.Worker){
var worker = new Worker("shapefile.js") var worker = null;
var Shapefile = function(o, callback){ var Shapefile = function(o, callback){
var var
w = this.worker = worker,
t = this, t = this,
o = typeof o == "string" ? {shp: o} : o o = typeof o == "string" ? {shp: o} : o
if (!worker) {
var path = (o.jsRoot || "") + "shapefile.js"
var w = worker = this.worker = new Worker(path)
}
w.onmessage = function(e){ w.onmessage = function(e){
t.data = e.date t.data = e.date
if(callback) callback(e.data) if(callback) callback(e.data)