如果我的位置位于多边形之外,如何让Google地图显示对话框?

If I have an area defined (Polygon, image boundary, etc.) I want to be able to alert the user if their current position is outside of the geographic location / geofenced area in Google Maps. I am able to determine the location of the user through HTML5 geolocation fine, I just need to know how to display an alert if the user is using the webpage outside of the designated area. First time poster, please go easy on me. :)

  1. Load the geometry library with the google maps api.
  2. Use the containsLocation utility method to determine if the user's current location is within your geofenced area.
  3. Display an alert to the user.

For the alert itself, you have several options. The easiest way is to use a standard javascript alert call. You could also use a maps api infowindow or even a 3rd party lightbox overlay.