1

JS API: get street name with

(20/10/2012 14:52:13 отредактировано unitedsecurity)

Тема: JS API: get street name with

hello developers. how i  can get that street name where is my unit with js API? thanks

Великий и ужасный Гиоргий Каладзе
2

JS API: get street name with

Re: JS API: get street name with

http://docs.gurtam.com/api/hosting/#wia … hod_public

Development Department
Gurtam
3

JS API: get street name with

Re: JS API: get street name with

 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?

Великий и ужасный Гиоргий Каладзе
4

JS API: get street name with

Re: JS API: get street name with

maybe - coords Array of locations in form [{lat: X, lon: X}], link.

Mobile Development
Gurtam
5

JS API: get street name with

Re: JS API: get street name with

ok thanks i fix this problem.

Великий и ужасный Гиоргий Каладзе
6

JS API: get street name with

Re: JS API: get street name with

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?

Великий и ужасный Гиоргий Каладзе
7

JS API: get street name with

Re: JS API: get street name with

var myvarible = "0";
wialon.util.Gis.getLocations(coordsc,function(code,responceval) {
    myvarible = responceval;
    console.log(myvarible); // output is 0

})

Callback is asynchronous.

Mobile Development
Gurtam
8

JS API: get street name with

Re: JS API: get street name with

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?

Великий и ужасный Гиоргий Каладзе
9

JS API: get street name with

Re: JS API: get street name with

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) {
    .....
}

Development Department
Gurtam
10

JS API: get street name with

Re: JS API: get street name with

 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?

Великий и ужасный Гиоргий Каладзе
11

JS API: get street name with

Re: JS API: get street name with

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);
});
Mobile Development
Gurtam
12

JS API: get street name with

(17/10/2012 15:57:57 отредактировано unitedsecurity)

Re: JS API: get street name with

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>&nbsp;&nbsp;&nbsp;"+uname+"</td></tr>          <tr><td>Device Type:</td><td>&nbsp;&nbsp;&nbsp;"+hwtype+"</td></tr>  <tr><td>Unique ID:</td><td>&nbsp;&nbsp;&nbsp;"+unicid+"</td></tr>        <tr><td>Phone:</td><td>&nbsp;&nbsp;&nbsp;"+phnum+"</td></tr>     <tr><td>Last Message:</td><td>&nbsp;&nbsp;&nbsp;"+tm+"</td></tr>     <tr><td>Location:</td><td>&nbsp;&nbsp;&nbsp;"+locations+"</td></tr>      <tr><td>Speed:</td><td>&nbsp;&nbsp;&nbsp;"+speed+" km/h</td></tr>   <tr><td>Altitude:</td><td>&nbsp;&nbsp;&nbsp;"+alt+" meters</td></tr>       <tr><td>"+sattit+"</td><td>&nbsp;&nbsp;&nbsp;"+sat+"</td></tr>    </table></div>");
           $("#loadeditlang").css({position:'absolute',  top:y, left:x});
           
            google.maps.event.addListener(marker, 'mouseout', function() {
             $("#loadeditlang").remove();
            
            });
Великий и ужасный Гиоргий Каладзе
13

JS API: get street name with

Re: JS API: get street name with

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.

Development Department
Gurtam
14

JS API: get street name with

(20/10/2012 14:51:57 отредактировано unitedsecurity)

Re: JS API: get street name with

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>&nbsp;&nbsp;&nbsp;"+uname+"</td></tr>          <tr><td>Device Type:</td><td>&nbsp;&nbsp;&nbsp;"+hwtype+"</td></tr>  <tr><td>Unique ID:</td><td>&nbsp;&nbsp;&nbsp;"+unicid+"</td></tr>        <tr><td>Phone:</td><td>&nbsp;&nbsp;&nbsp;"+phnum+"</td></tr>     <tr><td>Last Message:</td><td>&nbsp;&nbsp;&nbsp;"+tm+"</td></tr>     <tr><td>Location:</td><td>&nbsp;&nbsp;&nbsp;"+locations+"</td></tr>      <tr><td>Speed:</td><td>&nbsp;&nbsp;&nbsp;"+speed+" km/h</td></tr>   <tr><td>Altitude:</td><td>&nbsp;&nbsp;&nbsp;"+alt+" meters</td></tr>       <tr><td>"+sattit+"</td><td>&nbsp;&nbsp;&nbsp;"+sat+"</td></tr>    </table></div>");
           $("#loadeditlang").css({position:'absolute',  top:y, left:x});
            }
Великий и ужасный Гиоргий Каладзе