Comments (4)
Custom distance, as in, showing a different unit than meters?
from leaflet.editablehandlers.
Hey seabre,
Not all, I still wish to use meters. Sorry if I didn't describe it properly.
I am using a game map with custom tiles and the maximum distance between each side of the map is 2km.
When using the measuring tool, I measure from point A to point B, and it gives me a crazy distance of 10231840.88m.
How would I go about defining the maximum distance between each end of the map? So instead of such a large distance, it will give me, for example, 200m.
Also, I tried using crs: L.CRS.Simple for simple latlng (which I use already for the map) however this does not work and it throws the following error: "Uncaught TypeError: Cannot call method 'latLngToPoint' of undefined".
I know I'm shocking at describing things, so I'll be happy to do a jsfiddle if need Be.
Cheers.
from leaflet.editablehandlers.
The measuring tool uses Leaflet's L.LatLng.distanceTo to calculate the distance between to LatLngs. In your case, since you're not using real latitudes and longitudes (I guess?), this method will give bogus values back.
A hack you could try is to overwrite L.LatLng.prototype.distanceTo with whatever distance calculation that suites you (I guess it would be an application of the Pythagorean theorem).
It could be nice to add functionality to the measuring tool so that you could give it your own function for calculating distances.
from leaflet.editablehandlers.
Hey perliedman,
Thanks for pointing me to the distanceTo function. My Javascript skills are limited but I will see what I can come up with.
Cheers buddy.
from leaflet.editablehandlers.
Related Issues (6)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from leaflet.editablehandlers.