Giter Club home page Giter Club logo

Comments (4)

PaulLeCam avatar PaulLeCam commented on May 20, 2024

What are quadkeys?
The <Map /> component passes its props as options to the Leaflet constructor, so any option supported by Leaflet should work the same way.

from react-leaflet.

baziz avatar baziz commented on May 20, 2024

Quadkeys are tile references that are encapsulated in one string, in contrast to the more common tile references that happen with x / y / zoom https://msdn.microsoft.com/en-us/library/bb259689.aspx

In order to accommodate that type of URL, I extended your TileLayer component

class CustomTileLayer extends TileLayer {

  componentWillMount() {

    super.componentWillMount();
    const { map, url, ...props } = this.props;
    this.leafletElement.__proto__.getTileUrl = function (tilePoint) {

                this._adjustTilePoint(tilePoint);
                var myUrl = this._url.replace(/{s}/, 0).replace(/{q}/, 
                this._quadKey(tilePoint.x, tilePoint.y, this._getZoomForUrl()));
                return myUrl;

                };

    this.leafletElement.__proto__._quadKey = function (x, y, z) {

                    var quadKey = [];
                    for (var i = z; i > 0; i--) {
                        var digit = '0';
                        var mask = 1 << (i - 1);
                        if ((x & mask) != 0) {
                            digit++;
                        }
                        if ((y & mask) != 0) {
                            digit++;
                            digit++;
                        }
                        quadKey.push(digit);
                    }
                    return quadKey.join('');
                };
  } 

with the TileLayer component containing a url that has {q} in it and relabeled "CustomTileLayer"

from react-leaflet.

texas697 avatar texas697 commented on May 20, 2024

@baziz
I need to use this can you show me how you are using this pplease?

from react-leaflet.

baziz avatar baziz commented on May 20, 2024

@texas697 Been a couple years man - I'm sorry, I wish I could be of more help, but I think the code should be enough to get you going.

from react-leaflet.

Related Issues (20)

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.