GithubHelp home page GithubHelp logo

ismyrnow / leaflet.functionaltilelayer Goto Github PK

View Code? Open in Web Editor NEW
72.0 72.0 15.0 69 KB

Leaflet tile layer with functionally defined URL and support for promises.

License: MIT License

JavaScript 43.29% HTML 56.71%

leaflet.functionaltilelayer's People

Contributors

ismyrnow avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

leaflet.functionaltilelayer's Issues

_tileFunction is global

A great plugin! But _tileFunction is made global in initialize, limiting the number of layers of this type to just one.

I replaced it with this._tileFunction = tileFunction;

idem on line 33 return this._tileFunction(view);

Applying for project maintaining role

Hi, I've benefitted from this plugin in a project when I had started out mapping. Just revisited it with an idea in mind and saw the callout for maintainers. Would like to apply for the same. Please feel free to get in touch, ask questions etc. I'll see if I can find the exact page where I'd applied this plugin.

`Uncaught TypeError: Object #<Object> has no method 'fire'`

When I try to use your layer with promises I get an error saying:

Uncaught TypeError: Object #<Object> has no method 'fire' leaflet.functional.tilelayer.js:55
(anonymous function) leaflet.functional.tilelayer.js:55
(anonymous function) jquery.js:3069
fire jquery.js:2913 
self.fireWith jquery.js:3025
deferred.(anonymous function) jquery.js:3114

Where should fire come from and what should it exactly do?

Thanks!

Multiple Functional Layers

Adding a second functional tile layers seems to conflict with the first.

I dynamically add a second functional tile layer, but after I remove it, the first functional tile layer return tile URLs with paths to tiles from the second layer I just removed.

Virtual Pull Request: MaxNativeResolution

I seem to have some security issues with issuing pull requests, but here is my fixed up source:

L.TileLayer.Functional = L.TileLayer.extend({

    _tileFunction: null,

    initialize: function (tileFunction, options) {
        this._tileFunction = tileFunction;
        L.Util.setOptions(this, options);
    },

    getTileUrl: function (tilePoint) {
        // Note: bbox code untested; pulled from TileLayer.WMS
        var map = this._map,
            crs = map.options.crs,
            tileSize = this.options.tileSize,
            //zoom = this._map.getZoom(), // remove
            zoom = tilePoint.z,  // add
            nwPoint = tilePoint.multiplyBy(tileSize),
            sePoint = nwPoint.add(new L.Point(tileSize, tileSize)),
            nw = crs.project(map.unproject(nwPoint, zoom)),
            se = crs.project(map.unproject(sePoint, zoom)),
            bbox = [nw.x, se.y, se.x, nw.y].join(','),
            view = {
                bbox: bbox,
                width: tileSize,
                height: tileSize,
                zoom: zoom,
                tile: {
                    row: tilePoint.y,
                    column: tilePoint.x
                },
                subdomain: this._getSubdomain(tilePoint)
            };

        return this._tileFunction(view);
    },

    _loadTile: function (tile, tilePoint) {
    tile._layer = this;
    tile.onload = this._tileOnLoad;
    tile.onerror = this._tileOnError;

    this._adjustTilePoint(tilePoint);
    var tileUrl = this.getTileUrl(tilePoint);


        if (typeof tileUrl === "string") {
            tile.src = tileUrl;
        } else if (tileUrl) {
            // assume jQuery.Deferred
            tileUrl.done(function (tileUrl) {
                tile.src = tileUrl;
            });
        }
    }
});

L.tileLayer.functional = function (tileFunction, options) {
    return new L.TileLayer.Functional(tileFunction, options);
};

maxNativeZoom in functional tile layer

It seems I can pass minZoom and maxZoom as options into the functional tile layer, but passing in maxNativeZoom doesn't behave like it does in TileLayer

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.