Hi Kawish,
I think you have to apply a parseFloat() function to your arguments to turn them into floating point numbers. So, essentially your code is correct, apart from this parsing that is missing. (By the way, please note that Internet Explorer 11 does not support the Arrow Function you are using... but maybe we should consider that a non-issue - LOL)
Based on the research I have done to investigate your issue I have published a sample app using the corrected code below: ArcGIS JavaScript Tutorial - Use view.goTo() to zoom to given location
If you enter the coordinates 74.315 and 31.588, it will fly you directly to Lahore Fort, the fortified 16th-century Mughal citadel in Lahore, Pakistan.
So, your code should become:
let lon = document.getElementById("lon");
let lat = document.getElementById("lat");
let btnLocation = document.getElementById("btnlocation");
btnLocation.addEventListener('click', () => {
view.goTo({
target:[parseFloat(lon.value), parseFloat(lat.value)]
})
})
Does this solve your issue?
Best regards,
Egge-Jan