Google Map(API V3)中的像素距离,以避免重叠标签/叠加层 [英] Pixel distance in Google Map (API V3) to avoid overlapping labels / overlays

查看:177
本文介绍了Google Map(API V3)中的像素距离,以避免重叠标签/叠加层的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

计算Google地图中坐标(经纬度)之间的像素距离的最佳方法是什么?我不是询问以km /里为单位的距离(因此我有一个),但屏幕上的像素会考虑当前的缩放因子。背景:我希望绘制叠加而不重叠它们即可。所以我需要计算这些位置的偏移量。因此,在较低的缩放系数下,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. 将Google地图上的平移点移至屏幕上的特定像素位置(API v3) / how-to-call-fromlatlngtodivpixel-in-google-maps-api-v3>如何在Google Maps API V3中调用fromLatLngToDivPixel?


首先,我发现我正在寻找的是聚类库/示例的主题:

  • http:/ /www.appelsiini.net/2008/11/introduction-to-marker-clustering-with-google-maps

  • http://google-maps-utility-library-v3.googlecode.com/svn/tags/markerclusterer/1.0/examples/advanced_example.html

  • 这些例子显示了一个方法 google.maps.MapCanvasProjection.fromLatLngToDivPixel ,它需要一个投影的地图。最终,以下主题揭示了如何获得此预测:



    1. 如何在Google地图中调用fromLatLngToDivPixel API V3?


    What is the best way to calculate the pixel distance between to coordinates (lat/lon) in a Google Map. I am not asking about the distance in km/miles (therefore I have a library), but pixels on the screen considering the current zoom factor.

    Background: I want to draw overlays without overlapping them. So I need to calculate the offset for these positions. So in a lower zoom factor a distance of 500 km can mean the overlays do overlap, while at 50km they don't.

    Of course, any other algorithm to avoid overlaps not based on the pixel distance would be appreciated.

    -- Update --

    Guess is is going in the direction of clustering, will check this:

    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

    -- Update --

    Most likely I can use this here: http://code.google.com/apis/maps/documentation/javascript/reference.html

    google.maps.MapCanvasProjection.fromLatLngToDivPixel
    

    To get the projection I will use the answers here:

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

    解决方案

    First I found that what I am looking for is subject of the clustering libraries / examples:

    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

    The examples showed me a method google.maps.MapCanvasProjection.fromLatLngToDivPixel, which required a projection of the map. Eventually the following topics revealed how to get this projection:

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

    这篇关于Google Map(API V3)中的像素距离,以避免重叠标签/叠加层的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆