Mock call to nominatim for cucumber
This commit is contained in:
parent
bd99127600
commit
5ebbacf444
2 changed files with 8 additions and 2 deletions
|
|
@ -5,12 +5,12 @@ OSM = {};
|
||||||
OSM.Locator = function(){
|
OSM.Locator = function(){
|
||||||
|
|
||||||
var geolocalize = function(callback){
|
var geolocalize = function(callback){
|
||||||
navigator.geolocation.getCurrentPosition(function(position) {
|
navigator.geolocation.getCurrentPosition(function(position) {
|
||||||
var lat=position.coords.latitude,
|
var lat=position.coords.latitude,
|
||||||
lon=position.coords.longitude;
|
lon=position.coords.longitude;
|
||||||
$.getJSON("https://nominatim.openstreetmap.org/reverse?format=json&lat="+lat+"&lon="+lon+"&addressdetails=3", function(data){
|
$.getJSON("https://nominatim.openstreetmap.org/reverse?format=json&lat="+lat+"&lon="+lon+"&addressdetails=3", function(data){
|
||||||
return callback(data.display_name, position.coords);
|
return callback(data.display_name, position.coords);
|
||||||
});
|
});
|
||||||
},errorGettingPosition);
|
},errorGettingPosition);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,5 +9,11 @@ When /^I allow geolocation$/ do
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
$.getJSON = function(url, myCallback) {
|
||||||
|
if (url === "https://nominatim.openstreetmap.org/reverse?format=json&lat=42.42424242&lon=3.14159&addressdetails=3") {
|
||||||
|
return myCallback({display_name: "locator address"});
|
||||||
|
}
|
||||||
|
};
|
||||||
JS
|
JS
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue