Geolocation method to see if user in specific area

…衆ロ難τιáo~ 提交于 2019-12-24 00:57:50

问题


i'm developing an application for a Restaurant in Portugal called Olivier. Currently I'm studying geolocation api of phonegap, and I haven't find a way to solve my problem that is to check if the user position is inside the restaurant.

To be more specific I want my application to show a menu if the user is inside the restaurant area (trough geolocation) and to show a different menu if he's outside the restaurant area.

I would be glad if you answer a link to a guide or just write the method i'll need to use, so I can proceed with the application.


回答1:


If you're using google maps api:

You can use this: containsLocation(point:LatLng, polygon:Polygon) : Computes whether the given point lies inside the specified polygon.

to check if current geolocation is inside a given polygon (the restaurant area)

If you are not:

If your not using google maps API, im afraid u can only do an approximation by calculating the radius of the restaurant, and check if the distance between cur position and restaurant center is < than radius

Boa sorte com a aplicação :)



来源:https://stackoverflow.com/questions/16980424/geolocation-method-to-see-if-user-in-specific-area

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!