Skip to content

Commit

Permalink
Merge pull request #23 from davidlukerice/gh-pages
Browse files Browse the repository at this point in the history
Add optional importUrl to Shapefile method signature
  • Loading branch information
calvinmetcalf committed May 14, 2015
2 parents c3bbcab + 344bba4 commit 8c69a68
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ to be done in a worker, you'll need [catiline](https://github.com/calvinmetcalf/
usage:

```javascript
new L.Shapefile(arrayBuffer or url[,options]);
new L.Shapefile(arrayBuffer or url[,options][,importUrl]);

L.shapefile(arrayBuffer or url[,options]);
L.shapefile(arrayBuffer or url[,options][,importUrl]);
```

Options are passed to L.Geojson as is. First argument is either an array buffer of a zipped shapefile,
the url to a zipped shapefile, or the url to file.shp (this assumes file.dbf exists).
the url to a zipped shapefile, or the url to file.shp (this assumes file.dbf exists). The importUrl parameter allows you to change where a worker loads in `shp.js` when using [catiline](https://github.com/calvinmetcalf/catiline) and defaults to `shp.js`.

To easily try this out using your own shapefile, see the demo at [leaflet.calvinmetcalf.com](http://leaflet.calvinmetcalf.com/), where you can drag-and-drop your own shapefile and have it displayed on the map.
8 changes: 4 additions & 4 deletions leaflet.shpfile.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
L.Shapefile =L.GeoJSON.extend({
initialize: function (file, options) {
initialize: function (file, options, importUrl) {
if(typeof cw !== 'undefined'){
this.worker = cw(function(data,cb){
importScripts('shp.js');
importScripts(importUrl || 'shp.js');
shp(data).then(cb);
});
}
Expand Down Expand Up @@ -33,6 +33,6 @@ L.Shapefile =L.GeoJSON.extend({
}
});

L.shapefile= function(a,b){
return new L.Shapefile(a,b);
L.shapefile= function(a,b,c){
return new L.Shapefile(a,b,c);
}

0 comments on commit 8c69a68

Please sign in to comment.