I have a map on the link below:
http://gis.xyz/openlayers/openlayer.html The map works well, however there is one thing what is frustrating me. When I load the page and the first thing what I try to do on the map is pan the map window change to white and the coordinates change to NaN, NaN. If I start with zoom in or out the map and the pan function work as well. Is there anybody who can provide me a solution?


Make sure that your view center coordinates and zoom level are numbers. Currently they are strings (sometimes empty strings even), which leads to unexpected behavior. Something like

var zoomy = parseFloat(getParameterByName('zoomy') || 0);
var laty = parseFloat(getParameterByName('laty') || 0);
var lony = parseFloat(getParameterByName('lony') || 0);

Also make sure that your view center coordinates are in EPSG:3857 and x, y order. If it was your intention to use latitude and longitude (as your variable names suggest), then you'll have to change your view configuration:

view: new ol.View({
    center: ol.proj.transform([lony, laty], 'EPSG:4326', 'EPSG:3857'),
    zoom: zoomy
| improve this answer | |
  • I changed them to numbers and it solved the problem. Thank you. – Tamas Kosa Feb 4 '15 at 9:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.