Topic: JS API: get street name with
hello developers. how i can get that street name where is my unit with js API? thanks
hello developers. how i can get that street name where is my unit with js API? thanks
http://docs.gurtam.com/api/hosting/#wia … hod_public
var coordsc = {lat:pos.x, lon:pos.y};
wialon.util.Gis.getLocations(coordsc,function(code,locations){
if(code) {
console.log(wialon.core.Errors.getErrorText(code))
}
else {
console.log(locations);
}
});
thanks .... that is my code and it gives me invalit Input can you fix my problem?
maybe - coords Array of locations in form [{lat: X, lon: X}], link.
ok thanks i fix this problem.
but now i have one more problem >_< :
var myvarible = "0";
wialon.util.Gis.getLocations(coordsc,function(code,responceval) {
myvarible = responceval;
})
console.log(myvarible); // output is 0
i cant get responce on global. how i can do it?
var myvarible = "0";
wialon.util.Gis.getLocations(coordsc,function(code,responceval) {
myvarible = responceval;
console.log(myvarible); // output is 0
})
Callback is asynchronous.
yes i know bro, but i cant get value from this function. if you know can you give me example how i can get value from here or how i can work at this moment with asynchronous value?
for example you can send one more parameter to callback function
wialon.util.Gis.getLocations(coordsc,qx.lang.Function.bind(function(callback,code,responceval) {
callback(responceval);
}, this, this.doSmthWithMyVariable));
doSmthWithMyVariable: function(myVar) {
.....
}
wialon.util.Gis.getLocations(coordsc,qx.lang.Function.bind(function(callback,code,responceval) {callback(responceval);}, this, this.doSmthWithMyVariable));
doSmthWithMyVariable: function(myVar) {
alert(myVar);
}
console.log gives me error like this : Uncaught SyntaxError: Unexpected identifier;
what can i do?
It seems that you may have a fundamental misunderstanding when it comes to Ajax.
Ajax calls are set aside for some later time. The script carries on executing its code, and later on after Ajax has requested its content and received a response, only then (which is a long time after the rest of the script has finished) does the associated Ajax function get run.
So if you want to do something with the result in the callback function, it is inside of that callback function that you should do it, which can include calling other functions that you need too.
var myvarible = "0";
var myCallback =function(responceval){myvarible=responceval; console.log(myvarible);};
wialon.util.Gis.getLocations(coordsc,function(code,responceval) {
myCallback(responceval);
});
kopa yes i know what is responce and callback your example is like this :
wialon.util.Gis.getLocations(coordsc,function(code,responceval) {
ss(responceval);
});
function ss(arg) {
console.log(arg);
}
but i need make this callback "GLOBAL "varible. why? i need put it into comment like this :
var coordsc = [{lat:pos.y, lon:pos.x}];
var locations = "0";
wialon.util.Gis.getLocations(coordsc,function(code,responceval) {
locations = responceval;
});
$(document.body).append("<div id='loadeditlang' ><table> <tr><td>Name:</td><td> "+uname+"</td></tr> <tr><td>Device Type:</td><td> "+hwtype+"</td></tr> <tr><td>Unique ID:</td><td> "+unicid+"</td></tr> <tr><td>Phone:</td><td> "+phnum+"</td></tr> <tr><td>Last Message:</td><td> "+tm+"</td></tr> <tr><td>Location:</td><td> "+locations+"</td></tr> <tr><td>Speed:</td><td> "+speed+" km/h</td></tr> <tr><td>Altitude:</td><td> "+alt+" meters</td></tr> <tr><td>"+sattit+"</td><td> "+sat+"</td></tr> </table></div>");
$("#loadeditlang").css({position:'absolute', top:y, left:x});
google.maps.event.addListener(marker, 'mouseout', function() {
$("#loadeditlang").remove();
});
And why you couldn't place your jQuery calls withing getLocations callback? And all the additional variables such as uname and hwtype you may add as parameter in callback in a manner i show you before.
yes i try this but its work slow into callback. now i fix this problem. thanks all for help. i will write example
wialon.util.Gis.getLocations(coordsc,function(code,responceval) {givehim(responceval);}); function givehim(arg) {loaders(""+arg+"");}
function loaders(locations) {
if( ($('#loadeditlang').length)!== 0){$("#loadeditlang").remove();}
$(document.body).append("<div id='loadeditlang' ><table> <tr><td>Name:</td><td> "+uname+"</td></tr> <tr><td>Device Type:</td><td> "+hwtype+"</td></tr> <tr><td>Unique ID:</td><td> "+unicid+"</td></tr> <tr><td>Phone:</td><td> "+phnum+"</td></tr> <tr><td>Last Message:</td><td> "+tm+"</td></tr> <tr><td>Location:</td><td> "+locations+"</td></tr> <tr><td>Speed:</td><td> "+speed+" km/h</td></tr> <tr><td>Altitude:</td><td> "+alt+" meters</td></tr> <tr><td>"+sattit+"</td><td> "+sat+"</td></tr> </table></div>");
$("#loadeditlang").css({position:'absolute', top:y, left:x});
}