Leaflet / Leaflet.VectorGrid

Display gridded vector data (sliced GeoJSON or protobuf vector tiles) in Leaflet 1.0.0
593 stars 192 forks source link

LeafLet 1.4.0 does not accept numbers in scientific notation #199

Closed jmvanel closed 5 years ago

jmvanel commented 5 years ago

Like `"lat": "4.84029E1" ,

`where "48.4029" works.

I have to do this in my code, and I think it is better in LeafLet code: Number( lat )

IvanSanchez commented 5 years ago

That's because "4.48029E1" is a String, not a number (and that's javascript, not specific to Leaflet). Try { "lat": 4.84029E1 } paying attention to your quotes, and do read https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/parseFloat

jmvanel commented 5 years ago

That's not a big deal, but I still think that it should be done: there is an automatic conversion in Leaflet from "48.4029" to the number 48.4029 , why not from "4.48029E1" to 4.48029E1 ?

IvanSanchez commented 5 years ago

No, again automatic type casting is a JS thing, not a Leaflet thing. Leaflet works as expected when feeding strings to function/method calls that accept numbers anyway, there's no need for extra manipulation. See e.g. https://plnkr.co/edit/J8oRqoKnV4DBjdXWItxO?p=preview