AnsweredAssumed Answered

Test for NaN or undefined Coordinates?

Question asked by cleotokos on Nov 19, 2015
Latest reply on Nov 19, 2015 by cleotokos

I have a function that grabs coordinates from a text input box, and zooms to that point using centerAndZoom. I want to detect if the user enters something invalid, so I can pop up an alert informing them of the valid format, and abort the zoom. Currently it zooms to NaN, NaN if something invalid is entered.


The point retrieved from the textbox is called zoomPoint. I've tried:


if (zoomPoint === "undefined")

if (zoomPoint === "NaN")

if (zoomPoint === null)


if ((zoomPoint.x === "undefined") || (zoomPoint.y === "undefined"))

if ((zoomPoint.x === "NaN") || (zoomPoint.y === "NaN"))

if ((zoomPoint.x === null) || (zoomPoint.y === null))


None of these work when something invalid is entered, and the map zooms to coordinates NaN, NaN. When I popup an alert box containing zoompoint.x or zoompoint.y, the value shows as undefined - why doesn't the test if ((zoomPoint.x === "undefined") || (zoomPoint.y === "undefined")) work then?