[英]adding a static 1km grid to google maps using php
I want to create a grid that I'll be overlaying google maps.我想创建一个覆盖谷歌地图的网格。 The grid has to be static, meaning 1km² grid has to be exactly at the same location and has to be identifiable with a unique id.
网格必须是静态的,这意味着 1km² 的网格必须完全位于同一位置,并且必须使用唯一的 id 进行识别。 How can I achieve this in google maps and php?
我怎样才能在谷歌地图和 php 中实现这一点?
The best, redshark1802最好的,redshark1802
edit: Forgot to mention that I have to interact with these grids direclty, meaning changing color/style for each field.编辑:忘了提到我必须直接与这些网格交互,这意味着更改每个字段的颜色/样式。 I've found some site that did it already https://ownthisworld.com/
我发现一些网站已经做到了https://ownthisworld.com/
The answer to your question can be found in the Google Maps API (v3) .您的问题的答案可以在Google Maps API (v3) 中找到。
The basic approach here is:这里的基本方法是:
Extended information: If you know where to draw the grid, you also know where to draw the rectangles since the edges of the rectangles are basically line segments of the grid lines.扩展信息:如果您知道在哪里绘制网格,您也知道在哪里绘制矩形,因为矩形的边缘基本上是网格线的线段。 So how do you know where to draw the grid lines?
那么你怎么知道在哪里绘制网格线呢? If you decide on a standard zero point (for instance the point where the equator and prime Meridian meet), and basically start drawing grid lines from there, you will always have the grid lines (and thus rectangles) positioned on the same location.
如果您决定一个标准的零点(例如赤道和本初子午线相交的点),并基本上从那里开始绘制网格线,您将始终将网格线(以及矩形)定位在同一位置。 Note, you only draw those grid lines which are within map's view of bounds.
请注意,您只能绘制那些在地图边界视图内的网格线。 This way it is also fairly easy to identify a rectangle by for example it's top left corner...it will always be located on the same position.
这样也很容易识别一个矩形,例如它的左上角......它总是位于相同的位置。
maybe these examples will help: this is a fixed size grid - position it with the NW latlng and size it using the height and width variables也许这些例子会有所帮助:这是一个固定大小的网格 - 使用 NW latlng 定位它并使用高度和宽度变量调整它的大小
this is a grid that resizes and moves to cover the map area (more or less)这是一个调整大小并移动以覆盖地图区域的网格(或多或少)
both of them store the rectangles in the rectArr array, so you can manipulate their options, etc, by accessing that.它们都将矩形存储在 rectArr 数组中,因此您可以通过访问它来操纵它们的选项等。
You want a quadkey.你想要一个四键。 Geohash uses a similar system.
Geohash 使用类似的系统。 You can look for a L-system to write az curve or you can grab my code at phpclasses.org (hilbert curve).
您可以寻找一个 L 系统来编写 az 曲线,或者您可以在 phpclasses.org(希尔伯特曲线)上获取我的代码。 Here is good tutorial on how it works: http://blog.notdot.net/2009/11/Damn-Cool-Algorithms-Spatial-indexing-with-Quadtrees-and-Hilbert-Curves .
这是关于它如何工作的很好的教程: http : //blog.notdot.net/2009/11/Damn-Cool-Algorithms-Spatial-indexing-with-Quadtrees-and-Hilbert-Curves 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.