Leaflet / Leaflet.draw

Vector drawing and editing plugin for Leaflet
https://leaflet.github.io/Leaflet.draw/docs/leaflet-draw-latest.html
MIT License
1.97k stars 992 forks source link

Circle Object -> n.toFixed is not a function #741

Open Stan92 opened 7 years ago

Stan92 commented 7 years ago

How to reproduce

Hi, Using the example, when I start drawing a circle object, I get this following error.

GeometryUtil.js:45 Uncaught TypeError: n.toFixed is not a function at Object.formattedNumber (GeometryUtil.js:45) at Object.readableDistance (GeometryUtil.js:130) at NewClass._onMouseMove (Draw.Circle.js:68) at NewClass.fire (Events.js:186) at NewClass._touchEvent (TouchEvents.js:78) at NewClass._onTouchMove (TouchEvents.js:151) at handler (DomEvent.js:72) at Object._handlePointer (DomEvent.Pointer.js:107) at Object. (DomEvent.Pointer.js:115)

ddproxy commented 7 years ago

Are you using Leaflet 1.0.x or 1.1.x?

Stan92 commented 7 years ago

I simply use the online demo I ve changed the code by adding parseFloat(n).toFixed...

borisyue1 commented 7 years ago

I'm getting the same error too using Leaflet 1.0.3 and Leaflet Draw 0.4.10.

ddproxy commented 7 years ago

Yup, got the same error. Looking into it.

sirensoft commented 7 years ago

I am too. It happen in my chrome console while I draw a circle.

seedgabo commented 7 years ago

same issue here!. also Only happens to me if zoom more than 14 :(

jbccollins commented 7 years ago

+1

jbccollins commented 7 years ago

PR is up

manolino commented 7 years ago

Solved extending String class methods to handle toFixed method also withstring variables, with this code to :

if (!String.toFixed) {
   String.prototype.toFixed = function (decimals) {
      return parseFloat(this.toString()).toFixed(decimals);
   }
};
jbccollins commented 7 years ago

@manolino I'd be hesitant to extend built-in JS functions in a publicly available npm package. What if other authors decide to do the same and someone ends up needing to use Leaflet.draw and some other package that also provides a definition for String.toFixed? Could lead to some frustration for some devs.

derouck commented 7 years ago

I see this bug as well, the PR #747 fixes it completely

sgentile commented 7 years ago

I'm assuming this will make 0.4.11 - just fyi - we get this with leaflet 1.0.3 and 1.2.0 and are staying with 0.4.9 until resolved

vmagalhaes commented 7 years ago

I'm using the Leaflet draw 0.4.10 and Leaflet 1.0.3 and this problem happen with me, when I will use the circle the app crash, what can I do? @sgentile

sgentile commented 7 years ago

Go back to version 0.4.9 worked for me

On Aug 9, 2017 10:23 AM, "Victor Magalhães" notifications@github.com wrote:

I'm using the Leaflet draw 0.4.10 and Leaflet 1.0.3 and this problem happen with me, when I will use the circle the app crash, what can I do? @sgentile https://github.com/sgentile

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Leaflet/Leaflet.draw/issues/741#issuecomment-321270670, or mute the thread https://github.com/notifications/unsubscribe-auth/AAIFNBh2VdFJd-iOItteEf00qtGLydDbks5sWcDjgaJpZM4OKL3K .

vmagalhaes commented 7 years ago

Yeh @sgentile I do this, worked for me too. thx