Home Sorting of record based on current Geo location
Reply: 0

Sorting of record based on current Geo location

tajinder singh
tajinder singh Published in 2017-11-14 22:17:57Z

I am creating an angular application which shows list of peoples of different cities. I have to make sorting base of distance of person's city from current location I have already find out my current longitude and latitude. However i also know how to find distance of a city from current location (Based on longitude and latitude) Belwo code i used to find distace of a person's city from my current location's longitude and latitude

var origin = new google.maps.LatLng('51.5033640', '18.5033640'),
    destination = $scope.people.City, //(e.g. Texas City, TX, United States)
    service = new google.maps.DistanceMatrixService();
        origins: [origin],
        destinations: [destination],
        travelMode: google.maps.TravelMode.DRIVING,
        avoidHighways: false,
        avoidTolls: false
function callback(response, status) {
    if (status == "OK") {
        if (response.rows[0].elements[0].status == "OK")
           var distance = response.rows[0].elements[0].distance.text;
           // Location of city from current distacen e.g. 50 KM
    } else {
        alert("Error: " + status);

It works good but its on client side. Means i have to load all peoples let say 10000 count and then apply above code to find distacnce and then sort them accordingly .

But i just have to show top 100 records near by my current location. My question is how can i get only near by persons from database . I am saving person full city e.g. Texas City, TX, United States in database for every person

Also if somehow i am able to get list near by cities from my current location then i can get result from my database based on these cities. But i am not able to get names of near by cities .Could anyone help me in this.

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.348394 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO