I want to redirect by geolocation and i try with this javascript function and it works fine:
function showPosition(pos)
{
if (pos.coords.latitude >= 10.4696404 && pos.coords.longitude <= -66.8037185)
{
window.location = 'http://www.website.com/page1.html';
}
else{
window.location = 'http://www.website.com/page2.html';
}
}
but when i try to use a switch case do not work, what is wrong here?
function showPosition(pos)
{
var lat = position.coords.latitude;
var lon = position.coords.longitude;
switch(lat + "|" + lon){
case lat >="10.4696404"|lon <="-66.8037185"://Caracas
window.location = 'http://www.website.com/page1.html';
break;
case lat >="10.0618663"|lon <="-69.3628479"://BARQUISIMETO
window.location = 'http://www.website.com/page2.html';
break;
case lat >="10.6335502"|lon <="-71.6769433": //MARACAIBO
window.location = 'http://www.website.com/page3.html';
break;
default
window.location = 'http://www.website.com/';
}
}