i'm working on mobile application intel xdk (in background it's cordova finally, that's why put cordova in title.)
with ajax request, adresses , these adresses want calculate distance between them , current position of user.
so, adresses, convert them , make difference.
but actually, nothing working !
function codeaddress(id, addresse) { geocoder.geocode( { 'address': addresse}, function(results, status) { if (status == google.maps.geocoderstatus.over_query_limit) { settimeout(function(){}, 100); } console.log(id); console.log(addresse); //document.addeventlistener("intel.xdk.device.ready",function(){ if (navigator.geolocation) { if (status == google.maps.geocoderstatus.ok) { navigator.geolocation.getcurrentposition(function(position) { addressevent = results[0].geometry.location; var pos = { lat: position.coords.latitude, lng: position.coords.longitude }; var position = new google.maps.latlng(pos.lat, pos.lng) var resultat = google.maps.geometry.spherical.computedistancebetween(addressevent, position); console.log(resultat); console.log(addressevent); console.log(pos); console.log(position); var convert = math.floor(resultat); var finalconvert = convert + " m"; var distance = document.createelement('span'); distance.innerhtml = finalconvert; distance.classname = "geo"; document.getelementsbyclassname('meta-info-geo')[id].appendchild(distance); }, function() { handlelocationerror(true, infowindow); }); } } //},false); }); }
in console.log(id), console.log(addresse), have results !
actually i'm getting 4 ids , 4 adresses.
i checked on topics find on stackoverflow, , had add line in // addeventlistener changes nothing.
is there knows how change ?
ps : of course, cordova geoloc in build , permissions granted !
edit : i'm targeting android 4.0 min , ios 5.1.1. i'm using sdk.
geolocation not work way people expect work, variety of reasons have been expressed here , here.
you can experiment geo using "hello, cordova" sample app in xdk , available on github. try using on variety of devices see how things work. push "fine" button initiate single geo call "fine" location , push "coarse" button initiate single geo call "coarse" location. push "watch" button initiate request series of geo data points (set coarse or fine pushing 1 of single buttons first).
the behavior in emulate tab dramatically different on real device. type of device (android, ios, etc.) , version of device influence results; manufacturer of device , location (inside or outside) influence results. not assume making call geo apis give immediate , reliable data, geolocation hardware not work way... in fact, cannot assume can valid result! see 2 links pointed earlier in post reasons why.
Comments
Post a Comment