问题
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