javascript - Google Map (API V3) 中的像素距离以避免标签/叠加层重叠

标签 javascript google-maps google-maps-api-3

计算 Google map 中坐标(纬度/经度)之间的像素距离的最佳方法是什么。我不是询问以公里/英里为单位的距离(因此我有一个 library ),而是考虑当前缩放系数的屏幕像素。

背景:我想在不重叠的情况下绘制叠加层。所以我需要计算这些位置的偏移量。因此,在较低的缩放系数下,500 公里的距离可能意味着叠加层重叠,而在 50 公里处则不会。

当然,任何其他不基于像素距离的避免重叠的算法都会受到赞赏。

-- 更新--

猜测是朝着聚类的方向发展,将检查这个:

  1. http://www.appelsiini.net/2008/11/introduction-to-marker-clustering-with-google-maps
  2. http://google-maps-utility-library-v3.googlecode.com/svn/tags/markerclusterer/1.0/examples/advanced_example.html

-- 更新--

很可能我可以在这里使用它:http://code.google.com/apis/maps/documentation/javascript/reference.html

google.maps.MapCanvasProjection.fromLatLngToDivPixel

为了获得投影,我将使用此处的答案:

  1. Pan point on Google Map to specific pixel position on screen (API v3)
  2. How to call fromLatLngToDivPixel in Google Maps API V3?

最佳答案

首先我发现我要找的是集群库/示例的主题:

  1. http://www.appelsiini.net/2008/11/introduction-to-marker-clustering-with-google-maps
  2. http://google-maps-utility-library-v3.googlecode.com/svn/tags/markerclusterer/1.0/examples/advanced_example.html

示例向我展示了一种方法 google.maps.MapCanvasProjection.fromLatLngToDivPixel,它需要 map 的投影。最终,以下主题揭示了如何获得此投影:

  1. Pan point on Google Map to specific pixel position on screen (API v3)
  2. How to call fromLatLngToDivPixel in Google Maps API V3?

关于javascript - Google Map (API V3) 中的像素距离以避免标签/叠加层重叠,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7092085/

相关文章:

javascript - 当单独定义列时使用 D3 加载 JSON

javascript - AngularJS:通过选项卡中的 Google Maps API v3 进行映射

java - 标记类的子类

google-maps - 我如何知道哪个标记正在被 Google Maps API 拖动事件拖动?

javascript - 如何访问 Google Maps JavaScript API v3 中的默认 KmlLayer

google-maps-api-3 - 在多边形叠加层之上显示自定义 MapType

javascript - 为什么我的 Javascript 在本地服务器上运行时无法访问 Twitter?

javascript - 是否有任何类似于 Whatever :hover htc? 的 jquery 插件或技术

javascript - 循环遍历 'distinct' 值并忽略重复项 - javascript

google-maps - iFrame 上的内嵌框阴影(Google 日历)