Sunil Kothiyal
Sunil Kothiyal

Reputation: 177

How to find nearest user in google map using map API In Django?

I have a list of delivery agents(bikers) for a restaurant in the MYSQL database with longitude and latitude(updating in every 10 seconds). I want if the restaurant gets a new order, restaurant nearest agent will get the updating message.

I am stuck over how to do in Django. I know geoDjango is useful but it will give liner distance between two points.

Can someone help me to get the nearest user on the map?

Upvotes: 0

Views: 764

Answers (1)

rahul.m
rahul.m

Reputation: 5854

You can use django geopy here

geo_distance = great_circle(biker_latlog, hotel_latlog).miles

which will give the distance between hotel and biker guy

and further you can implement your logic

Upvotes: 1

Related Questions