GithubHelp home page GithubHelp logo

toKey bug about modestmaps-js HOT 4 CLOSED

stamen avatar stamen commented on July 29, 2024
toKey bug

from modestmaps-js.

Comments (4)

RandomEtc avatar RandomEtc commented on July 29, 2024

Which browser/OS and which version of Modest Maps JS? Can you post a demo somewhere?

Do you have one map on the page, or many?

Does it work if your map is bigger? new mm.Point(256,256) is smaller than I've tested, perhaps that's the issue?

from modestmaps-js.

olehz avatar olehz commented on July 29, 2024

I tested Modest Maps JS v0.13.4 and v0.13.3

Windows/Browsers: Mozilla, Chrome, Opera.
And Safari from IPhone.

Example: http://nadoloni.com/mm.html

I think, that "toKey" return not unique values

from modestmaps-js.

RandomEtc avatar RandomEtc commented on July 29, 2024

Ah, oh dear. You're right:

new com.modestmaps.Coordinate(5605, 9261, 14).toKey()
1680518083
new com.modestmaps.Coordinate(5606, 9262, 14).toKey()
1680518083

I guess that hashing function isn't the right thing for Modest Maps. A short term solution is just to concatenate the row/col/zoom as a String. I liked the hashing because it was quite a bit faster than string manipulation in some browsers, but obviously correctness is more important than raw speed.

Try adding the following before instantiating your map, to override the default behavior until we can add a patch:

com.modestmaps.Coordinate.prototype.toKey = function () {
    return this.container().toString();
}

A better one might be involve bitwise hashing based on the known distributions of zoom, row and colum, e.g. this.zoom << 24 + this.column << 12 + this.row but I'm not going to bet on it without more testing since I got it wrong with the current function :)

from modestmaps-js.

RandomEtc avatar RandomEtc commented on July 29, 2024

Thanks again for reporting this bug! I just committed a very simple fix: 1b3a646

from modestmaps-js.

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.