Quantcast
Channel: Appcelerator Developer Center Q&A Unanswered Questions 20
Viewing all articles
Browse latest Browse all 8068

Nearest location within 2 KMS

$
0
0
///current location/// if(Ti.Network.online){ Ti.Geolocation.purpose = "Receive User Location"; Titanium.Geolocation.getCurrentPosition(function(e){ if (!e.success || e.error) { alert('Could not find the device location'); return; } var longitude = e.coords.longitude; var latitude = e.coords.latitude; alert("latitude: " + latitude + "longitude: " + longitude); var func = Titanium.Network.createHTTPClient(); //alert ('saved'); func.setTimeout(25000); func.onload = function(e) { //alert ('saved4jmgl,'); Ti.API.info("onload"); svar = JSON.parse(this.responseText); //var totallength=results.length; //alert('totallength'); alert(this.responseText); alert(svar); }; func.onerror = function(e) { Ti.API.info("on error"); alert(e); }; var params1= { "geopoint": {"$nearSphere": { "__type": "GeoPoint", "latitude": latitude, "longitude": longitude }, "$maxDistanceInKilometers": 2.0 } }; //params1 =JSON.parse(params1); var par='https://api.parse.com/1/classes/save?where=tnagar'; Ti.API.info("param"+par); func.open('GET', par); func.setRequestHeader("X-Parse-Application-Id", "5X3FH6qXOQWHlmjvAeyXoaQ1OzlIaqkCPsivnybi"); func.setRequestHeader("X-Parse-REST-API-Key", "iLTqEiJSqHrxw2qbdI1UiVmujQm3i3b1NjeCM4rY"); func.setRequestHeader('Content-Type', "application/x-www-form-urlencoded; charset=utf-8"); //params1 = Ti.Network.encodeURIComponent(params1); //params = Ti.Network.encodeURIComponent(params); Ti.API.info("details"+JSON.stringify(params1)); func.send(); /////ending getting details///// }); } ////// getting details////// else{ alert("Internet connection is required to use localization features"); } This is my code and i am using parse to store my current address and geopoints.Now i need to get my nearest shops around me within 2 kms.I cant find solution for it.Can anyone help me out please.

Viewing all articles
Browse latest Browse all 8068

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>