Code Monkey home page Code Monkey logo

Comments (3)

ppete2 avatar ppete2 commented on July 30, 2024

Hi,
I'm afraid I can't help you with your issue. PolylineMeasure works with the latest version of Leaflet but it's just designed to work within "real world" maps. If you want to make it run also for phantasie maps you've to try to adapt the code for your world's coordinate system.

from leaflet.polylinemeasure.

Sand2Silicon avatar Sand2Silicon commented on July 30, 2024

Thanks for the fast response, that gives me some indication of the problem! I think Papyri handles this transformation on lines 54-78 of index.html ( https://github.com/jason-green-io/papyri/blob/master/template/index.html ) shown below.

Would you guess PolylineMeasure is most likely failing because the positive/negative quadrants of the coordinate system are arranged differently, or specifically because the world is "flat" and PolylineMeasure is trying to calculate an arc? If it's the latter case, maybe I can add an option flag for it to calculate "simple lines" without using the Great-Circle formulas.

Can you point me to the relevant portion of your code I might have to change, or at least to a starting point? I took a look at several other measuring plugins and yours is the best one I saw by far! If I can I'll adapt yours to work.

(Papyri index.html lines 54-78)

    factor = 1 / 2 ** 16
    L.CRS.pr = L.extend({}, L.CRS.Simple, {
        projection: L.Projection.LonLat,
        transformation: new L.Transformation(
            factor, 
            64 * factor, 
            factor, 
            64 * factor),
        scale: function(zoom) {
            return Math.pow(2, zoom);
        },

        zoom: function(scale) {
            return Math.log(scale) / Math.LN2;
        },

        distance: function(latlng1, latlng2) {
            var dx = latlng2.lng - latlng1.lng,
            dy = latlng2.lat - latlng1.lat;
            
            return Math.sqrt(dx * dx + dy * dy);
        },
        
        infinite: true
    });

from leaflet.polylinemeasure.

ppete2 avatar ppete2 commented on July 30, 2024

Well, the main function for drawing the arc lines is _"polylineArc" and the funtion to draw the arrows is _"drawArrow"

But since the plugin is using formulas which are restricted to the real-world coordinate system you have to create your own modified plugin to handle fictional coordinate systems. I won't implement them into PolylineMeasure, sorry. Thanks for understanding.

from leaflet.polylinemeasure.

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.