diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..fd4f2b0 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +node_modules +.DS_Store diff --git a/README.md b/README.md index 704ee92..8640c2d 100644 --- a/README.md +++ b/README.md @@ -1,24 +1,27 @@ Leaflet.functionaltilelayer =========================== +For use with Leaflet 1.0.1. + Leaflet tile layer with functionally defined URL and support for promises. A typical use case is fetching tiles asynchronously, with an ajax request or IndexedDB query. ## Usage -Use it like any other tile layer, but instead of providing a `urlTemplate` as -the first argument, provide a function. The function should return either the + +Use it like any other tile layer, but instead of providing a `urlTemplate` as +the first argument, provide a function. The function should return either the tile URL as a string, or a promise which resolves to a string. ```javascript var funcLayer = new L.TileLayer.Functional(function (view) { - var url = 'http://otile{3}.mqcdn.com/tiles/1.0.0/map/{0}/{1}/{2}.jpg' - .replace('{0}', view.zoom) - .replace('{1}', view.tile.row) - .replace('{2}', view.tile.column) - .replace('{3}', view.subdomain); - + var url = 'http://{s}.tile.osm.org/{z}/{x}/{y}.png' + .replace('{z}', view.zoom) + .replace('{y}', view.tile.row) + .replace('{x}', view.tile.column) + .replace('{s}', view.subdomain); + return url; }); ``` @@ -40,10 +43,10 @@ view = { ``` For an example of the code above, see the [basic example] -(http://ismyrnow.github.com/Leaflet.functionaltilelayer/example/basic.html). +(example/basic.html). For an example of using promises, see the [promise example] -(http://ismyrnow.github.com/Leaflet.functionaltilelayer/example/promise.html). +(example/promise.html). ## Thanks @@ -53,4 +56,4 @@ which were the inspiration for this plugin. ## License Leaflet.functionaltilelayer is free software, and may be redistributed under -the MIT-LICENSE. \ No newline at end of file +the MIT-LICENSE. diff --git a/example/basic.html b/example/basic.html index 766ffdb..e493ca3 100644 --- a/example/basic.html +++ b/example/basic.html @@ -3,8 +3,8 @@