如何绘制折线区域,即服务覆盖区域,并使用 Google Maps API 和 PHP 检查访问者的地址是否位于该区域内?

发布于 2024-07-08 10:14:11 字数 637 浏览 4 评论 0原文

我是一家正在构建新网站应用程序的企业的所有者。 我的合作伙伴是负责开发的程序员,我们都没有对 Google Map API 或其折线/多边形区域功能有任何真正深入的经验。

我们需要一种简单的方法来捕获用户管理区域内的输入,我们的位置可以输入其服务覆盖区域信息,即琼斯大道以北的第一街,或距离位置地址 5 英里半径等,并具有 Google 地图 API 绘图折线边界。

然后,我们网站的访问者需要能够在查看我们某个位置的谷歌地图时看到此信息,并查看他们的服务地址是否属于该服务区域。 然后,我们需要以某种方式设置一个标志,以触发向访问者发出通知,告知其地址不符合服务或交付条件。

如果有人可以帮助我们(与建议的 API 接口的示例 php 代码将是首选和理想的,因为我们根本不了解 Google API、折线坐标捕获工具等的复杂性),我们将不胜感激,因为我们一直在努力弄清楚如何在 php 中创建它,更重要的是如何将它集成到我们现有的网站中。

更新:谢谢您的回答 CodeMeIT...建议我们如何在 sql 数据库中捕获这些 longlats...即字段格式或类型是什么,我们是否需要为 long 和 lat 有单独的字段,以及我们如何才能对所有位置进行标准化,即创建多边形区域需要多少经度和纬度,因为我们希望能够让我们的位置管理器从用户登录区域输入他们自己位置的此信息。

I am the owner of a business that is building a new website application. My partner is the programmer who is doing the development and neither one of us has any real in-depth experience with Google Map API or it's polyline/polygon area capabilities.

We need an easy way to capture inputs within our user admin area where our locations can enter their service coverage area info i.e. 1st street north of Jones blvd, or a 5 mile radius from the location address, etc. and have the Google Map API plot the polyline borders.

Then, visitors to our site need to be able to see this info when they view the google map for one of our locations and also see if their service address falls within that service area or not. We then need to set a flag somehow to trigger a notification to the visitor that their address is not eligible for service or delivery.

If anyone can assist us with this (example php code to interface with the suggested APIs would be preferred and ideal as we simply don't understand the complexities of the Google API, the polyline coordinate capture tool, etc), it would be greatly appreciated, as we have struggled to figure out how to create this in php and more importantly how to integrate it into our existing site.

Update: Thank you for your answer CodeMeIT...how do recommend we capture these longlats in our sql database...i.e. what is the field format or type and do we need to have separate fields for long and lat, and how can we standardize for all locations, i.e. how many long and lats are needed to create a polygon area, as we want to be able to have our location managers input this info for their own locations from their user login areas.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

内心旳酸楚 2024-07-15 10:14:12

在地图上绘制多边形

您可以在谷歌地图上绘制覆盖您的服务区域的多边形。 这些多边形由一组经纬度定义,您可以从谷歌地球收集这些经纬度并将它们保存在某个地方。 获得覆盖每个服务区域的所有坐标后,您可以查看链接以了解如何在 Google 地图上绘制它们

Google 地图多边形示例

检查用户是否在服务区域内

如果用户在某处输入或存储了地址信息,您可以将地址带到谷歌地图地理编码服务以找出该地址的纬度和经度。

Google MAP 地理编码服务 API

获取地址坐标后,该代码可以检查坐标是否在服务区域的多边形的任何边界内。 如果为 false,则不在服务区。

PHP 用于检查多边形中的点

Draw polygon on map

You can draw polygons that covering your service area on google map. Those polygons are defined by a set of latlongs that you can collect from a google earth and sasve them somewhere. Once you had all the coordinates that can cover your each service area, you can see the link to find out how to draw them on google map

Google Map polygons Sample

Check if user is within service area

If the user had address information entered or stored somewhere, you can take the address to google map geocoding service to find out the address's latitude and longitude.

Google MAP Geocoding Service API

After getting the address' coordinate, the code can check if the coordinateis within any bound of the polygons of your service area. If false, that is out of service area.

PHP for checking point in polygon

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文