Skip to content

A Leaflet.js plugin to perform measurements when using a simple CRS (coordinate system).

License

Notifications You must be signed in to change notification settings

Conengmo/Leaflet.SimpleCRSMeasurement

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Leaflet.SimpleCRSMeasurement

A Leaflet.js plugin to perform measurements when using a simple CRS (coordinate system).

This is a fork of https://github.com/gokertanrisever/leaflet-ruler that I edited to work easily with L.CRS.Simple, when using non-standard maps like drawn maps or game maps.

screenshot

How to use

Add the dependencies to your map:

<link rel="stylesheet"  href="https://cdn.jsdelivr.net/gh/conengmo/Leaflet.SimpleCRSMeasurement/leaflet-ruler.css">
<script  src="https://cdn.jsdelivr.net/gh/conengmo/Leaflet.SimpleCRSMeasurement/leaflet-ruler.js"></script>

Load the control:

L.control.ruler().addTo(map);

Options

let options: {
    position: 'topright',         // Leaflet control position option
    circleMarker: {               // Leaflet circle marker options for points used in this plugin
        color: 'red',
        radius: 2
    },
    lineStyle: {                  // Leaflet polyline options for lines used in this plugin
        color: 'red',
        dashArray: '1,6'
    },
    // to get a meaningful distance you will have to provide a conversion factor:
    scale: 1.0,                   
    // custom function to return the distance as a string
    formatter: function(distance) {
        return distance.toFixed(1);            
    },
}
L.control.ruler(options).addTo(map);

About

A Leaflet.js plugin to perform measurements when using a simple CRS (coordinate system).

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published