Skip to content

CRS.Simple + distanceTo() = wrong distance #1442

@Fedik

Description

@Fedik

I tries make some fake map, so I use L.CRS.Simple

there I need possibility to get distance between two points on the map, but the method distanceTo() count the distance depend of Earth that have no sense with L.CRS.Simple

as temporary solution I use:

L.LatLng.prototype.distanceToCRSSimple = function(other) {
    other = L.latLng(other);
    var lngS = 0, latS = 0;

    lngS = other.lng - this.lng;
    lngS = lngS * lngS;

    latS = other.lat - this.lat;
    latS = latS * latS;

    return Math.sqrt(lngS + latS);
};

hope you will find better solution in future

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions