【问题标题】:Getting the pixel co-ordinates of a Google map marker获取谷歌地图标记的像素坐标
【发布时间】:2010-12-05 21:37:14
【问题描述】:

是否可以确定给定标记的像素坐标,同时考虑当前的缩放级别和地图的可见区域?

【问题讨论】:

    标签: coordinates google-maps pixel latitude-longitude marker


    【解决方案1】:

    当前 (v3):

    map.getProjection().fromLatLngToPoint(marker.position);
    

    https://developers.google.com/maps/documentation/javascript/3.exp/reference#Projection

    旧版 (v2):

    假设markerPoint 是您的标记,zoomLevel 是您当前的缩放比例,下面的方法 fromLatLngToContainerPixel 应该会为您提供所需的内容:

    map.fromLatLngToContainerPixel(markerPoint.getLatLng(), zoomLevel);
    

    【讨论】:

    • 谢谢,这正是我需要的方法! (实际上应该是:'map.fromLatLngToContainerPixel(markerPoint.getLatLng(), zoomLevel);' 因为第一个参数应该是一个 GLatLng 对象。)
    • 已更新以反映 markerPoint 评论,并添加了文档的直接链接。
    • V3 不支持此方法。
    猜你喜欢
    • 1970-01-01
    • 2014-07-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-08-23
    • 1970-01-01
    • 2013-04-06
    • 1970-01-01
    相关资源
    最近更新 更多